New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allowSyntheticDefaultImports should be the default? #10895
Comments
A simple node project won't do the magic binding so I think it should be off by default. |
The scenario is that users want to use ES6 style imports, but some typings for modules do not yet use ES6 style exports. As an example @waderyan an experienced JS and VS Code user thought Intellisense is broken in JS until we pointed him to this this setting. There is no feedback to the user that there are no suggestions because an imported module doesn't use ES6 exports. |
one thing to note, Since there is no native implementation for module loading, if the loader/transpiler does not support this transformation, the es6 code will not work. |
If we believe most JS users need this, I have no problems switching the default. |
Based on numerous customer observations, I believe this is the case. |
what does this do? I'm having issue with default imports:
Is transpiled to:
Where as it should be
None of the stuff seems to be working with .default syntax. Currently my tsconfig.json is:
The allowSyntheticDefaultImports didn't seem to fix this? |
In general, we should think this through since all of this is subject to change depending on how Node defines their interop behavior. I suspect that in Salsa (our JS editing experience), we should switch the default experience because users are probably using Babel if they are using ES modules. |
That clarifies things. Thought that this was going to switched on by default on TS as well. I don't know the numbers but I suspect a big bunch of TS devs are node devs, which means no magic default bindings. If this is switched on by default that means many TS users will run into this opposite issue. Opposite meaning importing a module and not working on runtime. |
Does it make more sense if this is a default option for |
The only numbers that make sense in computer science are 0, 1, and Infinity. we are past 0, and 1, so i guess we have some room to add more defaults here :) |
I think this will cause more confusion than good. |
The change only affects the default value of Node users, however, may be surprised if they use the syntax and things break at runtime. Though it is a debate between the perception of "js intellisense if broken" and "this specific feature is assuming the wrong thing for some users", I would think the former does more harm. |
I would be satisfied if Also perhaps it makes sense for something like ts-loader (webpack) to override this value since webpack will do the magic transformation. |
We are investigating into simplifying the getting started experience for JS/ES6 projects.
One obstacle we have found is that users are surprised that Intellisense doesn't when they use ES6 style imports. The remedy is tell them to set
allowSyntheticDefaultImports
to true and we have a trouble shooting section on this in our docs.Is there any reason why this setting cannot be true by default for JS projects?
CC @waderyan
The text was updated successfully, but these errors were encountered: