@atlaspack/transformer-typescript-types 2.14.5-canary.33 → 2.14.5-canary.331
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +330 -0
- package/dist/TSModule.js +40 -0
- package/dist/TSModuleGraph.js +233 -0
- package/dist/TSTypesTransformer.js +185 -0
- package/dist/collect.js +137 -0
- package/dist/shake.js +219 -0
- package/dist/utils.js +29 -0
- package/dist/wrappers.js +71 -0
- package/lib/TSModuleGraph.js +13 -0
- package/lib/TSTypesTransformer.js +7 -5
- package/lib/collect.js +28 -4
- package/lib/shake.js +24 -6
- package/lib/types/TSModule.d.ts +25 -0
- package/lib/types/TSModuleGraph.d.ts +33 -0
- package/lib/types/TSTypesTransformer.d.ts +3 -0
- package/lib/types/collect.d.ts +2 -0
- package/lib/types/shake.d.ts +2 -0
- package/lib/types/utils.d.ts +2 -0
- package/lib/types/wrappers.d.ts +8 -0
- package/lib/utils.js +4 -0
- package/lib/wrappers.js +5 -4
- package/package.json +14 -10
- package/src/{TSModule.js → TSModule.ts} +13 -6
- package/src/{TSModuleGraph.js → TSModuleGraph.ts} +48 -9
- package/src/{TSTypesTransformer.js → TSTypesTransformer.ts} +11 -11
- package/src/{collect.js → collect.ts} +22 -5
- package/src/{shake.js → shake.ts} +19 -6
- package/src/{utils.js → utils.ts} +3 -2
- package/src/{wrappers.js → wrappers.ts} +95 -58
- package/tsconfig.json +24 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
// @flow strict-local
|
|
2
|
-
|
|
3
1
|
import {Transformer} from '@atlaspack/plugin';
|
|
4
2
|
import path from 'path';
|
|
5
|
-
import SourceMap from '@
|
|
3
|
+
import SourceMap from '@atlaspack/source-map';
|
|
6
4
|
import type {DiagnosticCodeFrame} from '@atlaspack/diagnostic';
|
|
7
5
|
import type {CompilerOptions} from 'typescript';
|
|
8
6
|
|
|
@@ -15,7 +13,7 @@ import nullthrows from 'nullthrows';
|
|
|
15
13
|
import {collect} from './collect';
|
|
16
14
|
import {shake} from './shake';
|
|
17
15
|
|
|
18
|
-
export default
|
|
16
|
+
export default new Transformer({
|
|
19
17
|
loadConfig({config, options}) {
|
|
20
18
|
return loadTSConfig(config, options);
|
|
21
19
|
},
|
|
@@ -41,7 +39,7 @@ export default (new Transformer({
|
|
|
41
39
|
};
|
|
42
40
|
|
|
43
41
|
let host = new CompilerHost(options.inputFS, ts, logger);
|
|
44
|
-
//
|
|
42
|
+
// @ts-expect-error TS2345
|
|
45
43
|
let program = ts.createProgram([asset.filePath], opts, host);
|
|
46
44
|
|
|
47
45
|
for (let file of program.getSourceFiles()) {
|
|
@@ -54,6 +52,7 @@ export default (new Transformer({
|
|
|
54
52
|
|
|
55
53
|
let mainModuleName = normalizeSeparators(
|
|
56
54
|
path
|
|
55
|
+
// @ts-expect-error TS2339
|
|
57
56
|
.relative(program.getCommonSourceDirectory(), asset.filePath)
|
|
58
57
|
.slice(0, -path.extname(asset.filePath).length),
|
|
59
58
|
);
|
|
@@ -62,11 +61,11 @@ export default (new Transformer({
|
|
|
62
61
|
let emitResult = program.emit(undefined, undefined, undefined, true, {
|
|
63
62
|
afterDeclarations: [
|
|
64
63
|
// 1. Build module graph
|
|
65
|
-
(context) => (sourceFile) => {
|
|
64
|
+
(context: any) => (sourceFile: any) => {
|
|
66
65
|
return collect(moduleGraph, context, sourceFile);
|
|
67
66
|
},
|
|
68
67
|
// 2. Tree shake and rename types
|
|
69
|
-
(context) => (sourceFile) => {
|
|
68
|
+
(context: any) => (sourceFile: any) => {
|
|
70
69
|
return shake(moduleGraph, context, sourceFile);
|
|
71
70
|
},
|
|
72
71
|
],
|
|
@@ -77,7 +76,8 @@ export default (new Transformer({
|
|
|
77
76
|
.concat(emitResult.diagnostics);
|
|
78
77
|
|
|
79
78
|
let diagnosticIds = new Set();
|
|
80
|
-
|
|
79
|
+
// @ts-expect-error TS2304
|
|
80
|
+
let deduplicatedDiagnostics: Array<Diagnostic> = [];
|
|
81
81
|
for (let d of diagnostics) {
|
|
82
82
|
if (d.start != null && d.length != null && d.messageText != null) {
|
|
83
83
|
let id = `${d.start}:${d.length}:${ts.flattenDiagnosticMessageText(
|
|
@@ -102,14 +102,13 @@ export default (new Transformer({
|
|
|
102
102
|
'\n',
|
|
103
103
|
);
|
|
104
104
|
|
|
105
|
-
let codeframe:
|
|
105
|
+
let codeframe: DiagnosticCodeFrame | null | undefined;
|
|
106
106
|
if (file != null && diagnostic.start != null) {
|
|
107
107
|
let source = file.text || diagnostic.source;
|
|
108
108
|
if (file.fileName) {
|
|
109
109
|
filename = file.fileName;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
// $FlowFixMe
|
|
113
112
|
if (source) {
|
|
114
113
|
let lineChar = file.getLineAndCharacterOfPosition(diagnostic.start);
|
|
115
114
|
let start = {
|
|
@@ -167,6 +166,7 @@ export default (new Transformer({
|
|
|
167
166
|
code = code.substring(0, code.lastIndexOf('//# sourceMappingURL'));
|
|
168
167
|
|
|
169
168
|
let map = JSON.parse(nullthrows(host.outputMap));
|
|
169
|
+
// @ts-expect-error TS7006
|
|
170
170
|
map.sources = map.sources.map((source) =>
|
|
171
171
|
path.join(path.dirname(asset.filePath), source),
|
|
172
172
|
);
|
|
@@ -182,4 +182,4 @@ export default (new Transformer({
|
|
|
182
182
|
asset.setMap(sourceMap);
|
|
183
183
|
return [asset];
|
|
184
184
|
},
|
|
185
|
-
})
|
|
185
|
+
}) as Transformer<unknown>;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import type {TSModuleGraph} from './TSModuleGraph';
|
|
3
2
|
|
|
4
3
|
import nullthrows from 'nullthrows';
|
|
5
|
-
import ts, {
|
|
4
|
+
import ts, {EntityName} from 'typescript';
|
|
6
5
|
import {TSModule} from './TSModule';
|
|
7
6
|
import {getExportedName, isDeclaration} from './utils';
|
|
8
7
|
|
|
@@ -16,10 +15,11 @@ export function collect(
|
|
|
16
15
|
|
|
17
16
|
// When module definitions are nested inside each other (e.g with module augmentation),
|
|
18
17
|
// we want to keep track of the hierarchy so we can associated nodes with the right module.
|
|
19
|
-
const moduleStack: Array
|
|
20
|
-
let _currentModule:
|
|
18
|
+
const moduleStack: Array<TSModule | null | undefined> = [];
|
|
19
|
+
let _currentModule: TSModule | null | undefined;
|
|
21
20
|
let visit = (node: any): any => {
|
|
22
21
|
if (ts.isBundle(node)) {
|
|
22
|
+
// @ts-expect-error TS2345
|
|
23
23
|
return factory.updateBundle(node, ts.visitNodes(node.sourceFiles, visit));
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -36,17 +36,23 @@ export function collect(
|
|
|
36
36
|
let currentModule = nullthrows(_currentModule);
|
|
37
37
|
if (ts.isImportDeclaration(node) && node.importClause) {
|
|
38
38
|
if (node.importClause.namedBindings) {
|
|
39
|
+
// @ts-expect-error TS2339
|
|
39
40
|
if (node.importClause.namedBindings.elements) {
|
|
41
|
+
// @ts-expect-error TS2339
|
|
40
42
|
for (let element of node.importClause.namedBindings.elements) {
|
|
41
43
|
currentModule.addImport(
|
|
42
44
|
element.name.text,
|
|
45
|
+
// @ts-expect-error TS2339
|
|
43
46
|
node.moduleSpecifier.text,
|
|
44
47
|
(element.propertyName ?? element.name).text,
|
|
45
48
|
);
|
|
46
49
|
}
|
|
50
|
+
// @ts-expect-error TS2339
|
|
47
51
|
} else if (node.importClause.namedBindings.name) {
|
|
48
52
|
currentModule.addImport(
|
|
53
|
+
// @ts-expect-error TS2339
|
|
49
54
|
node.importClause.namedBindings.name.text,
|
|
55
|
+
// @ts-expect-error TS2339
|
|
50
56
|
node.moduleSpecifier.text,
|
|
51
57
|
'*',
|
|
52
58
|
);
|
|
@@ -56,6 +62,7 @@ export function collect(
|
|
|
56
62
|
if (node.importClause.name) {
|
|
57
63
|
currentModule.addImport(
|
|
58
64
|
node.importClause.name.text,
|
|
65
|
+
// @ts-expect-error TS2339
|
|
59
66
|
node.moduleSpecifier.text,
|
|
60
67
|
'default',
|
|
61
68
|
);
|
|
@@ -64,11 +71,13 @@ export function collect(
|
|
|
64
71
|
|
|
65
72
|
if (ts.isExportDeclaration(node)) {
|
|
66
73
|
if (node.exportClause) {
|
|
74
|
+
// @ts-expect-error TS2339
|
|
67
75
|
for (let element of node.exportClause.elements) {
|
|
68
76
|
if (node.moduleSpecifier) {
|
|
69
77
|
currentModule.addExport(
|
|
70
78
|
element.name.text,
|
|
71
79
|
(element.propertyName ?? element.name).text,
|
|
80
|
+
// @ts-expect-error TS2339
|
|
72
81
|
node.moduleSpecifier.text,
|
|
73
82
|
);
|
|
74
83
|
} else {
|
|
@@ -79,6 +88,7 @@ export function collect(
|
|
|
79
88
|
}
|
|
80
89
|
}
|
|
81
90
|
} else {
|
|
91
|
+
// @ts-expect-error TS18048
|
|
82
92
|
currentModule.addWildcardExport(node.moduleSpecifier.text);
|
|
83
93
|
}
|
|
84
94
|
}
|
|
@@ -118,8 +128,10 @@ export function collect(
|
|
|
118
128
|
(m) => m.kind === ts.SyntaxKind.ExportKeyword,
|
|
119
129
|
);
|
|
120
130
|
for (let v of node.declarationList.declarations) {
|
|
131
|
+
// @ts-expect-error TS2339
|
|
121
132
|
currentModule.addLocal(v.name.text, v);
|
|
122
133
|
if (isExported) {
|
|
134
|
+
// @ts-expect-error TS2339
|
|
123
135
|
currentModule.addExport(v.name.text, v.name.text);
|
|
124
136
|
}
|
|
125
137
|
}
|
|
@@ -139,19 +151,24 @@ export function collect(
|
|
|
139
151
|
// Traverse down an EntityName to the root identifier. Return that to use as the named import specifier,
|
|
140
152
|
// and collect the remaining parts into a new QualifiedName with the local replacement at the root.
|
|
141
153
|
// import('react').JSX.Element => import {JSX} from 'react'; JSX.Element
|
|
154
|
+
// @ts-expect-error TS7023
|
|
142
155
|
function getImportName(
|
|
143
|
-
qualifier:
|
|
156
|
+
qualifier: EntityName | null | undefined,
|
|
144
157
|
local: string,
|
|
145
158
|
factory: typeof ts,
|
|
146
159
|
) {
|
|
147
160
|
if (!qualifier) {
|
|
161
|
+
// @ts-expect-error TS2339
|
|
148
162
|
return ['*', factory.createIdentifier(local)];
|
|
149
163
|
}
|
|
150
164
|
|
|
151
165
|
if (qualifier.kind === ts.SyntaxKind.Identifier) {
|
|
166
|
+
// @ts-expect-error TS2339
|
|
152
167
|
return [qualifier.text, factory.createIdentifier(local)];
|
|
153
168
|
}
|
|
154
169
|
|
|
170
|
+
// @ts-expect-error TS7022
|
|
155
171
|
let [name, entity] = getImportName(qualifier.left, local, factory);
|
|
172
|
+
// @ts-expect-error TS2339
|
|
156
173
|
return [name, factory.createQualifiedName(entity, qualifier.right)];
|
|
157
174
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import {TSModule} from './TSModule';
|
|
3
2
|
import type {TSModuleGraph} from './TSModuleGraph';
|
|
4
3
|
|
|
@@ -30,13 +29,14 @@ export function shake(
|
|
|
30
29
|
|
|
31
30
|
// When module definitions are nested inside each other (e.g with module augmentation),
|
|
32
31
|
// we want to keep track of the hierarchy so we can associated nodes with the right module.
|
|
33
|
-
const moduleStack: Array
|
|
32
|
+
const moduleStack: Array<TSModule | null | undefined> = [];
|
|
34
33
|
|
|
35
34
|
let addedGeneratedImports = false;
|
|
36
35
|
|
|
37
|
-
let _currentModule:
|
|
36
|
+
let _currentModule: TSModule | null | undefined;
|
|
38
37
|
let visit = (node: any): any => {
|
|
39
38
|
if (ts.isBundle(node)) {
|
|
39
|
+
// @ts-expect-error TS2345
|
|
40
40
|
return factory.updateBundle(node, ts.visitNodes(node.sourceFiles, visit));
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -46,9 +46,12 @@ export function shake(
|
|
|
46
46
|
if (moduleStack.length >= 1) {
|
|
47
47
|
// Since we are hoisting them to the top-level scope, we need to add a "declare" keyword to make them ambient.
|
|
48
48
|
// we also want the declare keyword to come after the export keyword to guarantee a valid typings file.
|
|
49
|
+
// @ts-expect-error TS2540
|
|
49
50
|
node.modifiers ??= [];
|
|
50
51
|
const index =
|
|
52
|
+
// @ts-expect-error TS18048
|
|
51
53
|
node.modifiers[0]?.kind === ts.SyntaxKind.ExportKeyword ? 1 : 0;
|
|
54
|
+
// @ts-expect-error TS18048
|
|
52
55
|
node.modifiers.splice(
|
|
53
56
|
index,
|
|
54
57
|
0,
|
|
@@ -60,6 +63,7 @@ export function shake(
|
|
|
60
63
|
moduleStack.push(_currentModule);
|
|
61
64
|
let isFirstModule = !_currentModule;
|
|
62
65
|
_currentModule = moduleGraph.getModule(node.name.text);
|
|
66
|
+
// @ts-expect-error TS2532
|
|
63
67
|
let statements = ts.visitEachChild(node, visit, context).body.statements;
|
|
64
68
|
_currentModule = moduleStack.pop();
|
|
65
69
|
|
|
@@ -85,11 +89,13 @@ export function shake(
|
|
|
85
89
|
if (ts.isExportDeclaration(node)) {
|
|
86
90
|
if (
|
|
87
91
|
!node.moduleSpecifier ||
|
|
92
|
+
// @ts-expect-error TS2339
|
|
88
93
|
moduleGraph.getModule(node.moduleSpecifier.text)
|
|
89
94
|
) {
|
|
90
95
|
if (!node.moduleSpecifier && node.exportClause) {
|
|
91
96
|
// Filter exported elements to only external re-exports
|
|
92
|
-
let exported = [];
|
|
97
|
+
let exported: Array<any> = [];
|
|
98
|
+
// @ts-expect-error TS2339
|
|
93
99
|
for (let element of node.exportClause.elements) {
|
|
94
100
|
let name = (element.propertyName ?? element.name).text;
|
|
95
101
|
if (
|
|
@@ -135,6 +141,7 @@ export function shake(
|
|
|
135
141
|
|
|
136
142
|
// Remove original export modifiers
|
|
137
143
|
node.modifiers = (node.modifiers || []).filter(
|
|
144
|
+
// @ts-expect-error TS7006
|
|
138
145
|
(m) =>
|
|
139
146
|
m.kind !== ts.SyntaxKind.ExportKeyword &&
|
|
140
147
|
m.kind !== ts.SyntaxKind.DefaultKeyword,
|
|
@@ -161,6 +168,7 @@ export function shake(
|
|
|
161
168
|
ts.isFunctionDeclaration(node) ||
|
|
162
169
|
ts.isClassDeclaration(node)
|
|
163
170
|
) {
|
|
171
|
+
// @ts-expect-error TS18048
|
|
164
172
|
node.modifiers.unshift(
|
|
165
173
|
factory.createModifier(ts.SyntaxKind.DeclareKeyword),
|
|
166
174
|
);
|
|
@@ -177,6 +185,7 @@ export function shake(
|
|
|
177
185
|
|
|
178
186
|
// Remove original export modifiers
|
|
179
187
|
node.modifiers = (node.modifiers || []).filter(
|
|
188
|
+
// @ts-expect-error TS7006
|
|
180
189
|
(m) =>
|
|
181
190
|
m.kind !== ts.SyntaxKind.ExportKeyword &&
|
|
182
191
|
m.kind !== ts.SyntaxKind.DeclareKeyword,
|
|
@@ -184,6 +193,7 @@ export function shake(
|
|
|
184
193
|
|
|
185
194
|
// Add export modifier if all declarations are exported.
|
|
186
195
|
let isExported = node.declarationList.declarations.every(
|
|
196
|
+
// @ts-expect-error TS7006
|
|
187
197
|
(d) => exportedNames.get(d.name.text) === currentModule,
|
|
188
198
|
);
|
|
189
199
|
if (isExported) {
|
|
@@ -202,6 +212,7 @@ export function shake(
|
|
|
202
212
|
|
|
203
213
|
if (ts.isVariableDeclaration(node)) {
|
|
204
214
|
// Remove unused variables
|
|
215
|
+
// @ts-expect-error TS2339
|
|
205
216
|
if (!currentModule.used.has(node.name.text)) {
|
|
206
217
|
return null;
|
|
207
218
|
}
|
|
@@ -250,11 +261,13 @@ export function shake(
|
|
|
250
261
|
}
|
|
251
262
|
|
|
252
263
|
function generateImports(factory: any, moduleGraph: TSModuleGraph) {
|
|
253
|
-
|
|
264
|
+
// @ts-expect-error TS2304
|
|
265
|
+
let importStatements: Array<ImportDeclaration | any> = [];
|
|
254
266
|
for (let [specifier, names] of moduleGraph.getAllImports()) {
|
|
255
267
|
let defaultSpecifier;
|
|
256
268
|
let namespaceSpecifier;
|
|
257
|
-
|
|
269
|
+
// @ts-expect-error TS2304
|
|
270
|
+
let namedSpecifiers: Array<ImportSpecifier | any> = [];
|
|
258
271
|
for (let [name, imported] of names) {
|
|
259
272
|
if (imported === 'default') {
|
|
260
273
|
defaultSpecifier = factory.createIdentifier(name);
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import ts from 'typescript';
|
|
3
2
|
|
|
4
|
-
export function getExportedName(node: any):
|
|
3
|
+
export function getExportedName(node: any): string | null | undefined {
|
|
5
4
|
if (!node.modifiers) {
|
|
6
5
|
return null;
|
|
7
6
|
}
|
|
8
7
|
|
|
8
|
+
// @ts-expect-error TS7006
|
|
9
9
|
if (!node.modifiers.some((m) => m.kind === ts.SyntaxKind.ExportKeyword)) {
|
|
10
10
|
return null;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
// @ts-expect-error TS7006
|
|
13
14
|
if (node.modifiers.some((m) => m.kind === ts.SyntaxKind.DefaultKeyword)) {
|
|
14
15
|
return 'default';
|
|
15
16
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
/* eslint-disable no-unused-vars */
|
|
3
2
|
import type {
|
|
4
3
|
ExportDeclaration,
|
|
@@ -26,18 +25,30 @@ const [majorVersion, minorVersion] = ts.versionMajorMinor
|
|
|
26
25
|
export const createImportClause: (
|
|
27
26
|
factory: any,
|
|
28
27
|
isTypeOnly: boolean,
|
|
29
|
-
name: Identifier |
|
|
30
|
-
namedBindings: NamedImportBindings |
|
|
28
|
+
name: Identifier | undefined,
|
|
29
|
+
namedBindings: NamedImportBindings | undefined,
|
|
31
30
|
) => ImportClause = (() => {
|
|
32
31
|
if (majorVersion > 4 || (majorVersion === 4 && minorVersion >= 0)) {
|
|
33
|
-
return (
|
|
34
|
-
factory
|
|
32
|
+
return (
|
|
33
|
+
factory: any,
|
|
34
|
+
isTypeOnly: boolean,
|
|
35
|
+
name: undefined | Identifier,
|
|
36
|
+
namedBindings: undefined | NamedImportBindings,
|
|
37
|
+
) => factory.createImportClause(isTypeOnly, name, namedBindings);
|
|
35
38
|
} else if (majorVersion > 3 || (majorVersion === 3 && minorVersion >= 8)) {
|
|
36
|
-
return (
|
|
37
|
-
factory
|
|
39
|
+
return (
|
|
40
|
+
factory: any,
|
|
41
|
+
isTypeOnly: boolean,
|
|
42
|
+
name: undefined | Identifier,
|
|
43
|
+
namedBindings: undefined | NamedImportBindings,
|
|
44
|
+
) => factory.createImportClause(name, namedBindings, isTypeOnly);
|
|
38
45
|
} else if (majorVersion > 3 || (majorVersion === 3 && minorVersion >= 0)) {
|
|
39
|
-
return (
|
|
40
|
-
factory
|
|
46
|
+
return (
|
|
47
|
+
factory: any,
|
|
48
|
+
isTypeOnly: boolean,
|
|
49
|
+
name: undefined | Identifier,
|
|
50
|
+
namedBindings: undefined | NamedImportBindings,
|
|
51
|
+
) => factory.createImportClause(name, namedBindings);
|
|
41
52
|
} else {
|
|
42
53
|
invariant(false);
|
|
43
54
|
}
|
|
@@ -45,13 +56,19 @@ export const createImportClause: (
|
|
|
45
56
|
|
|
46
57
|
export const createImportDeclaration: (
|
|
47
58
|
factory: any,
|
|
48
|
-
modifiers: Modifier[] |
|
|
49
|
-
importClause: ImportClause |
|
|
59
|
+
modifiers: Modifier[] | undefined,
|
|
60
|
+
importClause: ImportClause | undefined,
|
|
50
61
|
moduleSpecifier: Expression,
|
|
51
62
|
assertClause: AssertClause,
|
|
52
63
|
) => ImportDeclaration = (() => {
|
|
53
64
|
if (majorVersion > 4 || (majorVersion === 4 && minorVersion >= 8)) {
|
|
54
|
-
return (
|
|
65
|
+
return (
|
|
66
|
+
factory: any,
|
|
67
|
+
modifiers: undefined | Array<Modifier>,
|
|
68
|
+
importClause: undefined | ImportClause,
|
|
69
|
+
moduleSpecifier: Expression,
|
|
70
|
+
assertClause: AssertClause,
|
|
71
|
+
) =>
|
|
55
72
|
factory.createImportDeclaration(
|
|
56
73
|
modifiers,
|
|
57
74
|
importClause,
|
|
@@ -59,7 +76,13 @@ export const createImportDeclaration: (
|
|
|
59
76
|
assertClause,
|
|
60
77
|
);
|
|
61
78
|
} else if (majorVersion > 4 || (majorVersion === 4 && minorVersion >= 5)) {
|
|
62
|
-
return (
|
|
79
|
+
return (
|
|
80
|
+
factory: any,
|
|
81
|
+
modifiers: undefined | Array<Modifier>,
|
|
82
|
+
importClause: undefined | ImportClause,
|
|
83
|
+
moduleSpecifier: Expression,
|
|
84
|
+
assertClause: AssertClause,
|
|
85
|
+
) =>
|
|
63
86
|
factory.createImportDeclaration(
|
|
64
87
|
undefined /* decorators */,
|
|
65
88
|
modifiers,
|
|
@@ -68,7 +91,13 @@ export const createImportDeclaration: (
|
|
|
68
91
|
assertClause,
|
|
69
92
|
);
|
|
70
93
|
} else if (majorVersion > 3 || (majorVersion === 3 && minorVersion >= 0)) {
|
|
71
|
-
return (
|
|
94
|
+
return (
|
|
95
|
+
factory: any,
|
|
96
|
+
modifiers: undefined | Array<Modifier>,
|
|
97
|
+
importClause: undefined | ImportClause,
|
|
98
|
+
moduleSpecifier: Expression,
|
|
99
|
+
assertClause: AssertClause,
|
|
100
|
+
) =>
|
|
72
101
|
factory.createImportDeclaration(
|
|
73
102
|
undefined /* decorators */,
|
|
74
103
|
modifiers,
|
|
@@ -83,15 +112,23 @@ export const createImportDeclaration: (
|
|
|
83
112
|
export const createImportSpecifier: (
|
|
84
113
|
factory: any,
|
|
85
114
|
isTypeOnly: boolean,
|
|
86
|
-
propertyName: Identifier |
|
|
115
|
+
propertyName: Identifier | undefined,
|
|
87
116
|
name: Identifier,
|
|
88
117
|
) => ImportSpecifier = (() => {
|
|
89
118
|
if (majorVersion > 4 || (majorVersion === 4 && minorVersion >= 5)) {
|
|
90
|
-
return (
|
|
91
|
-
factory
|
|
119
|
+
return (
|
|
120
|
+
factory: any,
|
|
121
|
+
isTypeOnly: boolean,
|
|
122
|
+
propertyName: undefined | Identifier,
|
|
123
|
+
name: Identifier,
|
|
124
|
+
) => factory.createImportSpecifier(isTypeOnly, propertyName, name);
|
|
92
125
|
} else if (majorVersion > 3 || (majorVersion === 3 && minorVersion >= 0)) {
|
|
93
|
-
return (
|
|
94
|
-
factory
|
|
126
|
+
return (
|
|
127
|
+
factory: any,
|
|
128
|
+
isTypeOnly: boolean,
|
|
129
|
+
propertyName: undefined | Identifier,
|
|
130
|
+
name: Identifier,
|
|
131
|
+
) => factory.createImportSpecifier(propertyName, name);
|
|
95
132
|
} else {
|
|
96
133
|
invariant(false);
|
|
97
134
|
}
|
|
@@ -100,21 +137,21 @@ export const createImportSpecifier: (
|
|
|
100
137
|
export const updateExportDeclaration: (
|
|
101
138
|
factory: any,
|
|
102
139
|
node: ExportDeclaration,
|
|
103
|
-
modifiers: Modifier[] |
|
|
140
|
+
modifiers: Modifier[] | undefined,
|
|
104
141
|
isTypeOnly: boolean,
|
|
105
|
-
exportClause: NamedExportBindings |
|
|
106
|
-
moduleSpecifier: Expression |
|
|
107
|
-
assertClause: AssertClause |
|
|
142
|
+
exportClause: NamedExportBindings | undefined,
|
|
143
|
+
moduleSpecifier: Expression | undefined,
|
|
144
|
+
assertClause: AssertClause | undefined,
|
|
108
145
|
) => ExportDeclaration = (() => {
|
|
109
146
|
if (majorVersion > 4 || (majorVersion === 4 && minorVersion >= 8)) {
|
|
110
147
|
return (
|
|
111
|
-
factory,
|
|
112
|
-
node,
|
|
113
|
-
modifiers
|
|
114
|
-
isTypeOnly,
|
|
115
|
-
exportClause,
|
|
116
|
-
moduleSpecifier,
|
|
117
|
-
assertClause,
|
|
148
|
+
factory: any,
|
|
149
|
+
node: ExportDeclaration,
|
|
150
|
+
modifiers: undefined | Array<Modifier>,
|
|
151
|
+
isTypeOnly: boolean,
|
|
152
|
+
exportClause: undefined | NamedExportBindings,
|
|
153
|
+
moduleSpecifier: undefined | Expression,
|
|
154
|
+
assertClause: undefined | AssertClause,
|
|
118
155
|
) =>
|
|
119
156
|
factory.updateExportDeclaration(
|
|
120
157
|
node,
|
|
@@ -126,13 +163,13 @@ export const updateExportDeclaration: (
|
|
|
126
163
|
);
|
|
127
164
|
} else if (majorVersion > 4 || (majorVersion === 4 && minorVersion >= 5)) {
|
|
128
165
|
return (
|
|
129
|
-
factory,
|
|
130
|
-
node,
|
|
131
|
-
modifiers
|
|
132
|
-
isTypeOnly,
|
|
133
|
-
exportClause,
|
|
134
|
-
moduleSpecifier,
|
|
135
|
-
assertClause,
|
|
166
|
+
factory: any,
|
|
167
|
+
node: ExportDeclaration,
|
|
168
|
+
modifiers: undefined | Array<Modifier>,
|
|
169
|
+
isTypeOnly: boolean,
|
|
170
|
+
exportClause: undefined | NamedExportBindings,
|
|
171
|
+
moduleSpecifier: undefined | Expression,
|
|
172
|
+
assertClause: undefined | AssertClause,
|
|
136
173
|
) =>
|
|
137
174
|
factory.updateExportDeclaration(
|
|
138
175
|
node,
|
|
@@ -145,13 +182,13 @@ export const updateExportDeclaration: (
|
|
|
145
182
|
);
|
|
146
183
|
} else if (majorVersion > 4 || (majorVersion === 4 && minorVersion >= 0)) {
|
|
147
184
|
return (
|
|
148
|
-
factory,
|
|
149
|
-
node,
|
|
150
|
-
modifiers
|
|
151
|
-
isTypeOnly,
|
|
152
|
-
exportClause,
|
|
153
|
-
moduleSpecifier,
|
|
154
|
-
assertClause,
|
|
185
|
+
factory: any,
|
|
186
|
+
node: ExportDeclaration,
|
|
187
|
+
modifiers: undefined | Array<Modifier>,
|
|
188
|
+
isTypeOnly: boolean,
|
|
189
|
+
exportClause: undefined | NamedExportBindings,
|
|
190
|
+
moduleSpecifier: undefined | Expression,
|
|
191
|
+
assertClause: undefined | AssertClause,
|
|
155
192
|
) =>
|
|
156
193
|
factory.updateExportDeclaration(
|
|
157
194
|
node,
|
|
@@ -163,13 +200,13 @@ export const updateExportDeclaration: (
|
|
|
163
200
|
);
|
|
164
201
|
} else if (majorVersion > 3 || (majorVersion === 3 && minorVersion >= 8)) {
|
|
165
202
|
return (
|
|
166
|
-
factory,
|
|
167
|
-
node,
|
|
168
|
-
modifiers
|
|
169
|
-
isTypeOnly,
|
|
170
|
-
exportClause,
|
|
171
|
-
moduleSpecifier,
|
|
172
|
-
assertClause,
|
|
203
|
+
factory: any,
|
|
204
|
+
node: ExportDeclaration,
|
|
205
|
+
modifiers: undefined | Array<Modifier>,
|
|
206
|
+
isTypeOnly: boolean,
|
|
207
|
+
exportClause: undefined | NamedExportBindings,
|
|
208
|
+
moduleSpecifier: undefined | Expression,
|
|
209
|
+
assertClause: undefined | AssertClause,
|
|
173
210
|
) =>
|
|
174
211
|
factory.updateExportDeclaration(
|
|
175
212
|
node,
|
|
@@ -181,13 +218,13 @@ export const updateExportDeclaration: (
|
|
|
181
218
|
);
|
|
182
219
|
} else if (majorVersion > 3 || (majorVersion === 3 && minorVersion >= 0)) {
|
|
183
220
|
return (
|
|
184
|
-
factory,
|
|
185
|
-
node,
|
|
186
|
-
modifiers
|
|
187
|
-
isTypeOnly,
|
|
188
|
-
exportClause,
|
|
189
|
-
moduleSpecifier,
|
|
190
|
-
assertClause,
|
|
221
|
+
factory: any,
|
|
222
|
+
node: ExportDeclaration,
|
|
223
|
+
modifiers: undefined | Array<Modifier>,
|
|
224
|
+
isTypeOnly: boolean,
|
|
225
|
+
exportClause: undefined | NamedExportBindings,
|
|
226
|
+
moduleSpecifier: undefined | Expression,
|
|
227
|
+
assertClause: undefined | AssertClause,
|
|
191
228
|
) =>
|
|
192
229
|
factory.updateExportDeclaration(
|
|
193
230
|
node,
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../tsconfig.base.json",
|
|
3
|
+
"include": ["src"],
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"composite": true
|
|
6
|
+
},
|
|
7
|
+
"references": [
|
|
8
|
+
{
|
|
9
|
+
"path": "../../core/diagnostic/tsconfig.json"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"path": "../../core/plugin/tsconfig.json"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"path": "../../core/utils/tsconfig.json"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"path": "../../utils/ts-utils/tsconfig.json"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"path": "../../core/source-map/tsconfig.json"
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|