Utility type to reference JSDoc of another type #41023
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
Search Terms
type level jsdoc
computed jsdoc
reference jsdoc from other type
Suggestion
Add a utility type
Docs<T>
, which, giventype T = U & Docs<V>
, results in a typeT
with the type ofU
, but with the JSDoc annotations ofV
(overriding anyU
might have). This should also addV
's go to definition results toT
's (maybe prioritized?).This could either be implemented as a magic type like
ThisType
(e.g.type Docs<T> = unknown
inlib.d.ts
), or as anintrinsic
type, as introduced in #40580.Use Cases
This is useful to preserve context when manipulating types (see example below).
Examples
Playground Link
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: