KC's Workspace
    Preparing search index...
    interface Program {
        emit(
            targetSourceFile?: SourceFile,
            writeFile?: WriteFileCallback,
            cancellationToken?: CancellationToken,
            emitOnlyDtsFiles?: boolean,
            customTransformers?: CustomTransformers,
        ): EmitResult;
        getCompilerOptions(): CompilerOptions;
        getConfigFileParsingDiagnostics(): readonly Diagnostic[];
        getCurrentDirectory(): string;
        getDeclarationDiagnostics(
            sourceFile?: SourceFile,
            cancellationToken?: CancellationToken,
        ): readonly DiagnosticWithLocation[];
        getGlobalDiagnostics(
            cancellationToken?: CancellationToken,
        ): readonly Diagnostic[];
        getIdentifierCount(): number;
        getInstantiationCount(): number;
        getModeForResolutionAtIndex(
            file: SourceFile,
            index: number,
        ): ResolutionMode;
        getModeForUsageLocation(
            file: SourceFile,
            usage: StringLiteralLike,
        ): ResolutionMode;
        getNodeCount(): number;
        getOptionsDiagnostics(
            cancellationToken?: CancellationToken,
        ): readonly Diagnostic[];
        getProjectReferences(): readonly ProjectReference[] | undefined;
        getRelationCacheSizes(): {
            assignable: number;
            identity: number;
            strictSubtype: number;
            subtype: number;
        };
        getResolvedProjectReferences(): | readonly (
            ResolvedProjectReference
            | undefined
        )[]
        | undefined;
        getRootFileNames(): readonly string[];
        getSemanticDiagnostics(
            sourceFile?: SourceFile,
            cancellationToken?: CancellationToken,
        ): readonly Diagnostic[];
        getSourceFile(fileName: string): SourceFile | undefined;
        getSourceFileByPath(path: Path): SourceFile | undefined;
        getSourceFiles(): readonly SourceFile[];
        getSymbolCount(): number;
        getSyntacticDiagnostics(
            sourceFile?: SourceFile,
            cancellationToken?: CancellationToken,
        ): readonly DiagnosticWithLocation[];
        getTypeChecker(): TypeChecker;
        getTypeCount(): number;
        isSourceFileDefaultLibrary(file: SourceFile): boolean;
        isSourceFileFromExternalLibrary(file: SourceFile): boolean;
    }

    Hierarchy (View Summary)

    Index

    Methods

    • Emits the JavaScript and declaration files. If targetSourceFile is not specified, then the JavaScript and declaration files will be produced for all the files in this program. If targetSourceFile is specified, then only the JavaScript and declaration for that specific file will be generated.

      If writeFile is not specified then the writeFile callback from the compiler host will be used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter will be invoked when writing the JavaScript and declaration files.

      Parameters

      Returns EmitResult

    • Returns number

    • Returns number

    • Calculates the final resolution mode for an import at some index within a file's imports list. This function only returns a result when module resolution settings allow differing resolution between ESM imports and CJS requires, or when a mode is explicitly provided via import attributes, which cause an import or require condition to be used during resolution regardless of module resolution settings. In absence of overriding attributes, and in modes that support differing resolution, the result indicates the syntax the usage would emit to JavaScript. Some examples:

      // tsc foo.mts --module nodenext
      import {} from "mod";
      // Result: ESNext - the import emits as ESM due to `impliedNodeFormat` set by .mts file extension

      // tsc foo.cts --module nodenext
      import {} from "mod";
      // Result: CommonJS - the import emits as CJS due to `impliedNodeFormat` set by .cts file extension

      // tsc foo.ts --module preserve --moduleResolution bundler
      import {} from "mod";
      // Result: ESNext - the import emits as ESM due to `--module preserve` and `--moduleResolution bundler`
      // supports conditional imports/exports

      // tsc foo.ts --module preserve --moduleResolution node10
      import {} from "mod";
      // Result: undefined - the import emits as ESM due to `--module preserve`, but `--moduleResolution node10`
      // does not support conditional imports/exports

      // tsc foo.ts --module commonjs --moduleResolution node10
      import type {} from "mod" with { "resolution-mode": "import" };
      // Result: ESNext - conditional imports/exports always supported with "resolution-mode" attribute

      Parameters

      Returns ResolutionMode

    • Calculates the final resolution mode for a given module reference node. This function only returns a result when module resolution settings allow differing resolution between ESM imports and CJS requires, or when a mode is explicitly provided via import attributes, which cause an import or require condition to be used during resolution regardless of module resolution settings. In absence of overriding attributes, and in modes that support differing resolution, the result indicates the syntax the usage would emit to JavaScript. Some examples:

      // tsc foo.mts --module nodenext
      import {} from "mod";
      // Result: ESNext - the import emits as ESM due to `impliedNodeFormat` set by .mts file extension

      // tsc foo.cts --module nodenext
      import {} from "mod";
      // Result: CommonJS - the import emits as CJS due to `impliedNodeFormat` set by .cts file extension

      // tsc foo.ts --module preserve --moduleResolution bundler
      import {} from "mod";
      // Result: ESNext - the import emits as ESM due to `--module preserve` and `--moduleResolution bundler`
      // supports conditional imports/exports

      // tsc foo.ts --module preserve --moduleResolution node10
      import {} from "mod";
      // Result: undefined - the import emits as ESM due to `--module preserve`, but `--moduleResolution node10`
      // does not support conditional imports/exports

      // tsc foo.ts --module commonjs --moduleResolution node10
      import type {} from "mod" with { "resolution-mode": "import" };
      // Result: ESNext - conditional imports/exports always supported with "resolution-mode" attribute

      Parameters

      Returns ResolutionMode

    • Returns number

    • Returns { assignable: number; identity: number; strictSubtype: number; subtype: number }

    • Get a list of root file names that were passed to a 'createProgram'

      Returns readonly string[]

    • Get a list of files in the program

      Returns readonly SourceFile[]

    • Returns number

    • Gets a type checker that can be used to semantically analyze source files in the program.

      Returns TypeChecker

    • Returns number

    • Parameters

      Returns boolean

    • Parameters

      Returns boolean