In the above file the first two types work in both ts compiler and webstorm. The final type works in ts compiler but fails in Web Storm
Last active
October 20, 2023 17:52
-
-
Save beattyml1/a02a0184930544b301ec104109c4fd95 to your computer and use it in GitHub Desktop.
Web Storm TypeScript Bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "webstorm-issues", | |
"version": "1.0.0", | |
"dependencies": { | |
"typescript": "^5.2.2" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type MyTypeWorks1<T extends {[k: string]: any}> = { | |
[K in keyof T]: T[K] | |
} | |
let instance1: MyTypeWorks1<{test:string}> = {test: ''}; | |
let val1 = instance1.test; // Autocomplete works, doesn't highlight as error | |
type MyTypeWorks2<T extends {[k: string]: any}> = { | |
[K in Uppercase<keyof T & string>]: any | |
} | |
let instance2: MyTypeWorks2<{test:string}> = {TEST: ''}; | |
let val2 = instance2.TEST; // Autocomplete works, doesn't highlight as error | |
type MyTypeDoesNotWork<T extends {[k: string]: any}> = { | |
[K in Uppercase<keyof T & string>]: T[K] | |
} | |
let nonWorkingInstance: MyTypeDoesNotWork<{test: string}> = {TEST: ''}; | |
let val3 = nonWorkingInstance.TEST; // Fails to autocomplete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"module": "commonjs", | |
"target": "es5", | |
"sourceMap": true | |
}, | |
"exclude": [ | |
"node_modules" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment