knip 2.41.6 → 2.42.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.
- package/dist/ProjectPrincipal.d.ts +2 -1
- package/dist/ProjectPrincipal.js +7 -1
- package/dist/typescript/SourceFile.d.ts +4 -0
- package/dist/typescript/getImportsAndExports.d.ts +2 -2
- package/dist/typescript/getImportsAndExports.js +2 -2
- package/dist/util/parseArgs.d.ts +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ import { SourceFileManager } from './typescript/SourceFileManager.js';
|
|
|
4
4
|
import type { PrincipalOptions } from './PrincipalFactory.js';
|
|
5
5
|
import type { SyncCompilers, AsyncCompilers } from './types/compilers.js';
|
|
6
6
|
import type { ExportItem, ExportItemMember } from './types/exports.js';
|
|
7
|
+
import type { ProgramMaybe53 } from './typescript/SourceFile.js';
|
|
7
8
|
import type { GlobbyFilterFunction } from 'globby';
|
|
8
9
|
export declare class ProjectPrincipal {
|
|
9
10
|
entryPaths: Set<string>;
|
|
@@ -20,7 +21,7 @@ export declare class ProjectPrincipal {
|
|
|
20
21
|
compilerHost: ts.CompilerHost;
|
|
21
22
|
resolveModuleNames: ReturnType<typeof createCustomModuleResolver>;
|
|
22
23
|
lsFindReferences: ts.LanguageService['findReferences'];
|
|
23
|
-
program?:
|
|
24
|
+
program?: ProgramMaybe53;
|
|
24
25
|
};
|
|
25
26
|
constructor({ compilerOptions, cwd, compilers, isGitIgnored }: PrincipalOptions);
|
|
26
27
|
private createProgram;
|
package/dist/ProjectPrincipal.js
CHANGED
|
@@ -111,7 +111,13 @@ export class ProjectPrincipal {
|
|
|
111
111
|
if (!sourceFile)
|
|
112
112
|
throw new Error(`Unable to find ${filePath}`);
|
|
113
113
|
const skipExports = this.skipExportsAnalysis.has(filePath);
|
|
114
|
-
const
|
|
114
|
+
const getResolvedModule = specifier => this.backend.program?.getResolvedModule
|
|
115
|
+
? this.backend.program.getResolvedModule(sourceFile, specifier, undefined)
|
|
116
|
+
: sourceFile.resolvedModules?.get(specifier, undefined);
|
|
117
|
+
const { imports, exports, scripts } = getImportsAndExports(sourceFile, getResolvedModule, {
|
|
118
|
+
skipTypeOnly,
|
|
119
|
+
skipExports,
|
|
120
|
+
});
|
|
115
121
|
const { internal, unresolved, external } = imports;
|
|
116
122
|
const unresolvedImports = new Set();
|
|
117
123
|
unresolved.forEach(specifier => {
|
|
@@ -15,4 +15,8 @@ export interface BoundSourceFile extends ts.SourceFile {
|
|
|
15
15
|
scriptKind?: ts.ScriptKind;
|
|
16
16
|
pragmas?: Map<string, PragmaMap | PragmaMap[]>;
|
|
17
17
|
}
|
|
18
|
+
export interface ProgramMaybe53 extends ts.Program {
|
|
19
|
+
getResolvedModule?: (f: ts.SourceFile, moduleName: string, mode: ts.ResolutionMode) => ts.ResolvedModuleWithFailedLookupLocations | undefined;
|
|
20
|
+
}
|
|
21
|
+
export type GetResolvedModule = (name: string) => ts.ResolvedModuleWithFailedLookupLocations | undefined;
|
|
18
22
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import type { BoundSourceFile } from './SourceFile.js';
|
|
2
|
+
import type { BoundSourceFile, GetResolvedModule } from './SourceFile.js';
|
|
3
3
|
import type { ExportItems as Exports, ExportItem } from '../types/exports.js';
|
|
4
4
|
import type { Imports } from '../types/imports.js';
|
|
5
5
|
export type GetImportsAndExportsOptions = {
|
|
@@ -15,7 +15,7 @@ export type AddImportOptions = {
|
|
|
15
15
|
export type AddExportOptions = ExportItem & {
|
|
16
16
|
identifier: string;
|
|
17
17
|
};
|
|
18
|
-
export declare const getImportsAndExports: (sourceFile: BoundSourceFile, options: GetImportsAndExportsOptions) => {
|
|
18
|
+
export declare const getImportsAndExports: (sourceFile: BoundSourceFile, getResolvedModule: GetResolvedModule, options: GetImportsAndExportsOptions) => {
|
|
19
19
|
imports: {
|
|
20
20
|
internal: Imports;
|
|
21
21
|
external: Set<string>;
|
|
@@ -13,7 +13,7 @@ const getVisitors = (sourceFile) => ({
|
|
|
13
13
|
import: getImportVisitors(sourceFile),
|
|
14
14
|
script: getScriptVisitors(sourceFile),
|
|
15
15
|
});
|
|
16
|
-
export const getImportsAndExports = (sourceFile, options) => {
|
|
16
|
+
export const getImportsAndExports = (sourceFile, getResolvedModule, options) => {
|
|
17
17
|
const internalImports = new Map();
|
|
18
18
|
const externalImports = new Set();
|
|
19
19
|
const unresolvedImports = new Set();
|
|
@@ -50,7 +50,7 @@ export const getImportsAndExports = (sourceFile, options) => {
|
|
|
50
50
|
const { specifier, symbol, identifier = '__anonymous', isReExport = false } = options;
|
|
51
51
|
if (isBuiltin(specifier))
|
|
52
52
|
return;
|
|
53
|
-
const module =
|
|
53
|
+
const module = getResolvedModule(specifier);
|
|
54
54
|
if (module?.resolvedModule) {
|
|
55
55
|
const filePath = module.resolvedModule.resolvedFileName;
|
|
56
56
|
if (filePath) {
|
package/dist/util/parseArgs.d.ts
CHANGED
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "2.
|
|
1
|
+
export declare const version = "2.42.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.
|
|
1
|
+
export const version = '2.42.0';
|
package/package.json
CHANGED