When caching type references cache the tracked symbols so they can be emitted in the d.ts file (#51721)

This commit is contained in:
Sheetal Nandi
2023-10-25 15:05:47 -07:00
committed by GitHub
parent 043e1ca743
commit 55395f9e01
4 changed files with 449 additions and 1 deletions

View File

@@ -908,4 +908,55 @@ console.log(a);`,
}],
baselinePrograms: true,
});
verifyTsc({
scenario: "incremental",
subScenario: "generates typerefs correctly",
commandLineArgs: ["-p", `/src/project`],
fs: () =>
loadProjectFromFiles({
"/src/project/tsconfig.json": jsonToReadableText({
compilerOptions: {
composite: true,
outDir: "outDir",
checkJs: true,
},
include: ["src"],
}),
"/src/project/src/box.ts": Utils.dedent`
export interface Box<T> {
unbox(): T
}
`,
"/src/project/src/bug.js": Utils.dedent`
import * as B from "./box.js"
import * as W from "./wrap.js"
/**
* @template {object} C
* @param {C} source
* @returns {W.Wrap<C>}
*/
const wrap = source => {
throw source
}
/**
* @returns {B.Box<number>}
*/
const box = (n = 0) => ({ unbox: () => n })
export const bug = wrap({ n: box(1) });
`,
"/src/project/src/wrap.ts": Utils.dedent`
export type Wrap<C> = {
[K in keyof C]: { wrapped: C[K] }
}
`,
}),
edits: [{
caption: "modify js file",
edit: fs => appendText(fs, "/src/project/src/bug.js", `export const something = 1;`),
}],
});
});