question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Go to definition for TypeScript literal strings

See original GitHub issue

Feature 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:open
  • Created a year ago
  • Reactions:55
  • Comments:14 (10 by maintainers)

github_iconTop GitHub Comments

26reactions
t3dotggcommented, Jun 20, 2022

I’ll throw in another $500 on this bounty @KATT

15reactions
KATTcommented, Dec 21, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found