TypeScript Version: 2.0.0 (also 2.1.0-dev.20160801)
Code
// See full reduced example at https://github.com/thenoseman/typescript-2.0.0-exper-dec-error
tsconfig.json:
{
"compilerOptions": {
"experimentalDecorators": true
}
}
Expected behavior:
node_modules/.bin/tsc
should not raise error TS1219 because experimentalDecorators
option is set in tsonfig.json.Actual behavior:
❯ node_modules/.bin/tsc app.component.ts N 6.3.1
app.component.ts(7,14): error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.
Using node_modules/.bin/tsc --experimentalDecorators app.component.ts
works though.
This might be expected behaviour or I could have missed something. If so please close this issue.
Thanks for your hard work to give us all safer javascript!
Frank
Hey Frank, this has been reported a few times but has typically been linked to strange issues like invalid JSON in tsconfig files or things like that. I wasn't able to reproduce the issue from your repo. What editor & version are you using, and what OS are you on?
Based on the screenshot : https://raw.githubusercontent.com/thenoseman/typescript-2.0.0-exper-dec-error/master/tsc-bug-experimental-decorators.png
TypeScript does not automatically pick up a project file, you need to specify it explicitly with -p
option :rose:
Hi, thanks for responding so fast 👍
@DanielRosenwasser : I'm on MacOSX 10.11.6 running iTerm2 with zsh and macvim with tsuquyomi for TS support but compiling via the above commandline.
What @basarat said does fix my issue. Thanks!
Sorry to bother you further but just so I understand it correctly:
Compiling a single file (node_modules/.bin/tsc app.component.ts
) _doesn't_ load the tsconfig.json while compiling all at once via node_modules/.bin/tsc -p .
or tsc -p tsconfig.json
_does_ load it, right?
If so this would be a great addition to the documentation (If it isn't mentioned somewhere I haven't found).
Thanks,
Frank
Update:
Found the docs: https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/tsconfig.json.md
Update 2:
Does this also concern the use of _tsserver_? How does tsserver handle tsconfig.json
?
I'm having this issue still. I have the flag --experimentalDecorators
set on command and "experimentalDecorators": true,
inside tsconfig. It ignores all. Why?
Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.
EDIT: I found my mistake. I had the -p flag misunderstood, now I put the path of the .tsconfig after -p and it works.
ngc -p ./tsconfig.json
works
looks like the original issue is resolved. please reopen if there are other issues.
I still have this issue.
I am using VS Code 1.5.2 and created an Angular 2 Project with angular-cli.
My tsconfig is the following:
{
"compilerOptions": {
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"../node_modules/@types"
]
}
}
@meivin123 can you share a repro project i can try?
It is the default application generated with angular-cli.
Test App
When you open /src/app/app.component.ts it shows the warning.
tsconfig.json is located under /src/tsconfig.json
If it helps here I'm also getting "cannot find module" errors on top of the decorators error in vscode when using path mappings. The compiler compiles the code fine, but I can't use intellisense for any path mapped modules' exports.
Couple things I tried in vscode was using various versions (2.0 and next) of typescript installed both globally and locally and changed the vscode tsdk settings, but nothing seemed to work. At one point of switching between multiple versions, vscode was picking up the modules imported via paths error above, but it reverted back to errors shortly after. I've also ensured all tsconfigs in the project have experimentalDecorators turned on in case the default project top level tsconfig isn't the only one affecting it.
Just for good measure I tried running vscode "as administrator" to ensure there wasn't some weird permissions issue with file reading of tsconfig or path mappings.
If anyone has some more clues here I'm open to try them.
@RyanQuackenbush do you have a repro project you can share?
@mhegazy I'll try to put to something together here. It's hard to track down in a large project. It works fine in the ng cli that ghost mentioned above.
@mhegazy After looking further it seems to have been a combination of reloading vscode / building the project after a tsconfig change and a path mapping setup incorrectly. I'm not sure what exactly happened where I could compile fine and still get the vscode ts errors in the editor, but I don't want to spend more time on it.
Minor pain point I'll post which might help someone else searching:
error TS5063: Substitutions for pattern '<some path key>' should be an array.
Is referencing a tsconfig issue with the paths
field which _must_ be an array ( the docs ). I originally had this setup like jspm does. Would be nice to allow a string value here, but maybe "should be an array in the tsconfig path mappings" would help as well. I did notice via --traceResolution that if a string value is passed each character is iterated over for path resolution attempts as if it was an array though.
I thought this was resolved, but it's still happening. It looks to be related to https://github.com/Microsoft/TypeScript/issues/12618
This happened to me today on WebStorm 2016.3.3 @ Debian Linux - finally, the only action that helped was "File" > "Invalidate Caches / Restart" > "Invalidate and Restart".
Hello there! I have the same problem with PhpStorm, but Invalidate Caches / Restart
command is not helping. Here's my tsconfig.json
:
{
"compilerOptions": {
"module": "commonjs",
"target": "ES6",
"alwaysStrict": true,
"listEmittedFiles": true,
"noImplicitAny": true,
"outDir": "dist/",
"pretty": true,
"removeComments": true,
"sourceMap": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"typeRoots": [
"node_modules/@types"
]
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules/"
]
}
The error is shown by the IDE on the class name in this code block:
@Injectable()
class Engine {
constructor () {
console.log('Engine is created');
}
}
I'm also using DI from Angular 2, but for my server-side project (Node.js).
I only get this error when an "include" block is present in the tsconfig.json.
I am also getting this error when there is either an "include" block, a "files" block, or both blocks present in the tsconfig.json. I am using IntelliJ IDEA on Win7.
I solved this issue in IntelliJ by renaming tsconfig.app.json
to tsconfig.json
.
Most helpful comment
This happened to me today on WebStorm 2016.3.3 @ Debian Linux - finally, the only action that helped was "File" > "Invalidate Caches / Restart" > "Invalidate and Restart".