Typescript type inference issue Follow
Inside of a class I have the literal type variable definition as follows:
myData = {
header: "",
text: "",
}
Then I use it like this:
this.myData.header = "hello";
ReSharper tells me the error:
Cannot convert type '"hello"' to type '""': String literal types '"hello"' and '""' have different values
Shouldn't "hello" and "" be infered to string type here? (acc. to https://www.typescriptlang.org/docs/handbook/type-inference.html)
The infered string type works on compiler level correctly, because I do not get an error here.
I've done the following workaround but I am thankful for clearing up whats right.
myData = {
header: <string>"",
text: <string>"",
}
many thanks!
I am using VS2015, ReSharper 2017.1.3 with language level 2.1 and compiler version 2.1.5
Please sign in to leave a comment.
Hello Chris!
Thank you for contacting us.
Please try the latest ReSharper 2017.2 EAP version - https://www.jetbrains.com/resharper/eap/ and check if the issue is still reproduced.
Thank you.
The issue still occurs in the EAP:
Cannot convert type 'string' to type '""'
Thank you for the feedback!
I've filed corresponding issue in our issue tracker - https://youtrack.jetbrains.com/issue/RSRP-465695
You are welcome to comment or vote for it.
Thank you.