π Search Terms
node reuse declarations
β
Viability Checklist
β Suggestion
When tryReuseExistingTypeNodeHelper encounters an node it can't use, it will throw away the whole original node. We can instead fall back on type printing for only the subnode that is not reusable.
π Motivating Example
// @filename: a.ts
export const nImported = "nImported"
export const nNotImported = "nNotImported"
const nPrivate = "private"
export const o = (p1: typeof nImported, p2: typeof nNotImported, p3: typeof nPrivate) => null! as { foo: typeof nImported, bar: typeof nPrivate, baz: typeof nNotImported }
// @filename: b.ts
import { o, nImported } from "./a";
export const g = o
console.log(nImported);
// @filename: c.ts
import * as a from "./a";
export const g = a.o
Playgorund link
// currently generates
// @filename:c.d.ts
import { nImported } from "./a";
export declare const g: (p1: typeof nImported, p2: "nNotImported", p3: "private") => {
foo: "nImported";
bar: "private";
baz: "nNotImported";
};
/// proposed
// @filename: c.d.ts
export declare const g: (p1: typeof a.nImported, p2: typeof a.nNotImported, p3: "private") => {
foo: typeof a.nImported;
bar: "private";
baz: typeof a.nNotImported;
};
π» Use Cases
- What do you want to use this for? - Improve declaration fidelity and speed
- What shortcomings exist with current approaches? - Throwing away the type node can happen half way through resulting in duplicate work.
- What workarounds are you using in the meantime?
π Search Terms
node reuse declarations
β Viability Checklist
β Suggestion
When
tryReuseExistingTypeNodeHelperencounters an node it can't use, it will throw away the whole original node. We can instead fall back on type printing for only the subnode that is not reusable.π Motivating Example
Playgorund link
π» Use Cases