问题
I'm using WebStorm for web-development & have recently upgraded from the built-in TypeScript 1.4 compiler to 1.5.3. However, not everything went as I wanted as the compiler began to yield errors prompting me to drop the --module commonjs
parameter & switch to ES6 modules instead (I'm using --target es6
). Having done that, I started getting errors saying that import assignments cannot be used when targeting ES6 & that I should use the new module syntax instead (error 1202). So I converted all my files, but apparently it wasn't enough as the .d.ts
files installed via tsd
from the DefinitelyTyped repo use the old syntax making the compiler keep giving the same errors.
I wrote a small converter for the .d.ts
files, it works fairly well although occasionally makes me fix errors manually here & there. I'm wondering if there is a better workaround for this? Perhaps, I'm missing something?
P.S. Changing the --target
to es5
is not an option as the compiler would otherwise complain about absence of things like promises which I heavily use in my project.
回答1:
Changing the --target to es5 is not an option as the compiler would otherwise complain about absence of things like promises which I heavily use in my project.
Use --target es5 --noLib
and then bring in es6.lib.d.ts
manually.
来源:https://stackoverflow.com/questions/31568198/typescript-1-5-es6-modules-d-ts-files-from-definitelytyped-seem-incompatible