TypeScript type missmatch inspection not working

I have a TypeScript project in WebStorm on Ubuntu 16 and the type missmatch inspection doesn't work.

Type missmatch inspection is on in the editor settings and other inspections (e.g. equality operator may cause type coercion) do work.
Yet the following code isn't highlighted for not matching return type or assignment type.

class MyClass {
private
test: number;

getTest(): string{
if(this.test == undefined){
this.test = "1" as string;
}
return this.test;
}
}
20 comments
Comment actions Permalink

works fine for me:

please make sure that inspection is turned on, file highlighting level is 'Inspections' and Power Save mode is not enabled

0
Comment actions Permalink

Inspection is turned on, file highlighting is at 'inspections' and power save is disabled. Even running the inspections manually finds errors from other inspections (spelling etc.) but not the type missmatch errors.

0
Comment actions Permalink

Try invalidating caches (File | Invalidate caches, invalidate and restart) - does the problem persist? Also, is the issue specific to certain file/project?

0
Comment actions Permalink

Invalidating caches didn't work. However I found out that the problem is only present in one project. The inspection works correctly in others.

0
Comment actions Permalink

can you share the project that shows up the issue? may be, a test .ts file inspection doesn't work for, plus your .idea folder?

0
Comment actions Permalink

Unfortunately I can't upload it here. What could be the problem? What should I be looking for?

0
Comment actions Permalink

This forum doesn't support attaching files:( You can upload the project to some file server and provide a link

0
Comment actions Permalink

Unfortunately I am not allowed to share the project.

The project was previously been worked on with PyCharm community edition. Could that have set some properties in a way that disturbs the type missmatch inspection?

0
Comment actions Permalink

No, unlikely... Unfortunately I can hardly help unless you provide the project:( You can try to figure out the reason yourself by comparing the project it doesn't work in with your other projects.

You can also try deleting and re-creating project `.idea` folder - but I'm not sure if it helps, and you will lose all your project-specific settings, run configurations, etc.

0
Comment actions Permalink

I deleted the .idea folder and reopened the project. It still doesn't work. The appropriate inspection is still on. The .iml file in my idea folder looks like this:

<module type="WEB_MODULE" version="4">
    <component name="NewModuleRootManager">
        <content url="file://$MODULE_DIR$">
            <excludeFolder url="file://$MODULE_DIR$/.tmp"/>
            <excludeFolder url="file://$MODULE_DIR$/temp"/>
            <excludeFolder url="file://$MODULE_DIR$/tmp"/>
        </content>
        <orderEntry type="inheritedJdk"/>
        <orderEntry type="sourceFolder" forTests="false"/>
    </component>
</module>

0
Comment actions Permalink

well... Providing the whole project is the only way to track down the issue then

Module file above a basic auto-generated .iml file, there is nothing wrong with it.

0
Comment actions Permalink

Here is the content of the .project file if it helps:

<projectDescription>
    <name>Phoenix Client</name>
    <comment/>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.wst.validation.validationbuilder</name>
            <arguments></arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
    </natures>
</projectDescription>

There are not that many non-source files in that project. Basically just .project, .gitignore and the .git and .idea folders.

0
Comment actions Permalink

it's not helpful unfortunately. This is Eclipse project file that is not used by IDEA

0
Comment actions Permalink

I have tracked down the difference between the project where the inspection works and where it doesn't.

The malfunctioning project has a lot in its node_modules folder including a typescript and a .bin folder. The other just has a svg.js folder corresponding to the svg.js module I clearly remember installing via npm.

0
Comment actions Permalink

So after invalidating some caches I now managed to have the errors detected and shown in the console in the bottom bar. Now the question is: How do I get the errors to be shown in the code?

0
Comment actions Permalink

So, it is about TypeScript compiler errors not being shown in the editor, not about WebStorm own inspections:) You should have mentioned this in your very first message - this would save a lot of time...

Questions:

- What TypeScript version is chosen in Settings | Languages & Frameworks | TypeScript?

- What WebStorm version is it?

- do you have any symlinks in your project path?

0
Comment actions Permalink

It was originally about the WebStorm's own inspections. I have just managed to have them run at all and previously it didn't show even in the console.

- TypeScript version is 2.6.2

- WebStorm 2017.3.3
Build #WS-173.4301.22, built on January 15, 2018
Licensed to Roberts Kolosovs
Subscription is active until January 4, 2019
For educational use only.
JRE: 1.8.0_152-release-1024-b11 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.4.0-109-generic

- Yes, the folder containing the project is accessed via a symlink. In the project folder itself there are no symlinks.

0
Comment actions Permalink

>It was originally about the WebStorm's own inspections. I have just managed to have them run at all and previously it didn't show even in the console

WebStorm own inspections are never shown in the console. And if the TypeScript service is enabled, WebStorm inspections are suppressed in favor of TypeScript compiler errors

 

>Yes, the folder containing the project is accessed via a symlink.

 

This is the issue (https://youtrack.jetbrains.com/issue/WEB-30318). Please try opening the folder from the actual path insted.

0
Comment actions Permalink

That solved the problem.

Thank you, Elena and sorry for the long back an forth. I got confused between what were the WebStorm's inspections and what were compiler errors.

1

Please sign in to leave a comment.