Skip to content

Commit 2e92c6b

Browse files
committed
tsc -b and tsc -p declaration emit tests
1 parent 1508396 commit 2e92c6b

12 files changed

+2879
-0
lines changed

internal/execute/tscdeclarationemit_test.go

Lines changed: 443 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
currentDirectory::/home/src/workspaces/project
2+
useCaseSensitiveFileNames::true
3+
Input::
4+
//// [/home/src/workspaces/project/index.ts] *new*
5+
import ky from 'ky';
6+
export const api = ky.extend({});
7+
//// [/home/src/workspaces/project/node_modules/ky/distribution/index.d.ts] *new*
8+
type KyInstance = {
9+
extend(options: Record<string,unknown>): KyInstance;
10+
}
11+
declare const ky: KyInstance;
12+
export default ky;
13+
//// [/home/src/workspaces/project/node_modules/ky/package.json] *new*
14+
{
15+
"name": "ky",
16+
"type": "module",
17+
"main": "./distribution/index.js"
18+
}
19+
//// [/home/src/workspaces/project/package.json] *new*
20+
{
21+
"type": "module"
22+
}
23+
//// [/home/src/workspaces/project/tsconfig.json] *new*
24+
{
25+
"compilerOptions": {
26+
"module": "NodeNext",
27+
"moduleResolution": "NodeNext",
28+
"composite": false,
29+
"incremental": true,
30+
"declaration": true,
31+
"skipLibCheck": true,
32+
"skipDefaultLibCheck": true,
33+
},
34+
}
35+
36+
tsgo -b --explainFiles --listEmittedFiles --v
37+
ExitStatus:: DiagnosticsPresent_OutputsGenerated
38+
Output::
39+
[HH:MM:SS AM] Projects in this build:
40+
* tsconfig.json
41+
42+
[HH:MM:SS AM] Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
43+
44+
[HH:MM:SS AM] Building project 'tsconfig.json'...
45+
46+
index.ts:2:14 - error TS4023: Exported variable 'api' has or is using name 'KyInstance' from external module "/home/src/workspaces/project/node_modules/ky/distribution/index" but cannot be named.
47+
48+
2 export const api = ky.extend({});
49+
   ~~~
50+
51+
TSFILE: /home/src/workspaces/project/index.js
52+
TSFILE: /home/src/workspaces/project/index.d.ts
53+
TSFILE: /home/src/workspaces/project/tsconfig.tsbuildinfo
54+
../../tslibs/TS/Lib/lib.esnext.full.d.ts
55+
Default library for target 'ESNext'
56+
node_modules/ky/distribution/index.d.ts
57+
Imported via ky from file 'index.ts'
58+
File is ECMAScript module because 'node_modules/ky/package.json' has field "type" with value "module"
59+
index.ts
60+
Matched by default include pattern '**/*'
61+
File is ECMAScript module because 'package.json' has field "type" with value "module"
62+
63+
Found 1 error in index.ts:2
64+
65+
//// [/home/src/tslibs/TS/Lib/lib.esnext.full.d.ts] *Lib*
66+
/// <reference no-default-lib="true"/>
67+
interface Boolean {}
68+
interface Function {}
69+
interface CallableFunction {}
70+
interface NewableFunction {}
71+
interface IArguments {}
72+
interface Number { toExponential: any; }
73+
interface Object {}
74+
interface RegExp {}
75+
interface String { charAt: any; }
76+
interface Array<T> { length: number; [n: number]: T; }
77+
interface ReadonlyArray<T> {}
78+
interface SymbolConstructor {
79+
(desc?: string | number): symbol;
80+
for(name: string): symbol;
81+
readonly toStringTag: symbol;
82+
}
83+
declare var Symbol: SymbolConstructor;
84+
interface Symbol {
85+
readonly [Symbol.toStringTag]: string;
86+
}
87+
declare const console: { log(msg: any): void; };
88+
//// [/home/src/workspaces/project/index.d.ts] *new*
89+
export declare const api: {
90+
extend(options: Record<string, unknown>): KyInstance;
91+
};
92+
93+
//// [/home/src/workspaces/project/index.js] *new*
94+
import ky from 'ky';
95+
export const api = ky.extend({});
96+
97+
//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *new*
98+
{"version":"FakeTSVersion","root":[3],"fileNames":["lib.esnext.full.d.ts","./node_modules/ky/distribution/index.d.ts","./index.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// <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> {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b9b50c37c18e43d94b0dd4fb43967f10-type KyInstance = {\n extend(options: Record<string,unknown>): KyInstance;\n}\ndeclare const ky: KyInstance;\nexport default ky;","impliedNodeFormat":99},{"version":"0f5091e963c17913313e4969c59e6eb4-import ky from 'ky';\nexport const api = ky.extend({});","signature":"5816fe34b5cf354b0d0d19bc77874616-export declare const api: {\n extend(options: Record<string, unknown>): KyInstance;\n};\n\n(34,3): error4023: Exported variable 'api' has or is using name 'KyInstance' from external module \"/home/src/workspaces/project/node_modules/ky/distribution/index\" but cannot be named.","impliedNodeFormat":99}],"fileIdsList":[[2]],"options":{"composite":false,"declaration":true,"module":199,"skipLibCheck":true,"skipDefaultLibCheck":true},"referencedMap":[[3,1]],"emitDiagnosticsPerFile":[[3,[{"pos":34,"end":37,"code":4023,"category":1,"message":"Exported variable 'api' has or is using name 'KyInstance' from external module \"/home/src/workspaces/project/node_modules/ky/distribution/index\" but cannot be named."}]]]}
99+
//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *new*
100+
{
101+
"version": "FakeTSVersion",
102+
"root": [
103+
{
104+
"files": [
105+
"./index.ts"
106+
],
107+
"original": 3
108+
}
109+
],
110+
"fileNames": [
111+
"lib.esnext.full.d.ts",
112+
"./node_modules/ky/distribution/index.d.ts",
113+
"./index.ts"
114+
],
115+
"fileInfos": [
116+
{
117+
"fileName": "lib.esnext.full.d.ts",
118+
"version": "8859c12c614ce56ba9a18e58384a198f-/// <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> {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };",
119+
"signature": "8859c12c614ce56ba9a18e58384a198f-/// <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> {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };",
120+
"affectsGlobalScope": true,
121+
"impliedNodeFormat": "CommonJS",
122+
"original": {
123+
"version": "8859c12c614ce56ba9a18e58384a198f-/// <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> {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };",
124+
"affectsGlobalScope": true,
125+
"impliedNodeFormat": 1
126+
}
127+
},
128+
{
129+
"fileName": "./node_modules/ky/distribution/index.d.ts",
130+
"version": "b9b50c37c18e43d94b0dd4fb43967f10-type KyInstance = {\n extend(options: Record<string,unknown>): KyInstance;\n}\ndeclare const ky: KyInstance;\nexport default ky;",
131+
"signature": "b9b50c37c18e43d94b0dd4fb43967f10-type KyInstance = {\n extend(options: Record<string,unknown>): KyInstance;\n}\ndeclare const ky: KyInstance;\nexport default ky;",
132+
"impliedNodeFormat": "ESNext",
133+
"original": {
134+
"version": "b9b50c37c18e43d94b0dd4fb43967f10-type KyInstance = {\n extend(options: Record<string,unknown>): KyInstance;\n}\ndeclare const ky: KyInstance;\nexport default ky;",
135+
"impliedNodeFormat": 99
136+
}
137+
},
138+
{
139+
"fileName": "./index.ts",
140+
"version": "0f5091e963c17913313e4969c59e6eb4-import ky from 'ky';\nexport const api = ky.extend({});",
141+
"signature": "5816fe34b5cf354b0d0d19bc77874616-export declare const api: {\n extend(options: Record<string, unknown>): KyInstance;\n};\n\n(34,3): error4023: Exported variable 'api' has or is using name 'KyInstance' from external module \"/home/src/workspaces/project/node_modules/ky/distribution/index\" but cannot be named.",
142+
"impliedNodeFormat": "ESNext",
143+
"original": {
144+
"version": "0f5091e963c17913313e4969c59e6eb4-import ky from 'ky';\nexport const api = ky.extend({});",
145+
"signature": "5816fe34b5cf354b0d0d19bc77874616-export declare const api: {\n extend(options: Record<string, unknown>): KyInstance;\n};\n\n(34,3): error4023: Exported variable 'api' has or is using name 'KyInstance' from external module \"/home/src/workspaces/project/node_modules/ky/distribution/index\" but cannot be named.",
146+
"impliedNodeFormat": 99
147+
}
148+
}
149+
],
150+
"fileIdsList": [
151+
[
152+
"./node_modules/ky/distribution/index.d.ts"
153+
]
154+
],
155+
"options": {
156+
"composite": false,
157+
"declaration": true,
158+
"module": 199,
159+
"skipLibCheck": true,
160+
"skipDefaultLibCheck": true
161+
},
162+
"referencedMap": {
163+
"./index.ts": [
164+
"./node_modules/ky/distribution/index.d.ts"
165+
]
166+
},
167+
"emitDiagnosticsPerFile": [
168+
[
169+
"./index.ts",
170+
[
171+
{
172+
"pos": 34,
173+
"end": 37,
174+
"code": 4023,
175+
"category": 1,
176+
"message": "Exported variable 'api' has or is using name 'KyInstance' from external module \"/home/src/workspaces/project/node_modules/ky/distribution/index\" but cannot be named."
177+
}
178+
]
179+
]
180+
],
181+
"size": 1983
182+
}
183+
184+
tsconfig.json::
185+
SemanticDiagnostics::
186+
*refresh* /home/src/tslibs/TS/Lib/lib.esnext.full.d.ts
187+
*refresh* /home/src/workspaces/project/node_modules/ky/distribution/index.d.ts
188+
*refresh* /home/src/workspaces/project/index.ts
189+
Signatures::
190+
(stored at emit) /home/src/workspaces/project/index.ts
191+
192+
193+
Edit [0]:: no change
194+
195+
tsgo -b --explainFiles --listEmittedFiles --v
196+
ExitStatus:: DiagnosticsPresent_OutputsSkipped
197+
Output::
198+
[HH:MM:SS AM] Projects in this build:
199+
* tsconfig.json
200+
201+
[HH:MM:SS AM] Project 'tsconfig.json' is out of date because buildinfo file 'tsconfig.tsbuildinfo' indicates that program needs to report errors.
202+
203+
[HH:MM:SS AM] Building project 'tsconfig.json'...
204+
205+
index.ts:2:14 - error TS4023: Exported variable 'api' has or is using name 'KyInstance' from external module "/home/src/workspaces/project/node_modules/ky/distribution/index" but cannot be named.
206+
207+
2 export const api = ky.extend({});
208+
   ~~~
209+
210+
TSFILE: /home/src/workspaces/project/tsconfig.tsbuildinfo
211+
../../tslibs/TS/Lib/lib.esnext.full.d.ts
212+
Default library for target 'ESNext'
213+
node_modules/ky/distribution/index.d.ts
214+
Imported via ky from file 'index.ts'
215+
File is ECMAScript module because 'node_modules/ky/package.json' has field "type" with value "module"
216+
index.ts
217+
Matched by default include pattern '**/*'
218+
File is ECMAScript module because 'package.json' has field "type" with value "module"
219+
220+
Found 1 error in index.ts:2
221+
222+
//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *rewrite with same content*
223+
//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *rewrite with same content*
224+
225+
tsconfig.json::
226+
SemanticDiagnostics::
227+
Signatures::
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
currentDirectory::/home/src/workspaces/project
2+
useCaseSensitiveFileNames::true
3+
Input::
4+
//// [/home/src/workspaces/project/index.ts] *new*
5+
import ky from 'ky';
6+
export const api = ky.extend({});
7+
//// [/home/src/workspaces/project/node_modules/ky/distribution/index.d.ts] *new*
8+
type KyInstance = {
9+
extend(options: Record<string,unknown>): KyInstance;
10+
}
11+
declare const ky: KyInstance;
12+
export default ky;
13+
//// [/home/src/workspaces/project/node_modules/ky/package.json] *new*
14+
{
15+
"name": "ky",
16+
"type": "module",
17+
"main": "./distribution/index.js"
18+
}
19+
//// [/home/src/workspaces/project/package.json] *new*
20+
{
21+
"type": "module"
22+
}
23+
//// [/home/src/workspaces/project/tsconfig.json] *new*
24+
{
25+
"compilerOptions": {
26+
"module": "NodeNext",
27+
"moduleResolution": "NodeNext",
28+
"composite": false,
29+
"incremental": false,
30+
"declaration": true,
31+
"skipLibCheck": true,
32+
"skipDefaultLibCheck": true,
33+
},
34+
}
35+
36+
tsgo -b --explainFiles --listEmittedFiles --v
37+
ExitStatus:: DiagnosticsPresent_OutputsGenerated
38+
Output::
39+
[HH:MM:SS AM] Projects in this build:
40+
* tsconfig.json
41+
42+
[HH:MM:SS AM] Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
43+
44+
[HH:MM:SS AM] Building project 'tsconfig.json'...
45+
46+
index.ts:2:14 - error TS4023: Exported variable 'api' has or is using name 'KyInstance' from external module "/home/src/workspaces/project/node_modules/ky/distribution/index" but cannot be named.
47+
48+
2 export const api = ky.extend({});
49+
   ~~~
50+
51+
TSFILE: /home/src/workspaces/project/index.js
52+
TSFILE: /home/src/workspaces/project/index.d.ts
53+
TSFILE: /home/src/workspaces/project/tsconfig.tsbuildinfo
54+
../../tslibs/TS/Lib/lib.esnext.full.d.ts
55+
Default library for target 'ESNext'
56+
node_modules/ky/distribution/index.d.ts
57+
Imported via ky from file 'index.ts'
58+
File is ECMAScript module because 'node_modules/ky/package.json' has field "type" with value "module"
59+
index.ts
60+
Matched by default include pattern '**/*'
61+
File is ECMAScript module because 'package.json' has field "type" with value "module"
62+
63+
Found 1 error in index.ts:2
64+
65+
//// [/home/src/tslibs/TS/Lib/lib.esnext.full.d.ts] *Lib*
66+
/// <reference no-default-lib="true"/>
67+
interface Boolean {}
68+
interface Function {}
69+
interface CallableFunction {}
70+
interface NewableFunction {}
71+
interface IArguments {}
72+
interface Number { toExponential: any; }
73+
interface Object {}
74+
interface RegExp {}
75+
interface String { charAt: any; }
76+
interface Array<T> { length: number; [n: number]: T; }
77+
interface ReadonlyArray<T> {}
78+
interface SymbolConstructor {
79+
(desc?: string | number): symbol;
80+
for(name: string): symbol;
81+
readonly toStringTag: symbol;
82+
}
83+
declare var Symbol: SymbolConstructor;
84+
interface Symbol {
85+
readonly [Symbol.toStringTag]: string;
86+
}
87+
declare const console: { log(msg: any): void; };
88+
//// [/home/src/workspaces/project/index.d.ts] *new*
89+
export declare const api: {
90+
extend(options: Record<string, unknown>): KyInstance;
91+
};
92+
93+
//// [/home/src/workspaces/project/index.js] *new*
94+
import ky from 'ky';
95+
export const api = ky.extend({});
96+
97+
//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *new*
98+
{"version":"FakeTSVersion","errors":true,"root":["./index.ts"]}
99+
//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *new*
100+
{
101+
"version": "FakeTSVersion",
102+
"errors": true,
103+
"root": [
104+
{
105+
"files": [
106+
"./index.ts"
107+
],
108+
"original": "./index.ts"
109+
}
110+
],
111+
"size": 63
112+
}
113+
114+
tsconfig.json::
115+
SemanticDiagnostics::
116+
*refresh* /home/src/tslibs/TS/Lib/lib.esnext.full.d.ts
117+
*refresh* /home/src/workspaces/project/node_modules/ky/distribution/index.d.ts
118+
*refresh* /home/src/workspaces/project/index.ts
119+
Signatures::
120+
(stored at emit) /home/src/workspaces/project/index.ts
121+
122+
123+
Edit [0]:: no change
124+
125+
tsgo -b --explainFiles --listEmittedFiles --v
126+
ExitStatus:: DiagnosticsPresent_OutputsGenerated
127+
Output::
128+
[HH:MM:SS AM] Projects in this build:
129+
* tsconfig.json
130+
131+
[HH:MM:SS AM] Project 'tsconfig.json' is out of date because buildinfo file 'tsconfig.tsbuildinfo' indicates that program needs to report errors.
132+
133+
[HH:MM:SS AM] Building project 'tsconfig.json'...
134+
135+
index.ts:2:14 - error TS4023: Exported variable 'api' has or is using name 'KyInstance' from external module "/home/src/workspaces/project/node_modules/ky/distribution/index" but cannot be named.
136+
137+
2 export const api = ky.extend({});
138+
   ~~~
139+
140+
TSFILE: /home/src/workspaces/project/index.js
141+
TSFILE: /home/src/workspaces/project/index.d.ts
142+
TSFILE: /home/src/workspaces/project/tsconfig.tsbuildinfo
143+
../../tslibs/TS/Lib/lib.esnext.full.d.ts
144+
Default library for target 'ESNext'
145+
node_modules/ky/distribution/index.d.ts
146+
Imported via ky from file 'index.ts'
147+
File is ECMAScript module because 'node_modules/ky/package.json' has field "type" with value "module"
148+
index.ts
149+
Matched by default include pattern '**/*'
150+
File is ECMAScript module because 'package.json' has field "type" with value "module"
151+
152+
Found 1 error in index.ts:2
153+
154+
//// [/home/src/workspaces/project/index.d.ts] *rewrite with same content*
155+
//// [/home/src/workspaces/project/index.js] *rewrite with same content*
156+
//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *rewrite with same content*
157+
//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *rewrite with same content*
158+
159+
tsconfig.json::
160+
SemanticDiagnostics::
161+
*refresh* /home/src/tslibs/TS/Lib/lib.esnext.full.d.ts
162+
*refresh* /home/src/workspaces/project/node_modules/ky/distribution/index.d.ts
163+
*refresh* /home/src/workspaces/project/index.ts
164+
Signatures::
165+
(stored at emit) /home/src/workspaces/project/index.ts

0 commit comments

Comments
 (0)