ember -v hereember-cli: 3.5.1
node: 10.14.1
os: darwin x64
tsc -v hereVersion 3.2.2
tconfig.json and tslint.json or eslint.json (if applicable) belowMy tsconfig.json
{
"compilerOptions": {
"target": "es2017",
"allowJs": true,
"moduleResolution": "node",
"isolatedModules": true,
"allowSyntheticDefaultImports": true,
"noImplicitAny": true,
"noImplicitThis": true,
"alwaysStrict": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noEmitOnError": false,
"noEmit": true,
"inlineSourceMap": true,
"inlineSources": true,
"baseUrl": ".",
"module": "es6",
"paths": {
"isolated-modules-error/tests/": [
"tests/"
],
"isolated-modules-error/": [
"app/"
],
"": [
"types/"
]
}
},
"include": [
"app//",
"tests//",
"types/*/"
]
}
ember new sample; cd ./sample
ember install ember-cli-typescript@next
ember s
I expected to not see any type errors right off the bat.
(I did expect a build error, because I haven't yet installed babel, but the type error I am reporting occurs regardless of babel understanding TS. This is just the minimum number of steps to reproduce.)
TypeScript complained about this:
config/environment.js:1:1 - error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided.
1 'use strict';
~~~~~~~~~~~~
I tried:
module.exports.So the type error is preferable, but just letting you know that the out-of-the-box types are confused about that env file.
We shouldn't even be compiling this at all. I'm not sure how or why it's ending up in the pipeline. @dfreeman any thoughts?
It looks like it's because of the relative import in the default test-helper.js in new projects. I'm not sure why the blueprint uses a relative import instead of an absolute one there, but because that happens to point to the actual path on disk of the config.js node module, TS is attempting to actually resolve that file.
Playing around locally, changing that to an absolute import (<app-name>/config/environment) or flipping allowJs off in tsconfig.json prevents TS from trying to load the file at all. @chriskrycho do you remember why we default to allowJs: true?
IIRC it's because the language server also uses that and you need it set to true to get it to resolve correctly across the TS/JS boundary for mixed codebases.
Ahh, that makes sense.
We might consider just turning isolatedModules back off by default for 2.0 projects. It's recommended for anyone using Babel for transpilation, but in practice it doesn't actually seem to catch usage of many of the problematic constructs, so it may be more trouble than it's worth.
For what it is worth, isolatedModules happens to be the reason I am getting errors (that I simply ignore) on some of my @types packages. Like @types/jquery. I didn’t mention that originally because I thought there was a chance it was “my fault” for those.
Fixed by #511 (now live as part of v2.0.0-rc.2). Thanks again for the report!
Most helpful comment
Ahh, that makes sense.
We might consider just turning
isolatedModulesback off by default for 2.0 projects. It's recommended for anyone using Babel for transpilation, but in practice it doesn't actually seem to catch usage of many of the problematic constructs, so it may be more trouble than it's worth.