@atlaspack/transformer-typescript-types 2.14.21-typescript-bc4459c37.0 → 2.14.21

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaspack/transformer-typescript-types
2
2
 
3
+ ## 2.14.21
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @atlaspack/utils@2.17.3
9
+ - @atlaspack/plugin@2.14.21
10
+
3
11
  ## 2.14.20
4
12
 
5
13
  ### Patch Changes
@@ -78,20 +78,15 @@ class TSModuleGraph {
78
78
  }
79
79
  }
80
80
  getExport(m, e) {
81
- // @ts-expect-error TS2339
82
81
  (0, _assert().default)(e.name != null);
83
- // @ts-expect-error TS2339
84
82
  let exportName = e.name;
85
83
 
86
84
  // Re-export
87
- // @ts-expect-error TS2339
88
85
  if (e.specifier && e.imported) {
89
86
  let m = this.getModule(e.specifier);
90
87
  if (!m) {
91
88
  return null;
92
89
  }
93
-
94
- // @ts-expect-error TS2339
95
90
  let exp = this.resolveExport(m, e.imported);
96
91
  if (!exp) {
97
92
  return null;
@@ -120,7 +115,6 @@ class TSModuleGraph {
120
115
  return {
121
116
  module: m,
122
117
  name: exportName,
123
- // @ts-expect-error TS2339
124
118
  imported: e.imported != null ? m.getName(e.imported) : exportName
125
119
  };
126
120
  }
@@ -142,7 +136,6 @@ class TSModuleGraph {
142
136
  }
143
137
  resolveExport(module, name) {
144
138
  for (let e of module.exports) {
145
- // @ts-expect-error TS2339
146
139
  if (e.name === name) {
147
140
  return this.getExport(module, e);
148
141
  } else if (e.specifier) {
@@ -156,7 +149,6 @@ class TSModuleGraph {
156
149
  getAllExports(module = (0, _nullthrows().default)(this.mainModule), excludeDefault = false) {
157
150
  let res = [];
158
151
  for (let e of module.exports) {
159
- // @ts-expect-error TS2339
160
152
  if (e.name && (!excludeDefault || e.name !== 'default')) {
161
153
  let exp = this.getExport(module, e);
162
154
  if (exp) {
@@ -226,14 +218,11 @@ class TSModuleGraph {
226
218
  // Map of imported specifiers -> map of imported names to local names
227
219
  let imports = new Map();
228
220
  for (let [m, orig] of importedSymbolsToUpdate) {
229
- // @ts-expect-error TS2339
230
221
  let imp = (0, _nullthrows().default)(m.imports.get(orig));
231
- // @ts-expect-error TS2345
232
222
  let imported = (0, _nullthrows().default)(this.resolveImport(m, orig));
233
223
 
234
224
  // If the module is bundled, map the local name to the original exported name.
235
225
  if (this.modules.has(imp.specifier)) {
236
- // @ts-expect-error TS2339
237
226
  m.names.set(orig, imported.imported);
238
227
  continue;
239
228
  }
@@ -255,8 +244,6 @@ class TSModuleGraph {
255
244
  }
256
245
  importedNames.set(imported.imported, name);
257
246
  }
258
-
259
- // @ts-expect-error TS2339
260
247
  m.names.set(orig, name);
261
248
  }
262
249
  return exportedNames;
@@ -98,16 +98,14 @@ var _default = exports.default = new (_plugin().Transformer)({
98
98
  incremental: false
99
99
  };
100
100
  let host = new (_tsUtils().CompilerHost)(options.inputFS, _typescript().default, logger);
101
- // @ts-expect-error TS2345
101
+ // $FlowFixMe
102
102
  let program = _typescript().default.createProgram([asset.filePath], opts, host);
103
103
  for (let file of program.getSourceFiles()) {
104
104
  if (_path().default.normalize(file.fileName) !== asset.filePath) {
105
105
  asset.invalidateOnFileChange(host.redirectTypes.get(file.fileName) ?? file.fileName);
106
106
  }
107
107
  }
108
- let mainModuleName = (0, _utils().normalizeSeparators)(_path().default
109
- // @ts-expect-error TS2339
110
- .relative(program.getCommonSourceDirectory(), asset.filePath).slice(0, -_path().default.extname(asset.filePath).length));
108
+ let mainModuleName = (0, _utils().normalizeSeparators)(_path().default.relative(program.getCommonSourceDirectory(), asset.filePath).slice(0, -_path().default.extname(asset.filePath).length));
111
109
  let moduleGraph = new _TSModuleGraph.TSModuleGraph(mainModuleName);
112
110
  let emitResult = program.emit(undefined, undefined, undefined, true, {
113
111
  afterDeclarations: [
@@ -122,7 +120,6 @@ var _default = exports.default = new (_plugin().Transformer)({
122
120
  });
123
121
  let diagnostics = _typescript().default.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
124
122
  let diagnosticIds = new Set();
125
- // @ts-expect-error TS2304
126
123
  let deduplicatedDiagnostics = [];
127
124
  for (let d of diagnostics) {
128
125
  if (d.start != null && d.length != null && d.messageText != null) {
@@ -147,6 +144,8 @@ var _default = exports.default = new (_plugin().Transformer)({
147
144
  if (file.fileName) {
148
145
  filename = file.fileName;
149
146
  }
147
+
148
+ // $FlowFixMe
150
149
  if (source) {
151
150
  let lineChar = file.getLineAndCharacterOfPosition(diagnostic.start);
152
151
  let start = {
@@ -192,7 +191,6 @@ var _default = exports.default = new (_plugin().Transformer)({
192
191
  let code = (0, _nullthrows().default)(host.outputCode);
193
192
  code = code.substring(0, code.lastIndexOf('//# sourceMappingURL'));
194
193
  let map = JSON.parse((0, _nullthrows().default)(host.outputMap));
195
- // @ts-expect-error TS7006
196
194
  map.sources = map.sources.map(source => _path().default.join(_path().default.dirname(asset.filePath), source));
197
195
  let sourceMap = null;
198
196
  if (map.mappings) {
package/lib/collect.js CHANGED
@@ -33,7 +33,6 @@ function collect(moduleGraph, context, sourceFile) {
33
33
  let _currentModule;
34
34
  let visit = node => {
35
35
  if (_typescript().default.isBundle(node)) {
36
- // @ts-expect-error TS2345
37
36
  return factory.updateBundle(node, _typescript().default.visitNodes(node.sourceFiles, visit));
38
37
  }
39
38
  if (_typescript().default.isModuleDeclaration(node)) {
@@ -47,43 +46,28 @@ function collect(moduleGraph, context, sourceFile) {
47
46
  let currentModule = (0, _nullthrows().default)(_currentModule);
48
47
  if (_typescript().default.isImportDeclaration(node) && node.importClause) {
49
48
  if (node.importClause.namedBindings) {
50
- // @ts-expect-error TS2339
51
49
  if (node.importClause.namedBindings.elements) {
52
- // @ts-expect-error TS2339
53
50
  for (let element of node.importClause.namedBindings.elements) {
54
- currentModule.addImport(element.name.text,
55
- // @ts-expect-error TS2339
56
- node.moduleSpecifier.text, (element.propertyName ?? element.name).text);
51
+ currentModule.addImport(element.name.text, node.moduleSpecifier.text, (element.propertyName ?? element.name).text);
57
52
  }
58
- // @ts-expect-error TS2339
59
53
  } else if (node.importClause.namedBindings.name) {
60
- currentModule.addImport(
61
- // @ts-expect-error TS2339
62
- node.importClause.namedBindings.name.text,
63
- // @ts-expect-error TS2339
64
- node.moduleSpecifier.text, '*');
54
+ currentModule.addImport(node.importClause.namedBindings.name.text, node.moduleSpecifier.text, '*');
65
55
  }
66
56
  }
67
57
  if (node.importClause.name) {
68
- currentModule.addImport(node.importClause.name.text,
69
- // @ts-expect-error TS2339
70
- node.moduleSpecifier.text, 'default');
58
+ currentModule.addImport(node.importClause.name.text, node.moduleSpecifier.text, 'default');
71
59
  }
72
60
  }
73
61
  if (_typescript().default.isExportDeclaration(node)) {
74
62
  if (node.exportClause) {
75
- // @ts-expect-error TS2339
76
63
  for (let element of node.exportClause.elements) {
77
64
  if (node.moduleSpecifier) {
78
- currentModule.addExport(element.name.text, (element.propertyName ?? element.name).text,
79
- // @ts-expect-error TS2339
80
- node.moduleSpecifier.text);
65
+ currentModule.addExport(element.name.text, (element.propertyName ?? element.name).text, node.moduleSpecifier.text);
81
66
  } else {
82
67
  currentModule.addExport(element.name.text, (element.propertyName ?? element.name).text);
83
68
  }
84
69
  }
85
70
  } else {
86
- // @ts-expect-error TS18048
87
71
  currentModule.addWildcardExport(node.moduleSpecifier.text);
88
72
  }
89
73
  }
@@ -112,10 +96,8 @@ function collect(moduleGraph, context, sourceFile) {
112
96
  if (_typescript().default.isVariableStatement(node) && node.modifiers) {
113
97
  let isExported = node.modifiers.some(m => m.kind === _typescript().default.SyntaxKind.ExportKeyword);
114
98
  for (let v of node.declarationList.declarations) {
115
- // @ts-expect-error TS2339
116
99
  currentModule.addLocal(v.name.text, v);
117
100
  if (isExported) {
118
- // @ts-expect-error TS2339
119
101
  currentModule.addExport(v.name.text, v.name.text);
120
102
  }
121
103
  }
@@ -134,19 +116,13 @@ function collect(moduleGraph, context, sourceFile) {
134
116
  // Traverse down an EntityName to the root identifier. Return that to use as the named import specifier,
135
117
  // and collect the remaining parts into a new QualifiedName with the local replacement at the root.
136
118
  // import('react').JSX.Element => import {JSX} from 'react'; JSX.Element
137
- // @ts-expect-error TS7023
138
119
  function getImportName(qualifier, local, factory) {
139
120
  if (!qualifier) {
140
- // @ts-expect-error TS2339
141
121
  return ['*', factory.createIdentifier(local)];
142
122
  }
143
123
  if (qualifier.kind === _typescript().default.SyntaxKind.Identifier) {
144
- // @ts-expect-error TS2339
145
124
  return [qualifier.text, factory.createIdentifier(local)];
146
125
  }
147
-
148
- // @ts-expect-error TS7022
149
126
  let [name, entity] = getImportName(qualifier.left, local, factory);
150
- // @ts-expect-error TS2339
151
127
  return [name, factory.createQualifiedName(entity, qualifier.right)];
152
128
  }
package/lib/shake.js CHANGED
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.shake = shake;
7
+ var _TSModule = require("./TSModule");
7
8
  function _typescript() {
8
9
  const data = _interopRequireDefault(require("typescript"));
9
10
  _typescript = function () {
@@ -42,7 +43,6 @@ function shake(moduleGraph, context, sourceFile) {
42
43
  let _currentModule;
43
44
  let visit = node => {
44
45
  if (_typescript().default.isBundle(node)) {
45
- // @ts-expect-error TS2345
46
46
  return factory.updateBundle(node, _typescript().default.visitNodes(node.sourceFiles, visit));
47
47
  }
48
48
 
@@ -53,19 +53,14 @@ function shake(moduleGraph, context, sourceFile) {
53
53
  var _node$modifiers$;
54
54
  // Since we are hoisting them to the top-level scope, we need to add a "declare" keyword to make them ambient.
55
55
  // we also want the declare keyword to come after the export keyword to guarantee a valid typings file.
56
- // @ts-expect-error TS2540
57
56
  node.modifiers ??= [];
58
- const index =
59
- // @ts-expect-error TS18048
60
- ((_node$modifiers$ = node.modifiers[0]) === null || _node$modifiers$ === void 0 ? void 0 : _node$modifiers$.kind) === _typescript().default.SyntaxKind.ExportKeyword ? 1 : 0;
61
- // @ts-expect-error TS18048
57
+ const index = ((_node$modifiers$ = node.modifiers[0]) === null || _node$modifiers$ === void 0 ? void 0 : _node$modifiers$.kind) === _typescript().default.SyntaxKind.ExportKeyword ? 1 : 0;
62
58
  node.modifiers.splice(index, 0, factory.createModifier(_typescript().default.SyntaxKind.DeclareKeyword));
63
59
  return node;
64
60
  }
65
61
  moduleStack.push(_currentModule);
66
62
  let isFirstModule = !_currentModule;
67
63
  _currentModule = moduleGraph.getModule(node.name.text);
68
- // @ts-expect-error TS2532
69
64
  let statements = _typescript().default.visitEachChild(node, visit, context).body.statements;
70
65
  _currentModule = moduleStack.pop();
71
66
  if (isFirstModule && !addedGeneratedImports) {
@@ -85,13 +80,10 @@ function shake(moduleGraph, context, sourceFile) {
85
80
  let currentModule = (0, _nullthrows().default)(_currentModule);
86
81
  // Remove exports from flattened modules
87
82
  if (_typescript().default.isExportDeclaration(node)) {
88
- if (!node.moduleSpecifier ||
89
- // @ts-expect-error TS2339
90
- moduleGraph.getModule(node.moduleSpecifier.text)) {
83
+ if (!node.moduleSpecifier || moduleGraph.getModule(node.moduleSpecifier.text)) {
91
84
  if (!node.moduleSpecifier && node.exportClause) {
92
85
  // Filter exported elements to only external re-exports
93
86
  let exported = [];
94
- // @ts-expect-error TS2339
95
87
  for (let element of node.exportClause.elements) {
96
88
  let name = (element.propertyName ?? element.name).text;
97
89
  if (exportedNames.get(name) === currentModule && !currentModule.hasBinding(name)) {
@@ -130,9 +122,7 @@ function shake(moduleGraph, context, sourceFile) {
130
122
  }
131
123
 
132
124
  // Remove original export modifiers
133
- node.modifiers = (node.modifiers || []).filter(
134
- // @ts-expect-error TS7006
135
- m => m.kind !== _typescript().default.SyntaxKind.ExportKeyword && m.kind !== _typescript().default.SyntaxKind.DefaultKeyword);
125
+ node.modifiers = (node.modifiers || []).filter(m => m.kind !== _typescript().default.SyntaxKind.ExportKeyword && m.kind !== _typescript().default.SyntaxKind.DefaultKeyword);
136
126
 
137
127
  // Rename declarations
138
128
  let newName = currentModule.getName(name);
@@ -147,7 +137,6 @@ function shake(moduleGraph, context, sourceFile) {
147
137
  }
148
138
  node.modifiers.unshift(factory.createModifier(_typescript().default.SyntaxKind.ExportKeyword));
149
139
  } else if (_typescript().default.isFunctionDeclaration(node) || _typescript().default.isClassDeclaration(node)) {
150
- // @ts-expect-error TS18048
151
140
  node.modifiers.unshift(factory.createModifier(_typescript().default.SyntaxKind.DeclareKeyword));
152
141
  }
153
142
  }
@@ -160,14 +149,10 @@ function shake(moduleGraph, context, sourceFile) {
160
149
  }
161
150
 
162
151
  // Remove original export modifiers
163
- node.modifiers = (node.modifiers || []).filter(
164
- // @ts-expect-error TS7006
165
- m => m.kind !== _typescript().default.SyntaxKind.ExportKeyword && m.kind !== _typescript().default.SyntaxKind.DeclareKeyword);
152
+ node.modifiers = (node.modifiers || []).filter(m => m.kind !== _typescript().default.SyntaxKind.ExportKeyword && m.kind !== _typescript().default.SyntaxKind.DeclareKeyword);
166
153
 
167
154
  // Add export modifier if all declarations are exported.
168
- let isExported = node.declarationList.declarations.every(
169
- // @ts-expect-error TS7006
170
- d => exportedNames.get(d.name.text) === currentModule);
155
+ let isExported = node.declarationList.declarations.every(d => exportedNames.get(d.name.text) === currentModule);
171
156
  if (isExported) {
172
157
  node.modifiers.unshift(factory.createModifier(_typescript().default.SyntaxKind.ExportKeyword));
173
158
  } else {
@@ -178,7 +163,6 @@ function shake(moduleGraph, context, sourceFile) {
178
163
  }
179
164
  if (_typescript().default.isVariableDeclaration(node)) {
180
165
  // Remove unused variables
181
- // @ts-expect-error TS2339
182
166
  if (!currentModule.used.has(node.name.text)) {
183
167
  return null;
184
168
  }
@@ -214,12 +198,10 @@ function shake(moduleGraph, context, sourceFile) {
214
198
  return _typescript().default.visitNode(sourceFile, visit);
215
199
  }
216
200
  function generateImports(factory, moduleGraph) {
217
- // @ts-expect-error TS2304
218
201
  let importStatements = [];
219
202
  for (let [specifier, names] of moduleGraph.getAllImports()) {
220
203
  let defaultSpecifier;
221
204
  let namespaceSpecifier;
222
- // @ts-expect-error TS2304
223
205
  let namedSpecifiers = [];
224
206
  for (let [name, imported] of names) {
225
207
  if (imported === 'default') {
package/lib/utils.js CHANGED
@@ -17,13 +17,9 @@ function getExportedName(node) {
17
17
  if (!node.modifiers) {
18
18
  return null;
19
19
  }
20
-
21
- // @ts-expect-error TS7006
22
20
  if (!node.modifiers.some(m => m.kind === _typescript().default.SyntaxKind.ExportKeyword)) {
23
21
  return null;
24
22
  }
25
-
26
- // @ts-expect-error TS7006
27
23
  if (node.modifiers.some(m => m.kind === _typescript().default.SyntaxKind.DefaultKeyword)) {
28
24
  return 'default';
29
25
  }
package/lib/wrappers.js CHANGED
@@ -20,7 +20,6 @@ function _assert() {
20
20
  }
21
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
22
  /* eslint-disable no-unused-vars */
23
-
24
23
  const [majorVersion, minorVersion] = _typescript().default.versionMajorMinor.split('.').map(num => parseInt(num, 10));
25
24
 
26
25
  // Everything below was generated using https://github.com/mischnic/tsc-version-wrapper
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/transformer-typescript-types",
3
- "version": "2.14.21-typescript-bc4459c37.0",
3
+ "version": "2.14.21",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -9,18 +9,17 @@
9
9
  "type": "git",
10
10
  "url": "https://github.com/atlassian-labs/atlaspack.git"
11
11
  },
12
- "main": "./lib/TSTypesTransformer.js",
13
- "source": "./src/TSTypesTransformer.ts",
14
- "types": "./lib/TSTypesTransformer.d.ts",
12
+ "main": "lib/TSTypesTransformer.js",
13
+ "source": "src/TSTypesTransformer.js",
15
14
  "engines": {
16
15
  "node": ">= 16.0.0"
17
16
  },
18
17
  "dependencies": {
19
- "@atlaspack/diagnostic": "2.14.2-typescript-bc4459c37.0",
20
- "@atlaspack/plugin": "2.14.21-typescript-bc4459c37.0",
21
- "@atlaspack/ts-utils": "2.14.2-typescript-bc4459c37.0",
22
- "@atlaspack/utils": "2.17.3-typescript-bc4459c37.0",
18
+ "@atlaspack/diagnostic": "2.14.1",
19
+ "@atlaspack/plugin": "2.14.21",
23
20
  "@parcel/source-map": "^2.1.1",
21
+ "@atlaspack/ts-utils": "2.14.1",
22
+ "@atlaspack/utils": "2.17.3",
24
23
  "nullthrows": "^1.1.1"
25
24
  },
26
25
  "devDependencies": {
@@ -29,9 +28,5 @@
29
28
  "peerDependencies": {
30
29
  "typescript": ">=3.0.0"
31
30
  },
32
- "type": "commonjs",
33
- "scripts": {
34
- "check-ts": "tsc --emitDeclarationOnly --rootDir src"
35
- },
36
- "gitHead": "bc4459c37a38ef1f74772126637e1d8841d1fcb0"
37
- }
31
+ "type": "commonjs"
32
+ }
@@ -1,16 +1,9 @@
1
- export type Import = {
2
- specifier: string;
3
- imported: string;
4
- };
1
+ // @flow
2
+
3
+ export type Import = {|specifier: string, imported: string|};
5
4
  export type Export =
6
- | {
7
- name: string;
8
- imported: string;
9
- specifier?: string | null | undefined;
10
- }
11
- | {
12
- specifier: string;
13
- };
5
+ | {|name: string, imported: string, specifier?: ?string|}
6
+ | {|specifier: string|};
14
7
 
15
8
  export class TSModule {
16
9
  imports: Map<string, Import>;
@@ -35,7 +28,7 @@ export class TSModule {
35
28
  }
36
29
 
37
30
  // if not a reexport: imported = local, name = exported
38
- addExport(name: string, imported: string, specifier?: string | null) {
31
+ addExport(name: string, imported: string, specifier: ?string) {
39
32
  this.exports.push({name, specifier, imported});
40
33
  }
41
34
 
@@ -1,3 +1,4 @@
1
+ // @flow
1
2
  import type {TSModule, Export} from './TSModule';
2
3
 
3
4
  import nullthrows from 'nullthrows';
@@ -7,7 +8,7 @@ import ts from 'typescript';
7
8
  export class TSModuleGraph {
8
9
  modules: Map<string, TSModule>;
9
10
  mainModuleName: string;
10
- mainModule: TSModule | null | undefined;
11
+ mainModule: ?TSModule;
11
12
  syntheticImportCount: number;
12
13
 
13
14
  constructor(mainModuleName: string) {
@@ -24,7 +25,7 @@ export class TSModuleGraph {
24
25
  }
25
26
  }
26
27
 
27
- getModule(name: string): TSModule | null | undefined {
28
+ getModule(name: string): ?TSModule {
28
29
  return this.modules.get(name);
29
30
  }
30
31
 
@@ -76,28 +77,17 @@ export class TSModuleGraph {
76
77
  getExport(
77
78
  m: TSModule,
78
79
  e: Export,
79
- ):
80
- | {
81
- imported: string;
82
- module: TSModule;
83
- name: string;
84
- }
85
- | null
86
- | undefined {
87
- // @ts-expect-error TS2339
80
+ ): ?{|imported: string, module: TSModule, name: string|} {
88
81
  invariant(e.name != null);
89
- // @ts-expect-error TS2339
90
82
  let exportName = e.name;
91
83
 
92
84
  // Re-export
93
- // @ts-expect-error TS2339
94
85
  if (e.specifier && e.imported) {
95
86
  let m = this.getModule(e.specifier);
96
87
  if (!m) {
97
88
  return null;
98
89
  }
99
90
 
100
- // @ts-expect-error TS2339
101
91
  let exp = this.resolveExport(m, e.imported);
102
92
  if (!exp) {
103
93
  return null;
@@ -124,7 +114,6 @@ export class TSModuleGraph {
124
114
  return {
125
115
  module: m,
126
116
  name: exportName,
127
- // @ts-expect-error TS2339
128
117
  imported: e.imported != null ? m.getName(e.imported) : exportName,
129
118
  };
130
119
  }
@@ -133,14 +122,7 @@ export class TSModuleGraph {
133
122
  module: TSModule,
134
123
  local: string,
135
124
  imported?: string,
136
- ):
137
- | {
138
- imported: string;
139
- module: TSModule;
140
- name: string;
141
- }
142
- | null
143
- | undefined {
125
+ ): ?{|imported: string, module: TSModule, name: string|} {
144
126
  let i = module.imports.get(local);
145
127
  if (!i) {
146
128
  return null;
@@ -158,16 +140,8 @@ export class TSModuleGraph {
158
140
  resolveExport(
159
141
  module: TSModule,
160
142
  name: string,
161
- ):
162
- | {
163
- imported: string;
164
- module: TSModule;
165
- name: string;
166
- }
167
- | null
168
- | undefined {
143
+ ): ?{|imported: string, module: TSModule, name: string|} {
169
144
  for (let e of module.exports) {
170
- // @ts-expect-error TS2339
171
145
  if (e.name === name) {
172
146
  return this.getExport(module, e);
173
147
  } else if (e.specifier) {
@@ -185,18 +159,9 @@ export class TSModuleGraph {
185
159
  getAllExports(
186
160
  module: TSModule = nullthrows(this.mainModule),
187
161
  excludeDefault: boolean = false,
188
- ): Array<{
189
- imported: string;
190
- module: TSModule;
191
- name: string;
192
- }> {
193
- let res: Array<{
194
- imported: string;
195
- module: TSModule;
196
- name: string;
197
- }> = [];
162
+ ): Array<{|imported: string, module: TSModule, name: string|}> {
163
+ let res = [];
198
164
  for (let e of module.exports) {
199
- // @ts-expect-error TS2339
200
165
  if (e.name && (!excludeDefault || e.name !== 'default')) {
201
166
  let exp = this.getExport(module, e);
202
167
  if (exp) {
@@ -244,7 +209,7 @@ export class TSModuleGraph {
244
209
  exportedNames.set(e.name, e.module);
245
210
  }
246
211
 
247
- let importedSymbolsToUpdate: Array<Array<TSModule | string>> = [];
212
+ let importedSymbolsToUpdate = [];
248
213
 
249
214
  // Assign unique names across all modules
250
215
  for (let m of this.modules.values()) {
@@ -275,14 +240,11 @@ export class TSModuleGraph {
275
240
  let imports = new Map();
276
241
 
277
242
  for (let [m, orig] of importedSymbolsToUpdate) {
278
- // @ts-expect-error TS2339
279
243
  let imp = nullthrows(m.imports.get(orig));
280
- // @ts-expect-error TS2345
281
244
  let imported = nullthrows(this.resolveImport(m, orig));
282
245
 
283
246
  // If the module is bundled, map the local name to the original exported name.
284
247
  if (this.modules.has(imp.specifier)) {
285
- // @ts-expect-error TS2339
286
248
  m.names.set(orig, imported.imported);
287
249
  continue;
288
250
  }
@@ -307,7 +269,6 @@ export class TSModuleGraph {
307
269
  importedNames.set(imported.imported, name);
308
270
  }
309
271
 
310
- // @ts-expect-error TS2339
311
272
  m.names.set(orig, name);
312
273
  }
313
274
 
@@ -1,3 +1,5 @@
1
+ // @flow strict-local
2
+
1
3
  import {Transformer} from '@atlaspack/plugin';
2
4
  import path from 'path';
3
5
  import SourceMap from '@parcel/source-map';
@@ -13,7 +15,7 @@ import nullthrows from 'nullthrows';
13
15
  import {collect} from './collect';
14
16
  import {shake} from './shake';
15
17
 
16
- export default new Transformer({
18
+ export default (new Transformer({
17
19
  loadConfig({config, options}) {
18
20
  return loadTSConfig(config, options);
19
21
  },
@@ -39,7 +41,7 @@ export default new Transformer({
39
41
  };
40
42
 
41
43
  let host = new CompilerHost(options.inputFS, ts, logger);
42
- // @ts-expect-error TS2345
44
+ // $FlowFixMe
43
45
  let program = ts.createProgram([asset.filePath], opts, host);
44
46
 
45
47
  for (let file of program.getSourceFiles()) {
@@ -52,7 +54,6 @@ export default new Transformer({
52
54
 
53
55
  let mainModuleName = normalizeSeparators(
54
56
  path
55
- // @ts-expect-error TS2339
56
57
  .relative(program.getCommonSourceDirectory(), asset.filePath)
57
58
  .slice(0, -path.extname(asset.filePath).length),
58
59
  );
@@ -61,11 +62,11 @@ export default new Transformer({
61
62
  let emitResult = program.emit(undefined, undefined, undefined, true, {
62
63
  afterDeclarations: [
63
64
  // 1. Build module graph
64
- (context: any) => (sourceFile: any) => {
65
+ (context) => (sourceFile) => {
65
66
  return collect(moduleGraph, context, sourceFile);
66
67
  },
67
68
  // 2. Tree shake and rename types
68
- (context: any) => (sourceFile: any) => {
69
+ (context) => (sourceFile) => {
69
70
  return shake(moduleGraph, context, sourceFile);
70
71
  },
71
72
  ],
@@ -76,8 +77,7 @@ export default new Transformer({
76
77
  .concat(emitResult.diagnostics);
77
78
 
78
79
  let diagnosticIds = new Set();
79
- // @ts-expect-error TS2304
80
- let deduplicatedDiagnostics: Array<Diagnostic> = [];
80
+ let deduplicatedDiagnostics = [];
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,13 +102,14 @@ export default new Transformer({
102
102
  '\n',
103
103
  );
104
104
 
105
- let codeframe: DiagnosticCodeFrame | null | undefined;
105
+ let codeframe: ?DiagnosticCodeFrame;
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
112
113
  if (source) {
113
114
  let lineChar = file.getLineAndCharacterOfPosition(diagnostic.start);
114
115
  let start = {
@@ -166,7 +167,6 @@ export default new Transformer({
166
167
  code = code.substring(0, code.lastIndexOf('//# sourceMappingURL'));
167
168
 
168
169
  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
- }) as Transformer<unknown>;
185
+ }): Transformer<mixed>);