microsoft / microsoft/TypeScript
Support labels in template string
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
🔍 Search Terms
template string label
template string name
interpolation label
✅ Viability Checklist
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
⭐ Suggestion
The idea is to allow the addition of labels into a template literal.
This has no effect on the type itself in any way, the sole purpose is to give a better DX.
These labels would be shown by IntelliSense in order to provide the same experience as labels for the tuple labels.
📃 Motivating Example
// Template literal today
type Options = {
name: `${string}/${string}`;
}
// With labels
type Options = {
name: `${scope: string}/${baseName: string}`;
}
💻 Use Cases
This would offer a slightly better DX.
Right now you can document the parts of the template in a JSDoc comment, but the JSDoc is not preserve by IntelliSense in some cases.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the motivating template-literal example and compare it with the existing tuple-label IntelliSense behavior referenced in the issue. The work is done when template literal labels improve IntelliSense documentation without changing the type or emitted JavaScript behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers, developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100