I am in search of a comprehensive and reliable source that provides detailed information on how TypeScript's JSDoc interacts with types, their mappings, and modifications.
It is widely known that Pick
and Omit
maintain the original JSDoc:
const any: any = {};
type A = {
/** FOO */ foo: 1,
/** BAR */ bar: 2
}
let A: A = any;
A.foo
// ^# FOO
let A2: Pick<A, 'foo'> = any;
A2.foo
// ^# FOO
let A3: Omit<A, 'bar'> = any;
A3.foo
// ^# FOO
A more complex scenario involves mapped types retaining the JSDoc:
type B = { [K in keyof A]: false }
let B: B = any;
B.foo
// ^# FOO
Hence, I am seeking a thorough list of strategies for manipulating JSDoc and understanding how JSDoc functions within TypeScript. This includes techniques beyond those mentioned above.
Specifically, but not limited to:
- Is it feasible to change
{ /** foo */ a: 1 }
to{ /** foo */ b: 1 }
? - Can JSDoc be added using a wrapper like
?function addJsdoc<T, ?>(fnWithoutJsdoc: T): <?<T>>
For more information, refer to: (Github)/TypeScript Feature Request: Documented Utility Type #41165