Incorrect TS1219 warning

-- Temporary Fix. Shutdown Webstorm and deleted the .idea folders and it realised that the files it thought were broken weren't. Unfortunately new files are getting the warning until I repeat this. it's a massive pain in the a**e.

 

I'm having a minor annoyance with the latest version of webstorm, it's got a liberal smattering of TS1219 errors on my Angular 2 project targeting @Component() @Input() etc, but not in all files.

It compiles fine as I have the experimentalDecorators set to true, but it's annoying to have red splattered all over the place.

 

This one is fine:

This one isn't:



32 comments

Do you mean that you get TS1219 errors despite having experimentalDecorators enabled in your tsconfig.json? What does your config look like? How many tsconfig.json files do you have in your project?

Also, please can you provide full output from TypeScript tool window, Errors tab, shown for the file that is red-highlighted? What IDE version do you work with?

0

I don't get the errors in compile, just in the IDE, lots of files are marked as having errors, and lots of lines are underlined in red. It gets in the way of spotting real errors.

I have 2 and they look like:

{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"noEmit": true,
"noEmitHelpers": true,
"importHelpers": true,
"strictNullChecks": false,
"lib": [
"dom",
"es7"
],
"typeRoots": [
"node_modules/@types"
],
"types": [
"hammerjs",
"jasmine",
"node",
"source-map",
"uglify-js",
"webpack"
]
},
"exclude": [
"node_modules",
"dist",
"**/*.spec.ts"
],
"awesomeTypescriptLoaderOptions": {
"forkChecker": true,
"useWebpackText": true
},
"compileOnSave": false,
"buildOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}

and

{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"noEmit": true,
"noEmitHelpers": true,
"importHelpers": true,
"strictNullChecks": false,
"lib": [
"es2015",
"dom"
],
"typeRoots": [
"node_modules/@types"
],
"types": [
"hammerjs",
"node"
]
},
"exclude": [
"node_modules",
"dist",
"**/*.spec.ts",
"**/*.e2e.ts"
],
"awesomeTypescriptLoaderOptions": {
"forkChecker": true,
"useWebpackText": true
},
"angularCompilerOptions": {
"genDir": "./compiled",
"skipMetadataEmit": true
},
"compileOnSave": false,
"buildOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}


The IDE version is: WebStorm 2016.3.4 Build #WS-163.13906.20, built on March 7, 2017

0

Where are these files located? What TypeScript version is chosen in Preferences | Languages & Frameworks | TypeScript?

Output from Error tab would still be appreciated

0

The files are located in, or a subfolder of a folder called app, which is located directly below the root.

 

Where do I find the error tab?

0

Ok this is what's showing up:

0

So, WebStorm has failed to find a tsconfig.json your file belongs to. What TypeScript version is chosen in Preferences | Languages & Frameworks | TypeScript? Do you have any symlinks/junctions in your project?

0

Typescript version is 2.2.2, there are no symlinks or junctions in the project.

0

Try using the bundled TypeScript instead - does the problem persist?

0

The issue goes away using the bundled version of typescript

0

I see. So it seems that the service support in 2016.3 is not compatible with TypeScript 2.2.2. Please try upgrading to 2017.1.2

0

I have the same issue with intelliJ 2017.2.1. I use the bundled version (2.4.1) and still get this annoying warning. 

0

What warning, sorry? Is it about 'cannot find parent tsconfig.json' message? This warning indicates that file your are currently editing is not included in any tsconfig.json file

0

No. I am talking about the experimentalDecorators warning coloring the code in red even though it is enabled.

0

Most probably it's still the same issue - your current .ts file is not included in any tsconfig.json file, thus the default preferences are used for transpiling

0

I get this error ('cannot find parent tsconfig.json') just by using 2017.3 beta

If I run 2017.2.4 - no issue

0

Please provide a project that shows up the issue. Also, what TypeScript version is chosen in Settings | Languages & Frameworks | TypeScript?

0

I'm having this issue as well, Settings | Languages & Frameworks | TypeScript shows: "2.6.2 (node_modules)"

I'm running IntelliJ Ultimate, 2017.2

My tsconfig.json looks like: 

{
"compilerOptions": {
"sourceMap": true,
"target": "es5",
"jsx": "react",
"module": "es6",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"declaration": false,
"noImplicitAny": false,
"noImplicitReturns": false,
"removeComments": true,
"strictNullChecks": false,
"outDir": "build",
"lib": [
"es6",
"es7",
"dom"
]
},
"exclude": [
"dist",
"build",
"node_modules"
]
}

And tslint.json:

{
"extends": "tslint-config-airbnb",
"compilerOptions": {
"experimentalDecorators": true,
"allowJs": true
}
}

Removing the `.idea.` folder and re-opening the project fixes it for a while, but the problem comes back, not sure what triggers it to return yet.

0

Ah, I just understood what you meant - apparently IntelliJ doesn't handle "include" in tsconfig.json the same as typescript does?

Adding an "include" section to tsconfig.json fixed the issue:

"include": [
"src",
"types"
]


People will keep having this problem though, since not specifying "include" at all seems to common in several of the popular react+typescript boilerplate projects.

I got this tsconfig.json from https://github.com/mobxjs/mobx-react-typescript-boilerplate/blob/master/tsconfig.json

0

>apparently IntelliJ doesn't handle "include" in tsconfig.json the same as typescript does?

Not sure where this conclusion come from... IDEA handles it EXACTLY in the same way as the tsc compiler; moreover, it uses the typescript tsserver service for this, it's not the own IDE functionality. No "include" is required - everything that is not excluded is included

>Settings | Languages & Frameworks | TypeScript shows: "2.6.2 (node_modules)"

that's the issue - tsserver integration doesn't work with TypeScript 2.6 due to breaking API changes, it's fixed in 2017.3. You have to either upgrade IDEA or change the TypeScript version to the bundled one

0

Btw I'm experiencing same sort of issues (Tsconfig not found or it is not taken into account properly) with 2017.3, ts 2.6.2, but issues disappear if using bundles 2.6.1 version

0

I have a similar issue for a different error code, but don't know how to solve it. In my case the error is TS2551, it appears in each file and I am using Intellij. The error marks go away, as soon as I close the file and relaunch Intellij. After opening the ts-file again, error messages appear again. Any idea what I could do?

0

@Chris, could you please provide more details on your issue:

1) full output of Errors tab of TypeScript tool window,

2) tsconfig.json and its location,

3) version of TS selected in TS settings (Settings (Preferences) | Languages & Frameworks | TypeScript),

4) IDE version

0

Dear Oksana,

1) just realized there are actually two different errors:

  • TS2304: Cannot find module name [VARIABLE]
  • TS2551, TS2339: Property [VARIABLE] does not exist on type [VARIABLE]

2) sorry, I am not sure what you mean by tsconsig json? I am contributing to a project that had been set up already and never dealt with typescript before...

3) Bundled 2.8.1

4) Intellij Idea Ultimate (2018.1.5)

0

1) please provide a screenshot of the complete output of TS Errors tab.

2) it's a TypeScript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html

0

WebStorm 2018.1.4 still experiencing the same issue.

 



tsconfig.json :

{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"noImplicitAny": true,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"declaration": false,
"sourceMap": true,
"noUnusedParameters": true,
"skipLibCheck": true,
"lib": [
"dom",
"dom.iterable",
"es7",
"scripthost",
"es2017"
],
"types": [
"node",
"jasmine",
"cordova-plugin-network-information",
"jest"
],
"baseUrl": ".",
"paths": {
"@mocks/*": ["src/common/core/mocks/*"],
"@common/*": ["src/common/*"]
}
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"coverage",
"resources",
"plugins",
"platforms",
"www"
],
"compileOnSave": false,
"atom": {
"rewriteTsconfig": false
},
"awesomeTypescriptLoaderOptions": {
"forkChecker": true,
"useWebpackText": true,
"useCache": true
}
}

0

Passing --tsConfigFile tsconfig.json to options fixes the issue.

0

I am also seeing the experimentalDecorators error in Intellij 2018.2.1. Adding --tsConfigFile tsconfig.json to options did not work for me. I have tried the bundled typescript version and or Angular Cli typescript version. Both have the same issue. This use to all work without issues in early versions of 2017. Now it has been rather flaky.

TSCONFIG.JSON

{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"baseUrl": "src",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2016",
"dom"
]
},
"include": [
"src/**/*"
]
}

0

>Adding --tsConfigFile tsconfig.json to options did not work for me

options specified in this field are only respected if the project doesn't have any tsconfig.*.json files

>I am also seeing the experimentalDecorators error in Intellij 2018.2.1. 

what file(s) is it shown for? Please provide a screenshot of Typescript tool window with the error

Please make sure that tsconfig.*.json file this file is included in has "experimentalDecorators" enabled. Note that tsconfig.app.json, tsconfig.spec.json, etc. are also considered (they were not respected in 2017.x)

0

> options specified in this field are only respected if the project doesn't have any tsconfig.*.json files

Thanks for informing about the options. I did not know that.

 

> what file(s) is it shown for? Please provide a screenshot of Typescript tool window with the error

Since commenting I tried a couple other things. I changed back to the bundled version and created a custom scope which points at my .ts locations. So far the warning has not came back. I am not sure what made the difference. If it was the change to use the bundled version (maybe needed some time to reindex everything? ) or if it was changing my project scope? If it comes back I will try to add some more details to this thread.

1

Please sign in to leave a comment.