knip 5.73.4 → 5.74.0

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.
Files changed (58) hide show
  1. package/dist/ConfigurationChief.d.ts +6 -0
  2. package/dist/ProjectPrincipal.d.ts +0 -1
  3. package/dist/ProjectPrincipal.js +18 -13
  4. package/dist/compilers/index.d.ts +10 -0
  5. package/dist/compilers/scss.js +1 -1
  6. package/dist/constants.d.ts +6 -1
  7. package/dist/constants.js +6 -1
  8. package/dist/graph/build.js +18 -9
  9. package/dist/graph-explorer/visitors.js +3 -3
  10. package/dist/plugins/index.d.ts +1 -0
  11. package/dist/plugins/index.js +2 -0
  12. package/dist/plugins/swc/index.d.ts +3 -0
  13. package/dist/plugins/swc/index.js +18 -0
  14. package/dist/plugins/swc/types.d.ts +7 -0
  15. package/dist/plugins/swc/types.js +1 -0
  16. package/dist/schema/configuration.d.ts +10 -0
  17. package/dist/schema/plugins.d.ts +5 -0
  18. package/dist/schema/plugins.js +1 -0
  19. package/dist/types/PluginNames.d.ts +2 -2
  20. package/dist/types/PluginNames.js +1 -0
  21. package/dist/types/exports.d.ts +14 -13
  22. package/dist/types/imports.d.ts +7 -7
  23. package/dist/types/module-graph.d.ts +27 -26
  24. package/dist/typescript/ast-helpers.d.ts +5 -3
  25. package/dist/typescript/ast-helpers.js +4 -2
  26. package/dist/typescript/create-hosts.d.ts +1 -2
  27. package/dist/typescript/create-hosts.js +2 -2
  28. package/dist/typescript/get-imports-and-exports.js +18 -15
  29. package/dist/typescript/pragmas/custom.js +11 -3
  30. package/dist/typescript/pragmas/typescript.js +20 -4
  31. package/dist/typescript/resolve-module-names.d.ts +1 -1
  32. package/dist/typescript/resolve-module-names.js +5 -9
  33. package/dist/typescript/visitors/dynamic-imports/importCall.js +100 -14
  34. package/dist/typescript/visitors/dynamic-imports/importType.js +5 -2
  35. package/dist/typescript/visitors/dynamic-imports/jsDocType.js +13 -4
  36. package/dist/typescript/visitors/dynamic-imports/requireCall.js +52 -8
  37. package/dist/typescript/visitors/dynamic-imports/resolveCall.js +5 -2
  38. package/dist/typescript/visitors/dynamic-imports/urlConstructor.js +5 -2
  39. package/dist/typescript/visitors/exports/exportAssignment.js +7 -9
  40. package/dist/typescript/visitors/exports/exportDeclaration.js +2 -2
  41. package/dist/typescript/visitors/exports/exportKeyword.js +49 -10
  42. package/dist/typescript/visitors/exports/exportsAccessExpression.js +4 -1
  43. package/dist/typescript/visitors/exports/moduleExportsAccessExpression.js +27 -3
  44. package/dist/typescript/visitors/imports/importDeclaration.js +19 -3
  45. package/dist/typescript/visitors/imports/importEqualsDeclaration.js +3 -2
  46. package/dist/typescript/visitors/imports/reExportDeclaration.js +15 -5
  47. package/dist/util/create-options.d.ts +10 -0
  48. package/dist/util/get-referenced-inputs.js +3 -3
  49. package/dist/util/module-graph.d.ts +0 -1
  50. package/dist/util/module-graph.js +3 -2
  51. package/dist/util/modules.js +7 -1
  52. package/dist/util/resolve.js +3 -3
  53. package/dist/util/to-source-path.d.ts +2 -2
  54. package/dist/util/to-source-path.js +1 -1
  55. package/dist/version.d.ts +1 -1
  56. package/dist/version.js +1 -1
  57. package/package.json +1 -1
  58. package/schema.json +4 -0
@@ -1,6 +1,6 @@
1
1
  import { isBuiltin } from 'node:module';
2
2
  import ts from 'typescript';
3
- import { ALIAS_TAG, IMPORT_MODIFIERS, IMPORT_STAR, OPAQUE, PROTOCOL_VIRTUAL, SIDE_EFFECTS } from '../constants.js';
3
+ import { ALIAS_TAG, IMPORT_FLAGS, IMPORT_STAR, OPAQUE, PROTOCOL_VIRTUAL, SIDE_EFFECTS } from '../constants.js';
4
4
  import { addNsValue, addValue, createImports } from '../util/module-graph.js';
5
5
  import { getPackageNameFromFilePath, isStartsLikePackageName, sanitizeSpecifier } from '../util/modules.js';
6
6
  import { timerify } from '../util/Performance.js';
@@ -31,6 +31,7 @@ const createMember = (node, member, pos) => {
31
31
  fix: member.fix,
32
32
  self: [0, false],
33
33
  jsDocTags: getJSDocTags(member.node),
34
+ flags: member.flags,
34
35
  };
35
36
  };
36
37
  const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, ignoreExportsUsedInFile, skipExports) => {
@@ -83,7 +84,7 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, i
83
84
  };
84
85
  const addInternalImport = (options) => {
85
86
  const { symbol, filePath, namespace, specifier, modifiers } = options;
86
- const identifier = options.identifier ?? (modifiers & IMPORT_MODIFIERS.OPAQUE ? OPAQUE : SIDE_EFFECTS);
87
+ const identifier = options.identifier ?? (modifiers & IMPORT_FLAGS.OPAQUE ? OPAQUE : SIDE_EFFECTS);
87
88
  const isStar = identifier === IMPORT_STAR;
88
89
  imports.add({
89
90
  filePath,
@@ -92,14 +93,14 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, i
92
93
  pos: options.pos,
93
94
  line: options.line,
94
95
  col: options.col,
95
- isTypeOnly: !!(modifiers & IMPORT_MODIFIERS.TYPE_ONLY),
96
+ isTypeOnly: !!(modifiers & IMPORT_FLAGS.TYPE_ONLY),
96
97
  });
97
98
  const file = internal.get(filePath);
98
99
  const importMaps = file ?? createImports();
99
100
  if (!file)
100
101
  internal.set(filePath, importMaps);
101
102
  const nsOrAlias = symbol ? String(symbol.escapedName) : options.alias;
102
- if (modifiers & IMPORT_MODIFIERS.RE_EXPORT) {
103
+ if (modifiers & IMPORT_FLAGS.RE_EXPORT) {
103
104
  if (isStar && namespace) {
104
105
  addValue(importMaps.reExportedNs, namespace, sourceFile.fileName);
105
106
  }
@@ -134,9 +135,9 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, i
134
135
  const filePath = module.resolvedFileName;
135
136
  if (filePath) {
136
137
  if (!isInNodeModules(filePath)) {
137
- if (opts.modifiers & IMPORT_MODIFIERS.ENTRY)
138
+ if (opts.modifiers & IMPORT_FLAGS.ENTRY)
138
139
  entryFiles.add(filePath);
139
- if (opts.modifiers & IMPORT_MODIFIERS.BRIDGE)
140
+ if (opts.modifiers & IMPORT_FLAGS.BRIDGE)
140
141
  programFiles.add(filePath);
141
142
  }
142
143
  if (!module.isExternalLibraryImport || !isInNodeModules(filePath)) {
@@ -149,7 +150,7 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, i
149
150
  });
150
151
  }
151
152
  if (module.isExternalLibraryImport) {
152
- if (options.skipTypeOnly && opts.modifiers & IMPORT_MODIFIERS.TYPE_ONLY)
153
+ if (options.skipTypeOnly && opts.modifiers & IMPORT_FLAGS.TYPE_ONLY)
153
154
  return;
154
155
  const sanitizedSpecifier = sanitizeSpecifier(isInNodeModules(filePath) || isInNodeModules(opts.specifier)
155
156
  ? getPackageNameFromFilePath(opts.specifier)
@@ -166,19 +167,19 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, i
166
167
  pos: opts.pos,
167
168
  line: line + 1,
168
169
  col: character + 2,
169
- isTypeOnly: !!(opts.modifiers & IMPORT_MODIFIERS.TYPE_ONLY),
170
+ isTypeOnly: !!(opts.modifiers & IMPORT_FLAGS.TYPE_ONLY),
170
171
  });
171
172
  }
172
173
  }
173
174
  }
174
175
  else {
175
- if (options.skipTypeOnly && opts.modifiers & IMPORT_MODIFIERS.TYPE_ONLY)
176
+ if (options.skipTypeOnly && opts.modifiers & IMPORT_FLAGS.TYPE_ONLY)
176
177
  return;
177
178
  if (shouldIgnore(getJSDocTags(node), options.tags))
178
179
  return;
179
180
  if (opts.specifier.startsWith(PROTOCOL_VIRTUAL))
180
181
  return;
181
- if (opts.modifiers && opts.modifiers & IMPORT_MODIFIERS.OPTIONAL) {
182
+ if (opts.modifiers && opts.modifiers & IMPORT_FLAGS.OPTIONAL) {
182
183
  programFiles.add(resolve(dirname(sourceFile.fileName), opts.specifier));
183
184
  return;
184
185
  }
@@ -191,11 +192,11 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, i
191
192
  pos,
192
193
  line: line + 1,
193
194
  col: character + 2,
194
- isTypeOnly: !!(opts.modifiers & IMPORT_MODIFIERS.TYPE_ONLY),
195
+ isTypeOnly: !!(opts.modifiers & IMPORT_FLAGS.TYPE_ONLY),
195
196
  });
196
197
  }
197
198
  };
198
- const addExport = ({ node, symbol, identifier, type, pos, members = [], fix }) => {
199
+ const addExport = ({ node, symbol, identifier, type, pos, members, fix }) => {
199
200
  if (skipExports)
200
201
  return;
201
202
  let isReExport = Boolean(node.parent?.parent && ts.isExportDeclaration(node.parent.parent) && node.parent.parent.moduleSpecifier);
@@ -222,9 +223,9 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, i
222
223
  const exportMembers = members.map(member => createMember(node, member, member.pos));
223
224
  const item = exports.get(identifier);
224
225
  if (item) {
225
- const members = [...(item.members ?? []), ...exportMembers];
226
- const tags = new Set([...(item.jsDocTags ?? []), ...jsDocTags]);
227
- const fixes = fix ? [...(item.fixes ?? []), fix] : item.fixes;
226
+ const members = [...item.members, ...exportMembers];
227
+ const tags = new Set([...item.jsDocTags, ...jsDocTags]);
228
+ const fixes = fix ? [...item.fixes, fix] : item.fixes;
228
229
  exports.set(identifier, { ...item, members, jsDocTags: tags, fixes, isReExport });
229
230
  }
230
231
  else {
@@ -448,6 +449,8 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, i
448
449
  exports,
449
450
  duplicates: [...aliasedExports.values()],
450
451
  scripts,
452
+ imported: undefined,
453
+ internalImportCache: undefined,
451
454
  };
452
455
  };
453
456
  export const _getImportsAndExports = timerify(getImportsAndExports);
@@ -1,4 +1,4 @@
1
- import { IMPORT_MODIFIERS } from '../../constants.js';
1
+ import { IMPORT_FLAGS } from '../../constants.js';
2
2
  import { getEnvSpecifier } from '../../plugins/vitest/helpers.js';
3
3
  import { isAbsolute, isInternal } from '../../util/path.js';
4
4
  import { getLeadingComments, stripQuotes } from '../ast-helpers.js';
@@ -15,10 +15,18 @@ export const collectCustomImports = (sourceFile) => {
15
15
  if (!id)
16
16
  continue;
17
17
  const isLocal = isInternal(id) || isAbsolute(id);
18
- const modifiers = isLocal ? IMPORT_MODIFIERS.ENTRY : IMPORT_MODIFIERS.NONE;
18
+ const modifiers = isLocal ? IMPORT_FLAGS.ENTRY : IMPORT_FLAGS.NONE;
19
19
  const offset = match[0].length - match[2].length;
20
20
  const specifier = isLocal || id === 'node' ? id : getEnvSpecifier(id);
21
- importNodes.push({ specifier, identifier: undefined, pos: comment.pos + match.index + offset, modifiers });
21
+ importNodes.push({
22
+ specifier,
23
+ identifier: undefined,
24
+ pos: comment.pos + match.index + offset,
25
+ modifiers,
26
+ alias: undefined,
27
+ namespace: undefined,
28
+ symbol: undefined,
29
+ });
22
30
  }
23
31
  }
24
32
  return importNodes;
@@ -1,9 +1,9 @@
1
- import { IMPORT_MODIFIERS } from '../../constants.js';
1
+ import { IMPORT_FLAGS } from '../../constants.js';
2
2
  export const collectTypeScriptPragmaImports = (sourceFile) => {
3
3
  if (!sourceFile.pragmas || sourceFile.pragmas.size === 0)
4
4
  return [];
5
5
  const importNodes = [];
6
- const modifiers = IMPORT_MODIFIERS.TYPE_ONLY;
6
+ const modifiers = IMPORT_FLAGS.TYPE_ONLY;
7
7
  const jsxImportSourcePragmas = sourceFile.pragmas.get('jsximportsource');
8
8
  if (jsxImportSourcePragmas) {
9
9
  const jsxImportSourcePragma = Array.isArray(jsxImportSourcePragmas)
@@ -12,7 +12,15 @@ export const collectTypeScriptPragmaImports = (sourceFile) => {
12
12
  const { factory: specifier } = jsxImportSourcePragma?.arguments ?? {};
13
13
  const pos = jsxImportSourcePragma.range?.pos ?? 0;
14
14
  if (specifier)
15
- importNodes.push({ specifier, identifier: undefined, pos, modifiers });
15
+ importNodes.push({
16
+ specifier,
17
+ identifier: undefined,
18
+ pos,
19
+ modifiers,
20
+ alias: undefined,
21
+ namespace: undefined,
22
+ symbol: undefined,
23
+ });
16
24
  }
17
25
  const referencePragma = sourceFile.pragmas.get('reference');
18
26
  if (referencePragma) {
@@ -21,7 +29,15 @@ export const collectTypeScriptPragmaImports = (sourceFile) => {
21
29
  if (ref.arguments?.types) {
22
30
  const { value: specifier, pos } = ref.arguments.types;
23
31
  if (specifier)
24
- importNodes.push({ specifier, identifier: undefined, pos, modifiers });
32
+ importNodes.push({
33
+ specifier,
34
+ identifier: undefined,
35
+ pos,
36
+ modifiers,
37
+ alias: undefined,
38
+ namespace: undefined,
39
+ symbol: undefined,
40
+ });
25
41
  }
26
42
  }
27
43
  }
@@ -1,4 +1,4 @@
1
1
  import ts from 'typescript';
2
2
  import type { ToSourceFilePath } from '../util/to-source-path.js';
3
3
  export type ResolveModuleNames = ReturnType<typeof createCustomModuleResolver>;
4
- export declare function createCustomModuleResolver(compilerOptions: ts.CompilerOptions, customCompilerExtensions: string[], toSourceFilePath: ToSourceFilePath, useCache?: boolean, isSkipLibs?: boolean): (moduleNames: string[], containingFile: string) => Array<ts.ResolvedModuleFull | undefined>;
4
+ export declare function createCustomModuleResolver(compilerOptions: ts.CompilerOptions, customCompilerExtensions: string[], toSourceFilePath: ToSourceFilePath, useCache?: boolean): (moduleNames: string[], containingFile: string) => Array<ts.ResolvedModuleFull | undefined>;
@@ -8,7 +8,7 @@ import { dirname, extname, isAbsolute, isInNodeModules, join } from '../util/pat
8
8
  import { _createSyncModuleResolver, _resolveModuleSync } from '../util/resolve.js';
9
9
  import { isDeclarationFileExtension } from './ast-helpers.js';
10
10
  const resolutionCache = new Map();
11
- const fileExists = (name, containingFile) => {
11
+ const moduleIfFileExists = (name, containingFile) => {
12
12
  const resolvedFileName = isAbsolute(name) ? name : join(dirname(containingFile), name);
13
13
  if (existsSync(resolvedFileName)) {
14
14
  return {
@@ -20,7 +20,7 @@ const fileExists = (name, containingFile) => {
20
20
  }
21
21
  };
22
22
  const tsResolveModuleName = timerify(ts.resolveModuleName);
23
- export function createCustomModuleResolver(compilerOptions, customCompilerExtensions, toSourceFilePath, useCache = true, isSkipLibs = true) {
23
+ export function createCustomModuleResolver(compilerOptions, customCompilerExtensions, toSourceFilePath, useCache = true) {
24
24
  const customCompilerExtensionsSet = new Set(customCompilerExtensions);
25
25
  const extensions = [...DEFAULT_EXTENSIONS, ...customCompilerExtensions];
26
26
  const resolveSync = customCompilerExtensionsSet.size === 0 ? _resolveModuleSync : _createSyncModuleResolver(extensions);
@@ -28,9 +28,8 @@ export function createCustomModuleResolver(compilerOptions, customCompilerExtens
28
28
  const tsSys = {
29
29
  ...ts.sys,
30
30
  fileExists(path) {
31
- if (ts.sys.fileExists(path)) {
31
+ if (ts.sys.fileExists(path))
32
32
  return true;
33
- }
34
33
  const original = originalFromDeclarationPath(path);
35
34
  if (original && ts.sys.fileExists(original.path)) {
36
35
  virtualDeclarationFiles.set(path, original);
@@ -58,7 +57,7 @@ export function createCustomModuleResolver(compilerOptions, customCompilerExtens
58
57
  const sanitizedSpecifier = sanitizeSpecifier(name);
59
58
  if (isBuiltin(sanitizedSpecifier))
60
59
  return undefined;
61
- const resolvedFileName = isSkipLibs && resolveSync(sanitizedSpecifier, containingFile);
60
+ const resolvedFileName = resolveSync(sanitizedSpecifier, containingFile);
62
61
  if (resolvedFileName) {
63
62
  const ext = extname(resolvedFileName);
64
63
  if (!customCompilerExtensionsSet.has(ext)) {
@@ -102,10 +101,7 @@ export function createCustomModuleResolver(compilerOptions, customCompilerExtens
102
101
  }
103
102
  return tsResolvedModule;
104
103
  }
105
- const module = fileExists(sanitizedSpecifier, containingFile);
106
- if (module)
107
- return module;
108
- return undefined;
104
+ return moduleIfFileExists(sanitizedSpecifier, containingFile);
109
105
  }
110
106
  return timerify(resolveModuleNames);
111
107
  }
@@ -1,5 +1,5 @@
1
1
  import ts from 'typescript';
2
- import { IMPORT_MODIFIERS } from '../../../constants.js';
2
+ import { IMPORT_FLAGS } from '../../../constants.js';
3
3
  import { findAncestor, findDescendants, getAccessedIdentifiers, getThenBindings, isAccessExpression, isImportCall, isInOpaqueExpression, isTopLevel, stripQuotes, } from '../../ast-helpers.js';
4
4
  import { importVisitor as visit } from '../index.js';
5
5
  const getSymbol = (node, isTopLevel) => (isTopLevel ? node.symbol : undefined);
@@ -7,7 +7,7 @@ export default visit(() => true, node => {
7
7
  if (isImportCall(node)) {
8
8
  if (node.arguments[0] && ts.isStringLiteralLike(node.arguments[0])) {
9
9
  const specifier = node.arguments[0].text;
10
- const modifiers = IMPORT_MODIFIERS.NONE;
10
+ const modifiers = IMPORT_FLAGS.NONE;
11
11
  if (specifier) {
12
12
  const accessExpression = findAncestor(node, _node => {
13
13
  if (ts.isExpressionStatement(_node) || ts.isCallExpression(_node))
@@ -23,20 +23,51 @@ export default visit(() => true, node => {
23
23
  if (ts.isCallExpression(callExpression)) {
24
24
  const accessed = getThenBindings(callExpression);
25
25
  if (accessed && accessed.length > 0) {
26
- return accessed.map(acc => ({ ...acc, specifier, modifiers }));
26
+ return accessed.map(acc => ({
27
+ ...acc,
28
+ specifier,
29
+ modifiers,
30
+ alias: undefined,
31
+ namespace: undefined,
32
+ symbol: undefined,
33
+ }));
27
34
  }
28
35
  }
29
- return { identifier: 'default', specifier, pos, modifiers };
36
+ return {
37
+ identifier: 'default',
38
+ specifier,
39
+ pos,
40
+ modifiers,
41
+ alias: undefined,
42
+ namespace: undefined,
43
+ symbol: undefined,
44
+ };
30
45
  }
31
46
  if (identifier !== 'catch')
32
- return { identifier, specifier, pos, modifiers };
47
+ return {
48
+ identifier,
49
+ specifier,
50
+ pos,
51
+ modifiers,
52
+ alias: undefined,
53
+ namespace: undefined,
54
+ symbol: undefined,
55
+ };
33
56
  }
34
57
  if (ts.isElementAccessExpression(accessExpression) &&
35
58
  ts.isStringLiteral(accessExpression.argumentExpression)) {
36
59
  const name = stripQuotes(accessExpression.argumentExpression.text);
37
60
  const pos = accessExpression.argumentExpression.pos;
38
61
  const identifier = name;
39
- return { identifier, specifier, pos, modifiers };
62
+ return {
63
+ identifier,
64
+ specifier,
65
+ pos,
66
+ modifiers,
67
+ alias: undefined,
68
+ namespace: undefined,
69
+ symbol: undefined,
70
+ };
40
71
  }
41
72
  }
42
73
  const variableDeclaration = accessExpression &&
@@ -63,9 +94,18 @@ export default visit(() => true, node => {
63
94
  specifier,
64
95
  pos: acc.pos,
65
96
  modifiers,
97
+ namespace: undefined,
66
98
  }));
67
99
  }
68
- return { identifier: 'default', alias, symbol, specifier, pos: node.arguments[0].pos, modifiers };
100
+ return {
101
+ identifier: 'default',
102
+ alias,
103
+ symbol,
104
+ specifier,
105
+ pos: node.arguments[0].pos,
106
+ modifiers,
107
+ namespace: undefined,
108
+ };
69
109
  }
70
110
  const bindings = findDescendants(variableDeclaration, ts.isBindingElement);
71
111
  if (bindings.length > 0) {
@@ -73,14 +113,25 @@ export default visit(() => true, node => {
73
113
  const identifier = (element.propertyName ?? element.name).getText();
74
114
  const alias = element.propertyName ? element.name.getText() : undefined;
75
115
  const symbol = getSymbol(element, isTLA);
76
- return { identifier, alias, symbol, specifier, pos: element.name.getStart(), modifiers };
116
+ return {
117
+ identifier,
118
+ alias,
119
+ symbol,
120
+ specifier,
121
+ pos: element.name.getStart(),
122
+ modifiers,
123
+ namespace: undefined,
124
+ };
77
125
  });
78
126
  }
79
127
  return {
80
128
  identifier: undefined,
81
129
  specifier,
82
130
  pos: node.arguments[0].pos,
83
- modifiers: IMPORT_MODIFIERS.SIDE_EFFECTS,
131
+ modifiers: IMPORT_FLAGS.SIDE_EFFECTS,
132
+ alias: undefined,
133
+ namespace: undefined,
134
+ symbol: undefined,
84
135
  };
85
136
  }
86
137
  const arrayLiteralExpression = node.parent;
@@ -99,25 +150,60 @@ export default visit(() => true, node => {
99
150
  const identifier = (element.propertyName ?? element.name).getText();
100
151
  const alias = element.propertyName ? element.name.getText() : undefined;
101
152
  const symbol = getSymbol(element, isTL);
102
- return { identifier, alias, symbol, specifier, pos: element.getStart(), modifiers };
153
+ return {
154
+ identifier,
155
+ alias,
156
+ symbol,
157
+ specifier,
158
+ pos: element.getStart(),
159
+ modifiers,
160
+ namespace: undefined,
161
+ };
103
162
  });
104
163
  }
105
164
  if (!ts.isOmittedExpression(element) && ts.isIdentifier(element.name)) {
106
165
  const alias = String(element.name.escapedText);
107
166
  const symbol = getSymbol(element, isTL);
108
- return { identifier: 'default', symbol, alias, specifier, pos: element.getStart(), modifiers };
167
+ return {
168
+ identifier: 'default',
169
+ symbol,
170
+ alias,
171
+ specifier,
172
+ pos: element.getStart(),
173
+ modifiers,
174
+ namespace: undefined,
175
+ };
109
176
  }
110
- return { identifier: 'default', specifier, pos: element.getStart(), modifiers };
177
+ return {
178
+ identifier: 'default',
179
+ specifier,
180
+ pos: element.getStart(),
181
+ modifiers,
182
+ alias: undefined,
183
+ namespace: undefined,
184
+ symbol: undefined,
185
+ };
111
186
  }
112
187
  }
113
188
  return {
114
189
  identifier: undefined,
115
190
  specifier,
116
191
  pos: node.arguments[0].pos,
117
- modifiers: isInOpaqueExpression(node) ? IMPORT_MODIFIERS.OPAQUE : IMPORT_MODIFIERS.SIDE_EFFECTS,
192
+ modifiers: isInOpaqueExpression(node) ? IMPORT_FLAGS.OPAQUE : IMPORT_FLAGS.SIDE_EFFECTS,
193
+ alias: undefined,
194
+ namespace: undefined,
195
+ symbol: undefined,
118
196
  };
119
197
  }
120
- return { specifier, identifier: 'default', pos: node.arguments[0].pos, modifiers };
198
+ return {
199
+ specifier,
200
+ identifier: 'default',
201
+ pos: node.arguments[0].pos,
202
+ modifiers,
203
+ alias: undefined,
204
+ namespace: undefined,
205
+ symbol: undefined,
206
+ };
121
207
  }
122
208
  }
123
209
  });
@@ -1,5 +1,5 @@
1
1
  import ts from 'typescript';
2
- import { IMPORT_MODIFIERS } from '../../../constants.js';
2
+ import { IMPORT_FLAGS } from '../../../constants.js';
3
3
  import { importVisitor as visit } from '../index.js';
4
4
  export default visit(() => true, node => {
5
5
  if (ts.isImportTypeNode(node)) {
@@ -8,7 +8,10 @@ export default visit(() => true, node => {
8
8
  specifier: node.argument.literal.text,
9
9
  identifier: undefined,
10
10
  pos: node.argument.literal.getStart(),
11
- modifiers: IMPORT_MODIFIERS.TYPE_ONLY,
11
+ modifiers: IMPORT_FLAGS.TYPE_ONLY,
12
+ alias: undefined,
13
+ namespace: undefined,
14
+ symbol: undefined,
12
15
  };
13
16
  }
14
17
  }
@@ -1,5 +1,5 @@
1
1
  import ts from 'typescript';
2
- import { IMPORT_MODIFIERS, IMPORT_STAR } from '../../../constants.js';
2
+ import { IMPORT_FLAGS, IMPORT_STAR } from '../../../constants.js';
3
3
  import { importVisitor as visit } from '../index.js';
4
4
  const supportsJSDocImportTag = 'isJSDocImportTag' in ts;
5
5
  const getImportSpecifiers = (node) => {
@@ -13,7 +13,10 @@ const getImportSpecifiers = (node) => {
13
13
  specifier: importClause.literal.text,
14
14
  identifier,
15
15
  pos: node.qualifier?.getStart() ?? importClause.literal.pos,
16
- modifiers: IMPORT_MODIFIERS.TYPE_ONLY,
16
+ modifiers: IMPORT_FLAGS.TYPE_ONLY,
17
+ alias: undefined,
18
+ namespace: undefined,
19
+ symbol: undefined,
17
20
  });
18
21
  }
19
22
  }
@@ -27,7 +30,10 @@ const getImportSpecifiers = (node) => {
27
30
  specifier: moduleSpecifier.text,
28
31
  identifier: IMPORT_STAR,
29
32
  pos: bindings.name.getStart(),
30
- modifiers: IMPORT_MODIFIERS.TYPE_ONLY,
33
+ modifiers: IMPORT_FLAGS.TYPE_ONLY,
34
+ alias: undefined,
35
+ namespace: undefined,
36
+ symbol: undefined,
31
37
  });
32
38
  }
33
39
  else {
@@ -36,7 +42,10 @@ const getImportSpecifiers = (node) => {
36
42
  specifier: moduleSpecifier.text,
37
43
  identifier: String((element.propertyName ?? element.name).escapedText),
38
44
  pos: element.name.getStart(),
39
- modifiers: IMPORT_MODIFIERS.TYPE_ONLY,
45
+ modifiers: IMPORT_FLAGS.TYPE_ONLY,
46
+ alias: undefined,
47
+ namespace: undefined,
48
+ symbol: undefined,
40
49
  });
41
50
  }
42
51
  }
@@ -1,5 +1,5 @@
1
1
  import ts from 'typescript';
2
- import { IMPORT_MODIFIERS, IMPORT_STAR } from '../../../constants.js';
2
+ import { IMPORT_FLAGS, IMPORT_STAR } from '../../../constants.js';
3
3
  import { findAncestor, findDescendants, isModuleExportsAccess, isRequireCall, isTopLevel } from '../../ast-helpers.js';
4
4
  import { isNotJS } from '../helpers.js';
5
5
  import { importVisitor as visit } from '../index.js';
@@ -7,7 +7,7 @@ export default visit(() => true, node => {
7
7
  if (isRequireCall(node)) {
8
8
  if (ts.isStringLiteralLike(node.arguments[0])) {
9
9
  const specifier = node.arguments[0].text;
10
- const modifiers = isNotJS(node.getSourceFile()) ? IMPORT_MODIFIERS.BRIDGE : IMPORT_MODIFIERS.NONE;
10
+ const modifiers = isNotJS(node.getSourceFile()) ? IMPORT_FLAGS.BRIDGE : IMPORT_FLAGS.NONE;
11
11
  if (specifier) {
12
12
  const propertyAccessExpression = findAncestor(node, _node => {
13
13
  if (ts.isExpressionStatement(_node) || ts.isCallExpression(_node))
@@ -16,7 +16,15 @@ export default visit(() => true, node => {
16
16
  });
17
17
  if (propertyAccessExpression) {
18
18
  const identifier = String(propertyAccessExpression.name.escapedText);
19
- return { identifier, specifier, pos: propertyAccessExpression.name.getStart(), modifiers };
19
+ return {
20
+ identifier,
21
+ specifier,
22
+ pos: propertyAccessExpression.name.getStart(),
23
+ modifiers,
24
+ alias: undefined,
25
+ namespace: undefined,
26
+ symbol: undefined,
27
+ };
20
28
  }
21
29
  const variableDeclaration = node.parent;
22
30
  if (ts.isVariableDeclaration(variableDeclaration) &&
@@ -30,6 +38,7 @@ export default visit(() => true, node => {
30
38
  symbol: isTLA ? variableDeclaration.symbol : undefined,
31
39
  specifier,
32
40
  pos: variableDeclaration.name.getStart(),
41
+ namespace: undefined,
33
42
  modifiers,
34
43
  };
35
44
  }
@@ -39,10 +48,26 @@ export default visit(() => true, node => {
39
48
  const identifier = (element.propertyName ?? element.name).getText();
40
49
  const alias = element.propertyName ? element.name.getText() : undefined;
41
50
  const symbol = isTLA ? element.symbol : undefined;
42
- return { identifier, specifier, alias, symbol, pos: element.name.getStart(), modifiers };
51
+ return {
52
+ identifier,
53
+ specifier,
54
+ alias,
55
+ symbol,
56
+ pos: element.name.getStart(),
57
+ modifiers,
58
+ namespace: undefined,
59
+ };
43
60
  });
44
61
  }
45
- return { identifier: 'default', specifier, pos: node.arguments[0].pos, modifiers };
62
+ return {
63
+ identifier: 'default',
64
+ specifier,
65
+ pos: node.arguments[0].pos,
66
+ modifiers,
67
+ alias: undefined,
68
+ namespace: undefined,
69
+ symbol: undefined,
70
+ };
46
71
  }
47
72
  if (ts.isBinaryExpression(node.parent) &&
48
73
  ts.isPropertyAccessExpression(node.parent.left) &&
@@ -51,13 +76,32 @@ export default visit(() => true, node => {
51
76
  identifier: IMPORT_STAR,
52
77
  specifier,
53
78
  pos: node.arguments[0].pos,
54
- modifiers: IMPORT_MODIFIERS.RE_EXPORT,
79
+ modifiers: IMPORT_FLAGS.RE_EXPORT,
80
+ alias: undefined,
81
+ namespace: undefined,
82
+ symbol: undefined,
55
83
  };
56
84
  }
57
85
  if (ts.isCallExpression(node.parent)) {
58
- return { identifier: 'default', specifier, pos: node.getEnd(), modifiers };
86
+ return {
87
+ identifier: 'default',
88
+ specifier,
89
+ pos: node.getEnd(),
90
+ modifiers,
91
+ alias: undefined,
92
+ namespace: undefined,
93
+ symbol: undefined,
94
+ };
59
95
  }
60
- return { identifier: 'default', specifier, pos: node.getStart(), modifiers };
96
+ return {
97
+ identifier: 'default',
98
+ specifier,
99
+ pos: node.getStart(),
100
+ modifiers,
101
+ alias: undefined,
102
+ namespace: undefined,
103
+ symbol: undefined,
104
+ };
61
105
  }
62
106
  }
63
107
  }
@@ -1,5 +1,5 @@
1
1
  import ts from 'typescript';
2
- import { IMPORT_MODIFIERS } from '../../../constants.js';
2
+ import { IMPORT_FLAGS } from '../../../constants.js';
3
3
  import { isPropertyAccessCall } from '../../ast-helpers.js';
4
4
  import { importVisitor as visit } from '../index.js';
5
5
  export default visit(() => true, node => {
@@ -11,7 +11,10 @@ export default visit(() => true, node => {
11
11
  specifier,
12
12
  identifier: undefined,
13
13
  pos: node.arguments[0].pos,
14
- modifiers: IMPORT_MODIFIERS.ENTRY,
14
+ modifiers: IMPORT_FLAGS.ENTRY,
15
+ alias: undefined,
16
+ namespace: undefined,
17
+ symbol: undefined,
15
18
  };
16
19
  }
17
20
  }
@@ -1,5 +1,5 @@
1
1
  import ts from 'typescript';
2
- import { IMPORT_MODIFIERS } from '../../../constants.js';
2
+ import { IMPORT_FLAGS } from '../../../constants.js';
3
3
  import { importVisitor as visit } from '../index.js';
4
4
  export default visit(() => true, node => {
5
5
  if (ts.isNewExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === 'URL') {
@@ -17,7 +17,10 @@ export default visit(() => true, node => {
17
17
  specifier,
18
18
  identifier: undefined,
19
19
  pos: node.arguments[0].pos,
20
- modifiers: IMPORT_MODIFIERS.ENTRY | IMPORT_MODIFIERS.OPTIONAL,
20
+ modifiers: IMPORT_FLAGS.ENTRY | IMPORT_FLAGS.OPTIONAL,
21
+ alias: undefined,
22
+ namespace: undefined,
23
+ symbol: undefined,
21
24
  };
22
25
  }
23
26
  }