typescript 'symbol cannot be properly resolved'

Answered

Hi,

I'm using ReSharper Ultimate 2016.2.2 and I have an issue in typescript support. I'm writing a React js application and I have this code:

import * as React from "react";

interface IComponentProps<TParams> extends ReactRouter.RouteComponentProps<TParams, {}> { }

class ComponentBase<TParams, TProps> extends React.Component<IComponentProps<TParams> & TProps, {}> { }

class Details extends ComponentBase<{ id: number }, { show: string }> {
    render() {
        var show = this.props.show;
        var id = this.props.params.id;
        return (
            <div className="container"></div>
        );
    }
}

When I try access this.props.params.id ReSharper is complaining that "Symbol 'id' cannot be properly resolved, probably it is located in inaccessible module". Typescript compiler is doesn't complain however, and it compiles correctly. When I turn off ReSharper visual studio is also correctly showing this in IntelliSense.

Should this be raised as a bug or maybe I'm doing something wrong?

Regards,

Maciek

62 comments
Comment actions Permalink
Official comment

Hello Maciej,

Thanks for the reply, I filed a new ticket to YouTrack https://youtrack.jetbrains.com/issue/RSRP-461471, feel free to comment/vote for it.

Thanks!  

Comment actions Permalink

It didn't help unfortunately. With 2016.3 EAP 5 I still have same error.

0
Comment actions Permalink

I think I'm having similar issues. I'm not using React. For me Resharper can't recognize basic DOM elements, for example: "cannot resolve symbol 'window'".

For me as well, both Visual Studio and WebPack's ts-loader are compiling the TypeScript with no issues.

This issue may be fixed in the EAP releases but all of them (including the latest version 7) hang (with high CPU usage) when opening .ts files. The last message that the status bar is showing is "Analyzing".

1
Comment actions Permalink

Hello Evgeny,

Does Visual Studio hang forever? If so, please follow https://resharper-support.jetbrains.com/hc/en-us/articles/206546619-What-to-do-if-Visual-Studio-with-ReSharper-hangs-completely-.

As for "cannot resolve symbol 'window'" - are you able to reproduce the same issue in a demo project? 

Thanks!  

0
Comment actions Permalink

Hi, i have some similar issues in my VS2015 project on ReSharper Ultimate 2016.3.EAP8.

I cannot create test solution with these bugs because I don't understand their reasons. I have only screenshots of my code.

In the first screen, I have one error in two similar code snippets.

In the second screen I have the unresolved "forEach" symbol for the array:



And it's not all issues, it's only two of many issues in my project.

0
Comment actions Permalink

@Evgeny Rudavsky: Please try 2016.3 EAP 9, the performance issue you mentioned should be fixed there.

@Maxim Mileshin: This issue should also be fixed in the EAP 9. Please tell if it is still reproducible for you.

0
Comment actions Permalink

Hi, Anton, the first issue has been fixed in EAP 9, thanks.

The second issue is still reproducible.

This is the code that reproduces the problem:

namespace Issue {
    export function func(definition: IProductDefinition) {
        const surfaces = definition.surfaces;
        if (isISurfacesFromFolder(surfaces)) {} else {
            surfaces.forEach(() => {});
        } 
    }
    function isISurfacesFromFolder(arg): arg is ISurfacesFromFolder { return true; }
    interface IProductDefinition { surfaces: string[] | ISurfacesFromFolder; }
    export interface ISurfacesFromFolder { designFolder?: string; }
}

And i have two snippets with issue, that can reproduce bug with the same error text:

1:

const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
svg.style.position = "absolute";

2:

const svgPath = document.createElementNS("http://www.w3.org/2000/svg", "path");
svgPath.getBBox();

 

If it's needed, I can create bug report with little solution for all these examples.

 

 

0
Comment actions Permalink

@Maciej Moron The issue should be fixed in EAP 10, please try and tell whether it helps or not. Thanks! https://confluence.jetbrains.com/display/ReSharper/ReSharper+2016.3+EAP

 

@Maxim Mileshin Overload resolution issue reported by you should be fixed in EAP 10 which is published now. Fix for the other issue reported by you comes in the next EAP 11.

0
Comment actions Permalink

@Anton Lobov - it works now. Thanks.

0
Comment actions Permalink

@Maciej Moron Great. Thanks for confirming!

0
Comment actions Permalink

I'm still seeing this issue in ReSharper Ultimate 2016.3.1. 

With ReSharper On:

With ReSharper suspended:

This is more annoying than it is a problem.

3
Comment actions Permalink

@Chris This is because TypeScript 2.1 introduced syntax changes to lib.d.ts, which ReSharper 2016.3.x doesn't understand. 2016.3.x will support TypeScript 2.0 maximum.

TypeScript 2.1 will be supported starting from ReSharper 2017.1 (EAP will open in the beginning of February).

0
Comment actions Permalink

This is quite strange, I was using Typescript 2.1.5 and it was working for a while. Then today I'm getting these errors in almost all my Typescript files.

 

Using Resharper 2016.3.2

0
Comment actions Permalink

@Tersius Thanks for the info. We're going to publish the first EAP of 2017.1 very soon (supposedly, during this week), it supports TypeScript 2.1 and has initial bits of support for TypeScript 2.2.

0
Comment actions Permalink

Has this been fixed? I still have this problem on my home computer, but not on my work computer. When I disabled Javascript and Typescript in Resharper the problem goes away in my .ts files.

I'm using Resharper 2016.3.2 and Visual Studio 2017 in both environments.

At work, where it's working, I have windows 10.

On my home computer I have windows 7.

0
Comment actions Permalink

Dan, it may depend on TypeScript version you use and version of React typings.

ReSharper 2016.3 doesn't support TS 2.1 and 2.2. Both 2.1 and 2.2 are supported in ReSharper 2017.1 EAP: https://www.jetbrains.com/resharper/eap/.

With old React .d.ts files everything works fine. With one of the recent updates, it stopped: https://youtrack.jetbrains.com/issue/RSRP-463227. This issue will be fixed for the release version of 2017.1, anyways.

Thanks for the info.

0
Comment actions Permalink

 I am having this issue too in R# 2017.1. giving error in so many properties. But typescript compiles successfully.

 

0
Comment actions Permalink

@ Balasubramanian Ramanathan

Thanks for the report, this issue was already reported, and will be fixed soon: https://youtrack.jetbrains.com/issue/RSRP-464603.

0
Comment actions Permalink

I think I am seeing this also with the r# 2017.1.2, also the import at the top of the page is saying that it isn't implemented, we just started using angular aot (ahead of time compilation) 

 

2
Comment actions Permalink

Turns out that clearing the local cach resolved this for me.

2
Comment actions Permalink

@Daniel Harvell Thanks for the info. Yes, there still exist few cases in which ReSharper TS caches become inconsistent after huge NPM updates. Clearing caches and reopening the solution should help in such cases. We're working on a fix for this issue for the next version of ReSharper.

0
Comment actions Permalink

It seems like there is still an issue with symbols not resolving properly in typescript. I'm using r# 2017.1.3.

Is there a fix for this or an active issue?

0
Comment actions Permalink

@Andy Harl: If you use TypeScript 2.3 or later, please upgrade to ReSharper 2017.2 EAP: https://www.jetbrains.com/resharper/eap/.

There were breaking syntax changes in lib.d.ts.

0
Comment actions Permalink

I'm also having this described problem with the very latest version (2017.2 EAP12). 

Typescript Version is set as 2.2

As you can see from the screenshot, it actually identifies seems to be able to identify the type of the property, but still shows it as non-accessible.

0
Comment actions Permalink

@Philipp Feigl. Thanks for your report. What is the type of "result"? Is AuthResponse a mapped type or an intersection type? If those methods "post" and "do" are part of some public npm package, could you please tell me the name of it, I'll try to reproduce the issue. Thanks.

0
Comment actions Permalink

Here is the complete source for AuthResponse:

export class AuthResponse {
    public access_token: string;
}

"do" is from an Observable

And this is how post looks like:

protected post<TResult>(path: string, data?: any, options?: {
    headers?: HttpHeaders,
    observe?: 'body',
    params?: HttpParams,
    reportProgress?: boolean,
    responseType?: 'json',
    withCredentials?: boolean,
}): Observable<TResult> {
    return this.httpClient
        .post<T>(this.toUri(path), data, options)
        .catch(this.handleError);
}

Whereas "httpClient" is the new httpClient from Angular 4.3 and "handleError" looks as the following:

protected handleError(error: any) {
    console.log(error);
    return Observable.throw(error);
}

0
Comment actions Permalink

Just FYI - I had this problem application widespread using the newest version 2017.2.1 and the suggestion to clear the cache (ReSharper -> Options -> General -> Clear caches button) actually worked. After pressing the button and restarting VS 2017, all of my symbols, imports, etc. in .ts files resolved and were working again. Maybe something the ReSharper team should look into. Also upon installing a new version maybe this should happen automatically. Regardless, it throws people for a loop, and honestly for a while I just turned of ReSharper which didn't help my desire to want to renew.

3
Comment actions Permalink

I'm having the same or similar issue, using 2017.2.1, and clearing the cache as not helped.  I'm simply importing the lodash library and calling a method.  The typescript compiler has no problem with it, and if I suspend Resharper, visual studio has no issue.  With resharper enabled, the method shows as unable to be resolved in my editor and intellisense auto-suggest does not work.  Although, if I hover over the method, I do get information about the method signature.

 

 

3

Please sign in to leave a comment.