/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import ts from 'typescript'; import { AbsoluteFsPath } from '../../file_system'; import { ShimAdapter, ShimReferenceTagger } from '../../shims'; import { RequiredDelegations } from '../../util/src/typescript'; import { ExtendedTsCompilerHost, NgCompilerAdapter, NgCompilerOptions, UnifiedModulesHost } from '../api'; /** * Delegates all methods of `ExtendedTsCompilerHost` to a delegate, with the exception of * `getSourceFile` and `fileExists` which are implemented in `NgCompilerHost`. * * If a new method is added to `ts.CompilerHost` which is not delegated, a type error will be * generated for this class. */ export declare class DelegatingCompilerHost implements Omit, 'getSourceFile' | 'fileExists'> { protected delegate: ExtendedTsCompilerHost; createHash: ((data: string) => string) | undefined; directoryExists: ((directoryName: string) => boolean) | undefined; fileNameToModuleName: ((importedFilePath: string, containingFilePath: string) => string) | undefined; getCancellationToken: (() => ts.CancellationToken) | undefined; getCanonicalFileName: (fileName: string) => string; getCurrentDirectory: () => string; getDefaultLibFileName: (options: ts.CompilerOptions) => string; getDefaultLibLocation: (() => string) | undefined; getDirectories: ((path: string) => string[]) | undefined; getEnvironmentVariable: ((name: string) => string | undefined) | undefined; getModifiedResourceFiles: (() => Set | undefined) | undefined; getNewLine: () => string; getParsedCommandLine: ((fileName: string) => ts.ParsedCommandLine | undefined) | undefined; getSourceFileByPath: ((fileName: string, path: ts.Path, languageVersionOrOptions: ts.ScriptTarget | ts.CreateSourceFileOptions, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean) => ts.SourceFile | undefined) | undefined; readDirectory: ((rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number) => string[]) | undefined; readFile: (fileName: string) => string | undefined; readResource: ((fileName: string) => Promise | string) | undefined; transformResource: ((data: string, context: import("../api").ResourceHostContext) => Promise) | undefined; realpath: ((path: string) => string) | undefined; resolveModuleNames: ((moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ts.ResolvedProjectReference | undefined, options: ts.CompilerOptions, containingSourceFile?: ts.SourceFile) => (ts.ResolvedModule | undefined)[]) | undefined; resolveTypeReferenceDirectives: ((typeReferenceDirectiveNames: string[] | readonly ts.FileReference[], containingFile: string, redirectedReference: ts.ResolvedProjectReference | undefined, options: ts.CompilerOptions, containingFileMode?: ts.ResolutionMode) => (ts.ResolvedTypeReferenceDirective | undefined)[]) | undefined; resourceNameToFileName: ((resourceName: string, containingFilePath: string, fallbackResolve?: (url: string, fromFile: string) => string | null) => string | null) | undefined; trace: ((s: string) => void) | undefined; useCaseSensitiveFileNames: () => boolean; writeFile: ts.WriteFileCallback; getModuleResolutionCache: (() => ts.ModuleResolutionCache | undefined) | undefined; hasInvalidatedResolutions: ((filePath: ts.Path) => boolean) | undefined; resolveModuleNameLiterals: ((moduleLiterals: readonly ts.StringLiteralLike[], containingFile: string, redirectedReference: ts.ResolvedProjectReference | undefined, options: ts.CompilerOptions, containingSourceFile: ts.SourceFile, reusedNames: readonly ts.StringLiteralLike[] | undefined) => readonly ts.ResolvedModuleWithFailedLookupLocations[]) | undefined; resolveTypeReferenceDirectiveReferences: ((typeDirectiveReferences: readonly T[], containingFile: string, redirectedReference: ts.ResolvedProjectReference | undefined, options: ts.CompilerOptions, containingSourceFile: ts.SourceFile | undefined, reusedNames: readonly T[] | undefined) => readonly ts.ResolvedTypeReferenceDirectiveWithFailedLookupLocations[]) | undefined; get jsDocParsingMode(): ts.JSDocParsingMode | undefined; set jsDocParsingMode(mode: ts.JSDocParsingMode | undefined); constructor(delegate: ExtendedTsCompilerHost); private delegateMethod; } /** * A wrapper around `ts.CompilerHost` (plus any extension methods from `ExtendedTsCompilerHost`). * * In order for a consumer to include Angular compilation in their TypeScript compiler, the * `ts.Program` must be created with a host that adds Angular-specific files (e.g. * the template type-checking file, etc) to the compilation. `NgCompilerHost` is the * host implementation which supports this. * * The interface implementations here ensure that `NgCompilerHost` fully delegates to * `ExtendedTsCompilerHost` methods whenever present. */ export declare class NgCompilerHost extends DelegatingCompilerHost implements RequiredDelegations, ExtendedTsCompilerHost, NgCompilerAdapter { private shimAdapter; private shimTagger; readonly entryPoint: AbsoluteFsPath | null; readonly constructionDiagnostics: ts.Diagnostic[]; readonly inputFiles: ReadonlyArray; readonly rootDirs: ReadonlyArray; constructor(delegate: ExtendedTsCompilerHost, inputFiles: ReadonlyArray, rootDirs: ReadonlyArray, shimAdapter: ShimAdapter, shimTagger: ShimReferenceTagger, entryPoint: AbsoluteFsPath | null, diagnostics: ts.Diagnostic[]); /** * Retrieves a set of `ts.SourceFile`s which should not be emitted as JS files. * * Available after this host is used to create a `ts.Program` (which causes all the files in the * program to be enumerated). */ get ignoreForEmit(): Set; /** * Retrieve the array of shim extension prefixes for which shims were created for each original * file. */ get shimExtensionPrefixes(): string[]; /** * Performs cleanup that needs to happen after a `ts.Program` has been created using this host. */ postProgramCreationCleanup(): void; /** * Create an `NgCompilerHost` from a delegate host, an array of input filenames, and the full set * of TypeScript and Angular compiler options. */ static wrap(delegate: ts.CompilerHost, inputFiles: ReadonlyArray, options: NgCompilerOptions, oldProgram: ts.Program | null): NgCompilerHost; /** * Check whether the given `ts.SourceFile` is a shim file. * * If this returns false, the file is user-provided. */ isShim(sf: ts.SourceFile): boolean; /** * Check whether the given `ts.SourceFile` is a resource file. * * This simply returns `false` for the compiler-cli since resource files are not added as root * files to the project. */ isResource(sf: ts.SourceFile): boolean; getSourceFile(fileName: string, languageVersionOrOptions: ts.ScriptTarget | ts.CreateSourceFileOptions, onError?: ((message: string) => void) | undefined, shouldCreateNewSourceFile?: boolean | undefined): ts.SourceFile | undefined; fileExists(fileName: string): boolean; get unifiedModulesHost(): UnifiedModulesHost | null; private createCachedResolveModuleNamesFunction; }