📄 typeDeclaredInFile¶
📊 Analysis Summary¶
| Metric | Count |
|---|---|
| 🔧 Functions | 1 |
| 📦 Imports | 2 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 packages/type-utils/src/typeOrValueSpecifiers/typeDeclaredInFile.ts
📦 Imports¶
| Name | Source |
|---|---|
getCanonicalFileName |
@typescript-eslint/typescript-estree |
path |
node:path |
Functions¶
typeDeclaredInFile(relativePath: string | undefined, declarationFiles: ts.SourceFile[], program: ts.Program): boolean¶
Parameters:
relativePathstring | undefineddeclarationFilests.SourceFile[]programts.Program
Returns: boolean
Calls:
getCanonicalFileName (from @typescript-eslint/typescript-estree)program.getCurrentDirectorydeclarationFiles.somegetCanonicalFileName(declaration.fileName).startsWithpath.join
Code
export function typeDeclaredInFile(
relativePath: string | undefined,
declarationFiles: ts.SourceFile[],
program: ts.Program,
): boolean {
if (relativePath == null) {
const cwd = getCanonicalFileName(program.getCurrentDirectory());
return declarationFiles.some(declaration =>
getCanonicalFileName(declaration.fileName).startsWith(cwd),
);
}
const absolutePath = getCanonicalFileName(
path.join(program.getCurrentDirectory(), relativePath),
);
return declarationFiles.some(
declaration => getCanonicalFileName(declaration.fileName) === absolutePath,
);
}
Generated by Syntax Scribe