New user confusion: as soon as you supply a .swcrc file, swc stops recognizing Typescript syntax #7724
jfirebaugh
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the bug
Hi, just wanted to share my perspective on a point of confusion I encountered as a brand new swc user. Hopefully it's helpful as insight on something that could potentially be improved in the user experience of swc. If not, feel free to close this issue!
I first started using swc without any config file and was happy to find that it could transpile all my .ts files without any issues. Yay!
Then I noticed that the output module format was the same as the input (ES6). I actually need CommonJS output. So, following the documentation I found here, I added an .swcrc file with:
This didn't work. The commands that were formerly working were now producing all kinds of confusing errors. It looked like swc stopped recognizing TypeScript syntax at all!
It took me a while to figure out that as soon as I added an .swcrc file, I needed to start explicitly telling swc that my .ts inputs were in fact TypeScript, by adding
"syntax": "typescript"
to the .swcrc file.It seems like swc could have handled this better. In decreasing order of personal preference, here are some suggestions:
"syntax": "typescript"
in the .swcrc, swc could default to interpreting .ts (and .tsx) files as TypeScript, as it seems to do just fine when there is no .swcrc file."syntax": "typescript"
to the .swcrc file."syntax"
is not exactly"ecmascript"
, but depends on whether or not an .swcrc file exists or not. (This seems like an inherently confusing behavior though, so I'd recommend avoiding it if possible.)Input code
No response
Config
No response
Playground link
No response
Expected behavior
See above
Actual behavior
No response
Version
v1.3.61
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions