forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnodeModulesJson(module=node16).types
139 lines (114 loc) · 3.44 KB
/
nodeModulesJson(module=node16).types
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
//// [tests/cases/conformance/node/nodeModulesJson.ts] ////
=== /node_modules/not.json/index.d.ts ===
export function oops(json: string): any;
>oops : (json: string) => any
> : ^ ^^ ^^^^^
>json : string
> : ^^^^^^
=== /node_modules/actually-json/index.json ===
{}
>{} : {}
> : ^^
=== /node_modules/actually-json/typed.d.json.ts ===
declare const _default: {};
>_default : {}
> : ^^
export default _default;
>_default : {}
> : ^^
=== /config.json ===
{
>{ "version": 1} : { version: number; }
> : ^^^^^^^^^^^^^^^^^^^^
"version": 1
>"version" : number
> : ^^^^^^
>1 : 1
> : ^
}
=== /main.mts ===
import { oops } from "not.json"; // Ok
>oops : (json: string) => any
> : ^ ^^ ^^^^^
import moreOops from "actually-json"; // Error in nodenext
>moreOops : {}
> : ^^
import typed from "actually-json/typed"; // Error in nodenext
>typed : typeof typed
> : ^^^^^^^^^^^^
import config from "./config.json" with { type: "json" }; // Ok
>config : { version: number; }
> : ^^^^^^^^^^^^^^^^^^^^
>type : any
> : ^^^
import { default as config1 } from "./config.json" with { type: "json" }; // Ok
>default : { version: number; }
> : ^^^^^^^^^^^^^^^^^^^^
>config1 : { version: number; }
> : ^^^^^^^^^^^^^^^^^^^^
>type : any
> : ^^^
import config2 from "./config.json"; // Error in nodenext, no attribute
>config2 : { version: number; }
> : ^^^^^^^^^^^^^^^^^^^^
import type config2Type from "./config.json"; // Ok, type-only
>config2Type : any
> : ^^^
import type config2Type2 from "./config.json" with { type: "json" }; // Error, import attributes not allowed on type-only imports
>config2Type2 : any
> : ^^^
>type : any
> : ^^^
import { version } from "./config.json" with { type: "json" }; // Error, named import
>version : number
> : ^^^^^^
>type : any
> : ^^^
import * as config3 from "./config.json" with { type: "json" };
>config3 : { default: { version: number; }; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>type : any
> : ^^^
config3.version; // Error
>config3.version : any
> : ^^^
>config3 : { default: { version: number; }; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>version : any
> : ^^^
config3.default; // Ok
>config3.default : { version: number; }
> : ^^^^^^^^^^^^^^^^^^^^
>config3 : { default: { version: number; }; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>default : { version: number; }
> : ^^^^^^^^^^^^^^^^^^^^
=== /loosey.cts ===
import config from "./config.json" with { type: "json" }; // Error
>config : { version: number; }
> : ^^^^^^^^^^^^^^^^^^^^
>type : any
> : ^^^
import config2 from "./config.json"; // Ok
>config2 : { version: number; }
> : ^^^^^^^^^^^^^^^^^^^^
import { version } from "./config.json"; // Ok
>version : number
> : ^^^^^^
import * as config3 from "./config.json";
>config3 : { version: number; }
> : ^^^^^^^^^^^^^^^^^^^^
config3.version; // Ok
>config3.version : number
> : ^^^^^^
>config3 : { version: number; }
> : ^^^^^^^^^^^^^^^^^^^^
>version : number
> : ^^^^^^
config3.default; // Error
>config3.default : any
> : ^^^
>config3 : { version: number; }
> : ^^^^^^^^^^^^^^^^^^^^
>default : any
> : ^^^