Skip to content

Commit 6d58d32

Browse files
committed
Test for failing to write import
1 parent 2a8436c commit 6d58d32

File tree

3 files changed

+541
-0
lines changed

3 files changed

+541
-0
lines changed

src/testRunner/unittests/tsc/incremental.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,4 +857,54 @@ console.log(a);`,
857857
}],
858858
baselinePrograms: true,
859859
});
860+
861+
verifyTsc({
862+
scenario: "incremental",
863+
subScenario: "generates typerefs correctly",
864+
commandLineArgs: ["-p", `/src/project`],
865+
fs: () => loadProjectFromFiles({
866+
"/src/project/tsconfig.json": JSON.stringify({
867+
compilerOptions: {
868+
composite: true,
869+
outDir: "outDir",
870+
checkJs: true,
871+
},
872+
include: ["src"]
873+
}),
874+
"/src/project/src/box.ts": Utils.dedent`
875+
export interface Box<T> {
876+
unbox(): T
877+
}
878+
`,
879+
"/src/project/src/bug.js": Utils.dedent`
880+
import * as B from "./box.js"
881+
import * as W from "./wrap.js"
882+
883+
/**
884+
* @template {object} C
885+
* @param {C} source
886+
* @returns {W.Wrap<C>}
887+
*/
888+
const wrap = source => {
889+
throw source
890+
}
891+
892+
/**
893+
* @returns {B.Box<number>}
894+
*/
895+
const box = (n = 0) => ({ unbox: () => n })
896+
897+
export const bug = wrap({ n: box(1) });
898+
`,
899+
"/src/project/src/wrap.ts": Utils.dedent`
900+
export type Wrap<C> = {
901+
[K in keyof C]: { wrapped: C[K] }
902+
}
903+
`,
904+
}),
905+
edits: [{
906+
caption: "modify js file",
907+
edit: fs => appendText(fs, "/src/project/src/bug.js", `export const something = 1;`),
908+
}]
909+
});
860910
});
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
0:: modify js file
2+
*** Needs explanation
3+
File: /src/project/outdir/src/bug.d.ts
4+
CleanBuild:
5+
export const bug: W.Wrap<{
6+
n: B.Box<number>;
7+
}>;
8+
export const something: 1;
9+
import * as B from "./box.js";
10+
import * as W from "./wrap.js";
11+
12+
IncrementalBuild:
13+
export const bug: W.Wrap<{
14+
n: B.Box<number>;
15+
}>;
16+
export const something: 1;
17+
import * as W from "./wrap.js";
18+
19+
TsBuild info text without affectedFilesPendingEmit:: /src/project/outdir/tsconfig.tsbuildinfo.readable.baseline.txt::
20+
CleanBuild:
21+
{
22+
"program": {
23+
"fileInfos": {
24+
"../../../lib/lib.d.ts": {
25+
"version": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
26+
"affectsGlobalScope": true
27+
},
28+
"../src/box.ts": {
29+
"version": "-14267342128-export interface Box<T> {\n unbox(): T\n}\n"
30+
},
31+
"../src/wrap.ts": {
32+
"version": "-7208318765-export type Wrap<C> = {\n [K in keyof C]: { wrapped: C[K] }\n}\n"
33+
},
34+
"../src/bug.js": {
35+
"version": "-25729561895-import * as B from \"./box.js\"\nimport * as W from \"./wrap.js\"\n\n/**\n * @template {object} C\n * @param {C} source\n * @returns {W.Wrap<C>}\n */\nconst wrap = source => {\nthrow source\n}\n\n/**\n * @returns {B.Box<number>}\n */\nconst box = (n = 0) => ({ unbox: () => n })\n\nexport const bug = wrap({ n: box(1) });\nexport const something = 1;"
36+
}
37+
},
38+
"root": [
39+
[
40+
[
41+
2,
42+
4
43+
],
44+
[
45+
"../src/box.ts",
46+
"../src/wrap.ts",
47+
"../src/bug.js"
48+
]
49+
]
50+
],
51+
"options": {
52+
"composite": true,
53+
"outDir": "./"
54+
},
55+
"referencedMap": {
56+
"../src/bug.js": [
57+
"../src/box.ts",
58+
"../src/wrap.ts"
59+
]
60+
},
61+
"semanticDiagnosticsPerFile": [
62+
"../../../lib/lib.d.ts",
63+
"../src/box.ts",
64+
"../src/bug.js",
65+
"../src/wrap.ts"
66+
],
67+
"latestChangedDtsFile": "FakeFileName"
68+
},
69+
"version": "FakeTSVersion"
70+
}
71+
IncrementalBuild:
72+
{
73+
"program": {
74+
"fileInfos": {
75+
"../../../lib/lib.d.ts": {
76+
"version": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
77+
"affectsGlobalScope": true
78+
},
79+
"../src/box.ts": {
80+
"version": "-14267342128-export interface Box<T> {\n unbox(): T\n}\n"
81+
},
82+
"../src/wrap.ts": {
83+
"version": "-7208318765-export type Wrap<C> = {\n [K in keyof C]: { wrapped: C[K] }\n}\n"
84+
},
85+
"../src/bug.js": {
86+
"version": "-25729561895-import * as B from \"./box.js\"\nimport * as W from \"./wrap.js\"\n\n/**\n * @template {object} C\n * @param {C} source\n * @returns {W.Wrap<C>}\n */\nconst wrap = source => {\nthrow source\n}\n\n/**\n * @returns {B.Box<number>}\n */\nconst box = (n = 0) => ({ unbox: () => n })\n\nexport const bug = wrap({ n: box(1) });\nexport const something = 1;"
87+
}
88+
},
89+
"root": [
90+
[
91+
[
92+
2,
93+
4
94+
],
95+
[
96+
"../src/box.ts",
97+
"../src/wrap.ts",
98+
"../src/bug.js"
99+
]
100+
]
101+
],
102+
"options": {
103+
"composite": true,
104+
"outDir": "./"
105+
},
106+
"referencedMap": {
107+
"../src/bug.js": [
108+
"../src/box.ts",
109+
"../src/wrap.ts"
110+
]
111+
},
112+
"semanticDiagnosticsPerFile": [
113+
"../../../lib/lib.d.ts",
114+
"../src/box.ts",
115+
"../src/bug.js",
116+
"../src/wrap.ts"
117+
],
118+
"emitSignatures": [
119+
[
120+
"../src/bug.js",
121+
"1273570373-export const bug: W.Wrap<{\n n: B.Box<number>;\n}>;\nexport const something: 1;\nimport * as W from \"./wrap.js\";\n"
122+
]
123+
],
124+
"latestChangedDtsFile": "FakeFileName"
125+
},
126+
"version": "FakeTSVersion"
127+
}

0 commit comments

Comments
 (0)