Go to definition for TypeScript literal strings
See original GitHub issueFeature request
Go to definition for TypeScript literal strings.
Example
Given the below code, I would really like to be able to jump to the definition of the 'foo'
:
const obj = {
foo: 'bar' as const,
hello: 'world' as const,
}
function get<T, K extends keyof T>(obj: T, path: K): T[K] {
return obj[path]
}
const val = get(obj, 'foo')
// 👆👆👆 Is there a way of make jump to definition work here?
// I really want to CMD+click `'foo'` and jump to line #2
Link to TypeScript playground.
WebStorm Demo of the same code
In WebStorm, it actually works how I wish that VSCode worked, here’s a video:
https://user-images.githubusercontent.com/459267/167470744-80bdd8af-b7fa-444a-84d5-7e3f83e7e003.mov
Issue Analytics
- State:
- Created a year ago
- Reactions:55
- Comments:14 (10 by maintainers)
Top Results From Across the Web
Documentation - Template Literal Types - TypeScript
Template literal types build on string literal types, and have the ability to expand into many strings via unions. They have the same...
Read more >What are string literal types in TypeScript ? - GeeksforGeeks
The string literal type allows you to specify a set of possible string values for a variable, only those string values can be...
Read more >Extract parameter types from string literal types with TypeScript
In this article, we are going to explore how to define such a type, through various TypeScript techniques, extracting types from a string...
Read more >TypeScript: Convert literal string type definition to string value ...
You have to not use an explicit type annotation to let the compiler infer the string literal type for the constant (or manually...
Read more >Taming Strings with Template Literal Types - SitePen
Template literals are potent tools in JavaScript and TypeScript with capabilities that go well beyond what is described here, but this is enough ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ll throw in another $500 on this bounty @KATT
Alright, I’ll pay $500 once it’s released if someone solves this within 3 months. I will come back later when I can find some bug bounty site where I can get the money back if it’s not resolved.