TypeScript: importHelpers option causes compiler errors
TypeScript Version: 2.2.1
Environment:
- Windows 10
- Node 7.6.0
- NPM 4.1.2
- TypeScript 2.2.1
- tslib 1.6.0
The recently added compiler option “importHelpers” causes compiler errors. There are several other closed issues where this problem was described: #12724, #12775, #12. This should be fixed, in TS 2.1.5 or 2.2.x but it still occurs. It’s a simple compiler error in the CLI. In vscode (latest version 1.10.1) the “extends” keyword causes the error.
I created a small skeleton which demonstrates this bug: https://github.com/code-chris/tslib-compile-error. This was tested on a windows machine with the specs above.
Expected behavior: There’s no compilation error when “importHelpers” option is enabled.
Actual behavior: The compilation result is runnable and correct, but there’s a compilation error like this:
src/main.ts(5,19): error TS2354: This syntax requires an imported helper but module 'tslib' cannot be found.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 18 (1 by maintainers)
To summarize: The problem isn’t the
--importHelpersoption, it’s that different people have had module resolution fail for various reasons. There’s no real bug here, but we could do more to help people understand why they’re getting resolution failures. I’ve created #15845 to track that.That shows that you’re using classic resolution. That is usually bad if you are using NPM, so you might want to try
"moduleResolution": "node".As I’m using
jspmwith its folder structure andmoduleResolution: "classic"I had to setup the right path mapping intsconfig.jsonMaybe this example helps someone else to sort out the issue.