typescript 'symbol cannot be properly resolved'
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
Please sign in to leave a 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!
Hello Maciej,
Please try installing R# 2016.3 EAP https://confluence.jetbrains.com/display/ReSharper/ReSharper+2016.3+EAP.
Thanks!
It didn't help unfortunately. With 2016.3 EAP 5 I still have same error.
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".
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!
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.
@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.
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.
Thanks, I created two issues based on your report:
https://youtrack.jetbrains.com/issue/RSRP-461834
https://youtrack.jetbrains.com/issue/RSRP-461835
@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.
@Anton Lobov - it works now. Thanks.
@Maciej Moron Great. Thanks for confirming!
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.
@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).
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
@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.
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.
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.
I am having this issue too in R# 2017.1. giving error in so many properties. But typescript compiles successfully.
@ Balasubramanian Ramanathan
Thanks for the report, this issue was already reported, and will be fixed soon: https://youtrack.jetbrains.com/issue/RSRP-464603.
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)
Turns out that clearing the local cach resolved this for me.
@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.
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?
@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.
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.
@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.
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);
}
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.
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.