summaryrefslogtreecommitdiff
path: root/cli/tsc/dts/typescript.d.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tsc/dts/typescript.d.ts')
-rw-r--r--cli/tsc/dts/typescript.d.ts417
1 files changed, 252 insertions, 165 deletions
diff --git a/cli/tsc/dts/typescript.d.ts b/cli/tsc/dts/typescript.d.ts
index 882767d3c..5326c98dd 100644
--- a/cli/tsc/dts/typescript.d.ts
+++ b/cli/tsc/dts/typescript.d.ts
@@ -214,6 +214,22 @@ declare namespace ts {
* The time spent creating or updating the auto-import program, in milliseconds.
*/
createAutoImportProviderProgramDurationMs?: number;
+ /**
+ * The time spent computing diagnostics, in milliseconds.
+ */
+ diagnosticsDuration?: FileDiagnosticPerformanceData[];
+ }
+ /**
+ * Time spent computing each kind of diagnostics, in milliseconds.
+ */
+ export type DiagnosticPerformanceData = {
+ [Kind in DiagnosticEventKind]?: number;
+ };
+ export interface FileDiagnosticPerformanceData extends DiagnosticPerformanceData {
+ /**
+ * The file for which the performance data is reported.
+ */
+ file: string;
}
/**
* Arguments for FileRequest messages.
@@ -584,23 +600,7 @@ declare namespace ts {
}
export interface ApplyCodeActionCommandResponse extends Response {
}
- export interface FileRangeRequestArgs extends FileRequestArgs {
- /**
- * The line number for the request (1-based).
- */
- startLine: number;
- /**
- * The character offset (on the line) for the request (1-based).
- */
- startOffset: number;
- /**
- * The line number for the request (1-based).
- */
- endLine: number;
- /**
- * The character offset (on the line) for the request (1-based).
- */
- endOffset: number;
+ export interface FileRangeRequestArgs extends FileRequestArgs, FileRange {
}
/**
* Instances of this interface specify errorcodes on a specific location in a sourcefile.
@@ -1866,7 +1866,7 @@ declare namespace ts {
* List of file names for which to compute compiler errors.
* The files will be checked in list order.
*/
- files: string[];
+ files: (string | FileRangesRequestArgs)[];
/**
* Delay in milliseconds to wait before starting to compute
* errors for the files in the file list
@@ -1887,6 +1887,27 @@ declare namespace ts {
command: CommandTypes.Geterr;
arguments: GeterrRequestArgs;
}
+ export interface FileRange {
+ /**
+ * The line number for the request (1-based).
+ */
+ startLine: number;
+ /**
+ * The character offset (on the line) for the request (1-based).
+ */
+ startOffset: number;
+ /**
+ * The line number for the request (1-based).
+ */
+ endLine: number;
+ /**
+ * The character offset (on the line) for the request (1-based).
+ */
+ endOffset: number;
+ }
+ export interface FileRangesRequestArgs extends Pick<FileRequestArgs, "file"> {
+ ranges: FileRange[];
+ }
export type RequestCompletedEventName = "requestCompleted";
/**
* Event that is sent when server have finished processing request with specified id.
@@ -1897,6 +1918,7 @@ declare namespace ts {
}
export interface RequestCompletedEventBody {
request_seq: number;
+ performanceData?: PerformanceData;
}
/**
* Item of diagnostic information found in a DiagnosticEvent message.
@@ -1969,8 +1991,12 @@ declare namespace ts {
* An array of diagnostic information items.
*/
diagnostics: Diagnostic[];
+ /**
+ * Spans where the region diagnostic was requested, if this is a region semantic diagnostic event.
+ */
+ spans?: TextSpan[];
}
- export type DiagnosticEventKind = "semanticDiag" | "syntaxDiag" | "suggestionDiag";
+ export type DiagnosticEventKind = "semanticDiag" | "syntaxDiag" | "suggestionDiag" | "regionSemanticDiag";
/**
* Event message for DiagnosticEventKind event types.
* These events provide syntactic and semantic errors for a file.
@@ -2510,6 +2536,7 @@ declare namespace ts {
private readonly knownCachesSet;
private readonly projectWatchers;
private safeList;
+ private pendingRunRequests;
private installRunCount;
private inFlightRequestCount;
abstract readonly typesRegistry: Map<string, MapLike<string>>;
@@ -2636,6 +2663,7 @@ declare namespace ts {
interface ServerHost extends System {
watchFile(path: string, callback: FileWatcherCallback, pollingInterval?: number, options?: WatchOptions): FileWatcher;
watchDirectory(path: string, callback: DirectoryWatcherCallback, recursive?: boolean, options?: WatchOptions): FileWatcher;
+ preferNonRecursiveWatch?: boolean;
setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): any;
clearTimeout(timeoutId: any): void;
setImmediate(callback: (...args: any[]) => void, ...args: any[]): any;
@@ -2644,6 +2672,18 @@ declare namespace ts {
trace?(s: string): void;
require?(initialPath: string, moduleName: string): ModuleImportResult;
}
+ interface InstallPackageOptionsWithProject extends InstallPackageOptions {
+ projectName: string;
+ projectRootPath: Path;
+ }
+ interface ITypingsInstaller {
+ isKnownTypesPackageName(name: string): boolean;
+ installPackage(options: InstallPackageOptionsWithProject): Promise<ApplyCodeActionCommandResult>;
+ enqueueInstallTypingsRequest(p: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray<string> | undefined): void;
+ attach(projectService: ProjectService): void;
+ onProjectClosed(p: Project): void;
+ readonly globalTypingsCacheLocation: string | undefined;
+ }
function createInstallTypingsRequest(project: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray<string>, cachePath?: string): DiscoverTypings;
function toNormalizedPath(fileName: string): NormalizedPath;
function normalizedPathToPath(normalizedPath: NormalizedPath, currentDirectory: string, getCanonicalFileName: (f: string) => string): Path;
@@ -2702,6 +2742,7 @@ declare namespace ts {
readonly containingProjects: Project[];
private formatSettings;
private preferences;
+ private realpath;
constructor(host: ServerHost, fileName: NormalizedPath, scriptKind: ScriptKind, hasMixedContent: boolean, path: Path, initialVersion?: number);
isScriptOpen(): boolean;
open(newText: string | undefined): void;
@@ -2735,19 +2776,6 @@ declare namespace ts {
positionToLineOffset(position: number): protocol.Location;
isJavaScript(): boolean;
}
- interface InstallPackageOptionsWithProject extends InstallPackageOptions {
- projectName: string;
- projectRootPath: Path;
- }
- interface ITypingsInstaller {
- isKnownTypesPackageName(name: string): boolean;
- installPackage(options: InstallPackageOptionsWithProject): Promise<ApplyCodeActionCommandResult>;
- enqueueInstallTypingsRequest(p: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray<string> | undefined): void;
- attach(projectService: ProjectService): void;
- onProjectClosed(p: Project): void;
- readonly globalTypingsCacheLocation: string | undefined;
- }
- const nullTypingsInstaller: ITypingsInstaller;
function allRootFilesAreJsOrDts(project: Project): boolean;
function allFilesAreJsOrDts(project: Project): boolean;
enum ProjectKind {
@@ -2789,33 +2817,31 @@ declare namespace ts {
private externalFiles;
private missingFilesMap;
private generatedFilesMap;
+ private hasAddedorRemovedFiles;
+ private hasAddedOrRemovedSymlinks;
protected languageService: LanguageService;
languageServiceEnabled: boolean;
readonly trace?: (s: string) => void;
readonly realpath?: (path: string) => string;
private builderState;
- /**
- * Set of files names that were updated since the last call to getChangesSinceVersion.
- */
private updatedFileNames;
- /**
- * Set of files that was returned from the last call to getChangesSinceVersion.
- */
private lastReportedFileNames;
- /**
- * Last version that was reported.
- */
private lastReportedVersion;
protected projectErrors: Diagnostic[] | undefined;
protected isInitialLoadPending: () => boolean;
+ private typingsCache;
+ private typingWatchers;
private readonly cancellationToken;
isNonTsProject(): boolean;
isJsOnlyProject(): boolean;
static resolveModule(moduleName: string, initialDir: string, host: ServerHost, log: (message: string) => void): {} | undefined;
+ private exportMapCache;
+ private changedFilesForExportMapCache;
+ private moduleSpecifierCache;
+ private symlinks;
readonly jsDocParsingMode: JSDocParsingMode | undefined;
isKnownTypesPackageName(name: string): boolean;
installPackage(options: InstallPackageOptions): Promise<ApplyCodeActionCommandResult>;
- private get typingsCache();
getCompilationSettings(): ts.CompilerOptions;
getCompilerOptions(): ts.CompilerOptions;
getNewLine(): string;
@@ -2882,6 +2908,8 @@ declare namespace ts {
* @returns: true if set of files in the project stays the same and false - otherwise.
*/
updateGraph(): boolean;
+ private closeWatchingTypingLocations;
+ private onTypingInstallerWatchInvoke;
protected removeExistingTypings(include: string[]): string[];
private updateGraphWorker;
private detachScriptInfoFromProject;
@@ -2893,6 +2921,7 @@ declare namespace ts {
getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo | undefined;
getScriptInfo(uncheckedFileName: string): ts.server.ScriptInfo | undefined;
filesToString(writeProjectFileNames: boolean): string;
+ private filesToStringWorker;
setCompilerOptions(compilerOptions: CompilerOptions): void;
setTypeAcquisition(newTypeAcquisition: TypeAcquisition | undefined): void;
getTypeAcquisition(): ts.TypeAcquisition;
@@ -2901,6 +2930,8 @@ declare namespace ts {
protected enablePlugin(pluginConfigEntry: PluginImport, searchPaths: string[]): void;
/** Starts a new check for diagnostics. Call this if some file has updated that would cause diagnostics to be changed. */
refreshDiagnostics(): void;
+ private isDefaultProjectForOpenFiles;
+ private getCompilerOptionsForNoDtsResolutionProject;
}
/**
* If a file is opened and no tsconfig (or jsconfig) is found,
@@ -2920,6 +2951,7 @@ declare namespace ts {
}
class AutoImportProviderProject extends Project {
private hostProject;
+ private static readonly maxDependencies;
private rootFileNames;
updateGraph(): boolean;
hasRoots(): boolean;
@@ -2936,6 +2968,8 @@ declare namespace ts {
class ConfiguredProject extends Project {
readonly canonicalConfigFilePath: NormalizedPath;
private projectReferences;
+ private compilerHost?;
+ private releaseParsedConfig;
/**
* If the project has reload from disk pending, it reloads (and then updates graph as part of that) instead of just updating the graph
* @returns: true if set of files in the project stays the same and false - otherwise.
@@ -3126,6 +3160,7 @@ declare namespace ts {
configFileName?: NormalizedPath;
configFileErrors?: readonly Diagnostic[];
}
+ const nullTypingsInstaller: ITypingsInstaller;
interface ProjectServiceOptions {
host: ServerHost;
logger: Logger;
@@ -3151,16 +3186,8 @@ declare namespace ts {
}
class ProjectService {
private readonly nodeModulesWatchers;
- /**
- * Contains all the deleted script info's version information so that
- * it does not reset when creating script info again
- * (and could have potentially collided with version where contents mismatch)
- */
private readonly filenameToScriptInfoVersion;
private readonly allJsFilesForOpenFileTelemetry;
- /**
- * maps external project file name to list of config files that were the part of this project
- */
private readonly externalProjectToConfiguredProjectMap;
/**
* external projects (configuration and list of root files is not controlled by tsserver)
@@ -3178,13 +3205,8 @@ declare namespace ts {
* Open files: with value being project root path, and key being Path of the file that is open
*/
readonly openFiles: Map<Path, NormalizedPath | undefined>;
- /** Config files looked up and cached config files for open script info */
private readonly configFileForOpenFiles;
- /** Set of open script infos that are root of inferred project */
private rootOfInferredProjects;
- /**
- * Map of open files that are opened without complete path but have projectRoot as current directory
- */
private readonly openFilesWithNonRootedDiskPath;
private compilerOptionsForInferredProjects;
private compilerOptionsForInferredProjectsPerProjectRoot;
@@ -3192,18 +3214,11 @@ declare namespace ts {
private watchOptionsForInferredProjectsPerProjectRoot;
private typeAcquisitionForInferredProjects;
private typeAcquisitionForInferredProjectsPerProjectRoot;
- /**
- * Project size for configured or external projects
- */
private readonly projectToSizeMap;
private readonly hostConfiguration;
private safelist;
private readonly legacySafelist;
private pendingProjectUpdates;
- /**
- * All the open script info that needs recalculation of the default project,
- * this also caches config file info before config file change was detected to use it in case projects are not updated yet
- */
private pendingOpenFileProjectUpdates?;
readonly currentDirectory: NormalizedPath;
readonly toCanonicalFileName: (f: string) => string;
@@ -3221,8 +3236,11 @@ declare namespace ts {
readonly allowLocalPluginLoads: boolean;
readonly typesMapLocation: string | undefined;
readonly serverMode: LanguageServiceMode;
- /** Tracks projects that we have already sent telemetry for. */
private readonly seenProjects;
+ private readonly sharedExtendedConfigFileWatchers;
+ private readonly extendedConfigCache;
+ private packageJsonFilesMap;
+ private incompleteCompletionsCache;
private performanceEventHandler?;
private pendingPluginEnablements?;
private currentPluginEnablementPromise?;
@@ -3236,20 +3254,9 @@ declare namespace ts {
setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.InferredProjectCompilerOptions, projectRootPath?: string): void;
findProject(projectName: string): Project | undefined;
getDefaultProjectForFile(fileName: NormalizedPath, ensureProject: boolean): Project | undefined;
- /**
- * If there is default project calculation pending for this file,
- * then it completes that calculation so that correct default project is used for the project
- */
private tryGetDefaultProjectForEnsuringConfiguredProjectForFile;
private doEnsureDefaultProjectForFile;
getScriptInfoEnsuringProjectsUptoDate(uncheckedFileName: string): ScriptInfo | undefined;
- /**
- * Ensures the project structures are upto date
- * This means,
- * - we go through all the projects and update them if they are dirty
- * - if updates reflect some change in structure or there was pending request to ensure projects for open files
- * ensure that each open script info has project
- */
private ensureProjectStructuresUptoDate;
getFormatCodeOptions(file: NormalizedPath): FormatCodeSettings;
getPreferences(file: NormalizedPath): protocol.UserPreferences;
@@ -3260,37 +3267,30 @@ declare namespace ts {
private delayUpdateSourceInfoProjects;
private delayUpdateProjectsOfScriptInfoPath;
private handleDeletedFile;
+ private watchWildcardDirectory;
+ private onWildCardDirectoryWatcherInvoke;
+ private delayUpdateProjectsFromParsedConfigOnConfigFileChange;
+ private onConfigFileChanged;
private removeProject;
private assignOrphanScriptInfosToInferredProject;
- /**
- * Remove this file from the set of open, non-configured files.
- * @param info The file that has been closed or newly configured
- */
private closeOpenFile;
private deleteScriptInfo;
private configFileExists;
- /**
- * This function tries to search for a tsconfig.json for the given file.
- * This is different from the method the compiler uses because
- * the compiler can assume it will always start searching in the
- * current directory (the directory in which tsc was invoked).
- * The server must start searching from the directory containing
- * the newly opened file.
- */
+ private createConfigFileWatcherForParsedConfig;
private forEachConfigFileLocation;
- /** Get cached configFileName for scriptInfo or ancestor of open script info */
private getConfigFileNameForFileFromCache;
- /** Caches the configFilename for script info or ancestor of open script info */
private setConfigFileNameForFileInCache;
private printProjects;
private getConfiguredProjectByCanonicalConfigFilePath;
private findExternalProjectByProjectName;
- /** Get a filename if the language service exceeds the maximum allowed program size; otherwise returns undefined. */
private getFilenameForExceededTotalSizeLimitForNonTsFiles;
private createExternalProject;
private addFilesToNonInferredProject;
+ private loadConfiguredProject;
private updateNonInferredProjectFiles;
private updateRootAndOptionsOfNonInferredProject;
+ private reloadFileNamesOfParsedConfig;
+ private clearSemanticCache;
private getOrCreateInferredProjectForProjectRootPathIfEnabled;
private getOrCreateSingleInferredProjectIfEnabled;
private getOrCreateSingleInferredWithoutProjectRoot;
@@ -3316,23 +3316,15 @@ declare namespace ts {
private addSourceInfoToSourceMap;
private addMissingSourceMapFile;
setHostConfiguration(args: protocol.ConfigureRequestArguments): void;
+ private getWatchOptionsFromProjectWatchOptions;
closeLog(): void;
+ private sendSourceFileChange;
/**
* This function rebuilds the project for every file opened by the client
* This does not reload contents of open files from disk. But we could do that if needed
*/
reloadProjects(): void;
- /**
- * Remove the root of inferred project if script info is part of another project
- */
private removeRootOfInferredProjectIfNowPartOfOtherProject;
- /**
- * This function is to update the project structure for every inferred project.
- * It is called on the premise that all the configured projects are
- * up to date.
- * This will go through open files and assign them to inferred project if open file is not part of any other project
- * After that all the inferred project graphs are updated
- */
private ensureProjectForOpenFiles;
/**
* Open file whose contents is managed by the client
@@ -3343,20 +3335,12 @@ declare namespace ts {
private findExternalProjectContainingOpenScriptInfo;
private getOrCreateOpenScriptInfo;
private assignProjectToOpenedScriptInfo;
- /**
- * Finds the default configured project for given info
- * For any tsconfig found, it looks into that project, if not then all its references,
- * The search happens for all tsconfigs till projectRootPath
- */
private tryFindDefaultConfiguredProjectForOpenScriptInfo;
- /**
- * Finds the default configured project, if found, it creates the solution projects (does not load them right away)
- * with Find: finds the projects even if the project is deferredClosed
- */
private tryFindDefaultConfiguredProjectAndLoadAncestorsForOpenScriptInfo;
private ensureProjectChildren;
private cleanupConfiguredProjects;
private cleanupProjectsAndScriptInfos;
+ private tryInvokeWildCardDirectories;
openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, projectRootPath?: NormalizedPath): OpenConfiguredProjectResult;
private removeOrphanScriptInfos;
private telemetryOnOpenFile;
@@ -3368,7 +3352,6 @@ declare namespace ts {
private collectChanges;
closeExternalProject(uncheckedFileName: string): void;
openExternalProjects(projects: protocol.ExternalProject[]): void;
- /** Makes a filename safe to insert in a RegExp */
private static readonly filenameEscapeRegexp;
private static escapeFilenameForRegex;
resetSafeList(): void;
@@ -3376,9 +3359,12 @@ declare namespace ts {
private applySafeListWorker;
openExternalProject(proj: protocol.ExternalProject): void;
hasDeferredExtension(): boolean;
+ private endEnablePlugin;
private enableRequestedPluginsAsync;
private enableRequestedPluginsWorker;
configurePlugin(args: protocol.ConfigurePluginRequestArguments): void;
+ private watchPackageJsonFile;
+ private onPackageJsonChange;
}
function formatMessage<T extends protocol.Message>(msg: T, logger: Logger, byteLength: (s: string, encoding: BufferEncoding) => number, newLine: string): string;
interface ServerCancellationToken extends HostCancellationToken {
@@ -3386,10 +3372,6 @@ declare namespace ts {
resetRequest(requestId: number): void;
}
const nullCancellationToken: ServerCancellationToken;
- interface PendingErrorCheck {
- fileName: NormalizedPath;
- project: Project;
- }
/** @deprecated use ts.server.protocol.CommandTypes */
type CommandNames = protocol.CommandTypes;
/** @deprecated use ts.server.protocol.CommandTypes */
@@ -3449,6 +3431,7 @@ declare namespace ts {
constructor(opts: SessionOptions);
private sendRequestCompletedEvent;
private addPerformanceData;
+ private addDiagnosticsPerformanceData;
private performanceEventHandler;
private defaultEventHandler;
private projectsUpdatedInBackgroundEvent;
@@ -3460,8 +3443,8 @@ declare namespace ts {
private semanticCheck;
private syntacticCheck;
private suggestionCheck;
+ private regionSemanticCheck;
private sendDiagnosticsEvent;
- /** It is the caller's responsibility to verify that `!this.suppressDiagnosticEvents`. */
private updateErrorCheck;
private cleanProjects;
private cleanup;
@@ -3508,10 +3491,6 @@ declare namespace ts {
private toSpanGroups;
private getReferences;
private getFileReferences;
- /**
- * @param fileName is the name of the file to be opened
- * @param fileContent is a version of the file content that is known to be more up to date than the one on disk
- */
private openClientFile;
private getPosition;
private getPositionInFile;
@@ -3610,19 +3589,12 @@ declare namespace ts {
}
namespace deno {
function setIsNodeSourceFileCallback(callback: IsNodeSourceFileCallback): void;
- function setNodeBuiltInModuleNames(names: readonly string[]): void;
function setNodeOnlyGlobalNames(names: readonly string[]): void;
- function createDenoForkContext({ mergeSymbol, globals, nodeGlobals, ambientModuleSymbolRegex }: {
+ function createDenoForkContext({ mergeSymbol, globals, nodeGlobals }: {
mergeSymbol(target: ts.Symbol, source: ts.Symbol, unidirectional?: boolean): ts.Symbol;
globals: ts.SymbolTable;
nodeGlobals: ts.SymbolTable;
- ambientModuleSymbolRegex: RegExp;
- }): {
- hasNodeSourceFile: (node: ts.Node | undefined) => boolean;
- getGlobalsForName: (id: ts.__String) => ts.SymbolTable;
- mergeGlobalSymbolTable: (node: ts.Node, source: ts.SymbolTable, unidirectional?: boolean) => void;
- combinedGlobals: ts.SymbolTable;
- };
+ }): DenoForkContext;
function tryParseNpmPackageReference(text: string): {
name: string;
versionReq: string | undefined;
@@ -3634,6 +3606,12 @@ declare namespace ts {
subPath: string | undefined;
};
type IsNodeSourceFileCallback = (sourceFile: ts.SourceFile) => boolean;
+ interface DenoForkContext {
+ hasNodeSourceFile: (node: ts.Node | undefined) => boolean;
+ getGlobalsForName: (id: ts.__String) => ts.SymbolTable;
+ mergeGlobalSymbolTable: (node: ts.Node, source: ts.SymbolTable, unidirectional?: boolean) => void;
+ combinedGlobals: ts.SymbolTable;
+ }
interface NpmPackageReference {
name: string;
versionReq: string;
@@ -3648,7 +3626,7 @@ declare namespace ts {
readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[] | undefined, depth?: number): string[];
}
}
- const versionMajorMinor = "5.5";
+ const versionMajorMinor = "5.6";
/** The version of the TypeScript compiler release */
const version: string;
/**
@@ -4478,7 +4456,7 @@ declare namespace ts {
readonly right: Identifier;
}
type EntityName = Identifier | QualifiedName;
- type PropertyName = Identifier | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | ComputedPropertyName | PrivateIdentifier;
+ type PropertyName = Identifier | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | ComputedPropertyName | PrivateIdentifier | BigIntLiteral;
type MemberName = Identifier | PrivateIdentifier;
type DeclarationName = PropertyName | JsxAttributeName | StringLiteralLike | ElementAccessExpression | BindingPattern | EntityNameExpression;
interface Declaration extends Node {
@@ -4829,7 +4807,7 @@ declare namespace ts {
readonly kind: SyntaxKind.StringLiteral;
}
type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral;
- type PropertyNameLiteral = Identifier | StringLiteralLike | NumericLiteral | JsxNamespacedName;
+ type PropertyNameLiteral = Identifier | StringLiteralLike | NumericLiteral | JsxNamespacedName | BigIntLiteral;
interface TemplateLiteralTypeNode extends TypeNode {
kind: SyntaxKind.TemplateLiteralType;
readonly head: TemplateHead;
@@ -5549,7 +5527,7 @@ declare namespace ts {
interface NamespaceExport extends NamedDeclaration {
readonly kind: SyntaxKind.NamespaceExport;
readonly parent: ExportDeclaration;
- readonly name: Identifier;
+ readonly name: ModuleExportName;
}
interface NamespaceExportDeclaration extends DeclarationStatement, JSDocContainer {
readonly kind: SyntaxKind.NamespaceExportDeclaration;
@@ -5581,7 +5559,7 @@ declare namespace ts {
interface ImportSpecifier extends NamedDeclaration {
readonly kind: SyntaxKind.ImportSpecifier;
readonly parent: NamedImports;
- readonly propertyName?: Identifier;
+ readonly propertyName?: ModuleExportName;
readonly name: Identifier;
readonly isTypeOnly: boolean;
}
@@ -5589,9 +5567,10 @@ declare namespace ts {
readonly kind: SyntaxKind.ExportSpecifier;
readonly parent: NamedExports;
readonly isTypeOnly: boolean;
- readonly propertyName?: Identifier;
- readonly name: Identifier;
+ readonly propertyName?: ModuleExportName;
+ readonly name: ModuleExportName;
}
+ type ModuleExportName = Identifier | StringLiteral;
type ImportOrExportSpecifier = ImportSpecifier | ExportSpecifier;
type TypeOnlyCompatibleAliasDeclaration = ImportClause | ImportEqualsDeclaration | NamespaceImport | ImportOrExportSpecifier | ExportDeclaration | NamespaceExport;
type TypeOnlyImportDeclaration =
@@ -6046,19 +6025,67 @@ declare namespace ts {
isSourceFileFromExternalLibrary(file: SourceFile): boolean;
isSourceFileDefaultLibrary(file: SourceFile): boolean;
/**
- * Calculates the final resolution mode for a given module reference node. This is the resolution mode explicitly provided via import
- * attributes, if present, or the syntax the usage would have if emitted to JavaScript. In `--module node16` or `nodenext`, this may
- * depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the input syntax of the reference. In other
- * `module` modes, when overriding import attributes are not provided, this function returns `undefined`, as the result would have no
- * impact on module resolution, emit, or type checking.
+ * 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:
+ *
+ * ```ts
+ * // 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
+ * ```
*/
getModeForUsageLocation(file: SourceFile, usage: StringLiteralLike): ResolutionMode;
/**
- * Calculates the final resolution mode for an import at some index within a file's `imports` list. This is the resolution mode
- * explicitly provided via import attributes, if present, or the syntax the usage would have if emitted to JavaScript. In
- * `--module node16` or `nodenext`, this may depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the
- * input syntax of the reference. In other `module` modes, when overriding import attributes are not provided, this function returns
- * `undefined`, as the result would have no impact on module resolution, emit, or type checking.
+ * 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:
+ *
+ * ```ts
+ * // 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
+ * ```
*/
getModeForResolutionAtIndex(file: SourceFile, index: number): ResolutionMode;
getProjectReferences(): readonly ProjectReference[] | undefined;
@@ -6125,6 +6152,27 @@ declare namespace ts {
getBaseTypes(type: InterfaceType): BaseType[];
getBaseTypeOfLiteralType(type: Type): Type;
getWidenedType(type: Type): Type;
+ /**
+ * Gets the "awaited type" of a type.
+ *
+ * If an expression has a Promise-like type, the "awaited type" of the expression is
+ * derived from the type of the first argument of the fulfillment callback for that
+ * Promise's `then` method. If the "awaited type" is itself a Promise-like, it is
+ * recursively unwrapped in the same manner until a non-promise type is found.
+ *
+ * If an expression does not have a Promise-like type, its "awaited type" is the type
+ * of the expression.
+ *
+ * If the resulting "awaited type" is a generic object type, then it is wrapped in
+ * an `Awaited<T>`.
+ *
+ * In the event the "awaited type" circularly references itself, or is a non-Promise
+ * object-type with a callable `then()` method, an "awaited type" cannot be determined
+ * and the value `undefined` will be returned.
+ *
+ * This is used to reflect the runtime behavior of the `await` keyword.
+ */
+ getAwaitedType(type: Type): Type | undefined;
getReturnTypeOfSignature(signature: Signature): Type;
getNullableType(type: Type, flags: TypeFlags): Type;
getNonNullableType(type: Type): Type;
@@ -6217,6 +6265,7 @@ declare namespace ts {
getNumberType(): Type;
getNumberLiteralType(value: number): NumberLiteralType;
getBigIntType(): Type;
+ getBigIntLiteralType(value: PseudoBigInt): BigIntLiteralType;
getBooleanType(): Type;
getFalseType(): Type;
getTrueType(): Type;
@@ -6686,7 +6735,11 @@ declare namespace ts {
minLength: number;
/** Number of initial required or optional elements */
fixedLength: number;
- /** True if tuple has any rest or variadic elements */
+ /**
+ * True if tuple has any rest or variadic elements
+ *
+ * @deprecated Use `.combinedFlags & ElementFlags.Variable` instead
+ */
hasRestElement: boolean;
combinedFlags: ElementFlags;
readonly: boolean;
@@ -7010,6 +7063,7 @@ declare namespace ts {
strictBindCallApply?: boolean;
strictNullChecks?: boolean;
strictPropertyInitialization?: boolean;
+ strictBuiltinIteratorReturn?: boolean;
stripInternal?: boolean;
/** @deprecated */
suppressExcessPropertyErrors?: boolean;
@@ -7018,6 +7072,7 @@ declare namespace ts {
target?: ScriptTarget;
traceResolution?: boolean;
useUnknownInCatchVariables?: boolean;
+ noUncheckedSideEffectImports?: boolean;
resolveJsonModule?: boolean;
types?: string[];
/** Paths used to compute primary types search locations */
@@ -7344,9 +7399,10 @@ declare namespace ts {
TypeAssertions = 2,
NonNullAssertions = 4,
PartiallyEmittedExpressions = 8,
+ ExpressionsWithTypeArguments = 16,
Assertions = 6,
- All = 15,
- ExcludeJSDocTypeAssertion = 16,
+ All = 31,
+ ExcludeJSDocTypeAssertion = -2147483648,
}
type ImmediatelyInvokedFunctionExpression = CallExpression & {
readonly expression: FunctionExpression;
@@ -7645,20 +7701,20 @@ declare namespace ts {
updateImportAttribute(node: ImportAttribute, name: ImportAttributeName, value: Expression): ImportAttribute;
createNamespaceImport(name: Identifier): NamespaceImport;
updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport;
- createNamespaceExport(name: Identifier): NamespaceExport;
- updateNamespaceExport(node: NamespaceExport, name: Identifier): NamespaceExport;
+ createNamespaceExport(name: ModuleExportName): NamespaceExport;
+ updateNamespaceExport(node: NamespaceExport, name: ModuleExportName): NamespaceExport;
createNamedImports(elements: readonly ImportSpecifier[]): NamedImports;
updateNamedImports(node: NamedImports, elements: readonly ImportSpecifier[]): NamedImports;
- createImportSpecifier(isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier;
- updateImportSpecifier(node: ImportSpecifier, isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier;
+ createImportSpecifier(isTypeOnly: boolean, propertyName: ModuleExportName | undefined, name: Identifier): ImportSpecifier;
+ updateImportSpecifier(node: ImportSpecifier, isTypeOnly: boolean, propertyName: ModuleExportName | undefined, name: Identifier): ImportSpecifier;
createExportAssignment(modifiers: readonly ModifierLike[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment;
updateExportAssignment(node: ExportAssignment, modifiers: readonly ModifierLike[] | undefined, expression: Expression): ExportAssignment;
createExportDeclaration(modifiers: readonly ModifierLike[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier?: Expression, attributes?: ImportAttributes): ExportDeclaration;
updateExportDeclaration(node: ExportDeclaration, modifiers: readonly ModifierLike[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier: Expression | undefined, attributes: ImportAttributes | undefined): ExportDeclaration;
createNamedExports(elements: readonly ExportSpecifier[]): NamedExports;
updateNamedExports(node: NamedExports, elements: readonly ExportSpecifier[]): NamedExports;
- createExportSpecifier(isTypeOnly: boolean, propertyName: string | Identifier | undefined, name: string | Identifier): ExportSpecifier;
- updateExportSpecifier(node: ExportSpecifier, isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier): ExportSpecifier;
+ createExportSpecifier(isTypeOnly: boolean, propertyName: string | ModuleExportName | undefined, name: string | ModuleExportName): ExportSpecifier;
+ updateExportSpecifier(node: ExportSpecifier, isTypeOnly: boolean, propertyName: ModuleExportName | undefined, name: ModuleExportName): ExportSpecifier;
createExternalModuleReference(expression: Expression): ExternalModuleReference;
updateExternalModuleReference(node: ExternalModuleReference, expression: Expression): ExternalModuleReference;
createJSDocAllType(): JSDocAllType;
@@ -8238,6 +8294,7 @@ declare namespace ts {
readonly interactiveInlayHints?: boolean;
readonly allowRenameOfImportPath?: boolean;
readonly autoImportFileExcludePatterns?: string[];
+ readonly autoImportSpecifierExcludeRegexes?: string[];
readonly preferTypeOnlyAutoImports?: boolean;
/**
* Indicates whether imports should be organized in a case-insensitive manner.
@@ -8976,6 +9033,7 @@ declare namespace ts {
function isExportDeclaration(node: Node): node is ExportDeclaration;
function isNamedExports(node: Node): node is NamedExports;
function isExportSpecifier(node: Node): node is ExportSpecifier;
+ function isModuleExportName(node: Node): node is ModuleExportName;
function isMissingDeclaration(node: Node): node is MissingDeclaration;
function isNotEmittedStatement(node: Node): node is NotEmittedStatement;
function isExternalModuleReference(node: Node): node is ExternalModuleReference;
@@ -9411,24 +9469,43 @@ declare namespace ts {
function getModeForResolutionAtIndex(file: SourceFile, index: number, compilerOptions: CompilerOptions): ResolutionMode;
/**
* Use `program.getModeForUsageLocation`, which retrieves the correct `compilerOptions`, instead of this function whenever possible.
- * Calculates the final resolution mode for a given module reference node. This is the resolution mode explicitly provided via import
- * attributes, if present, or the syntax the usage would have if emitted to JavaScript. In `--module node16` or `nodenext`, this may
- * depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the input syntax of the reference. In other
- * `module` modes, when overriding import attributes are not provided, this function returns `undefined`, as the result would have no
- * impact on module resolution, emit, or type checking.
+ * 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:
+ *
+ * ```ts
+ * // 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
+ * ```
+ *
* @param file The file the import or import-like reference is contained within
* @param usage The module reference string
* @param compilerOptions The compiler options for the program that owns the file. If the file belongs to a referenced project, the compiler options
* should be the options of the referenced project, not the referencing project.
* @returns The final resolution mode of the import
*/
- function getModeForUsageLocation(
- file: {
- impliedNodeFormat?: ResolutionMode;
- },
- usage: StringLiteralLike,
- compilerOptions: CompilerOptions,
- ): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
+ function getModeForUsageLocation(file: SourceFile, usage: StringLiteralLike, compilerOptions: CompilerOptions): ResolutionMode;
function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[];
/**
* A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the
@@ -9654,6 +9731,7 @@ declare namespace ts {
setTimeout?(callback: (...args: any[]) => void, ms: number, ...args: any[]): any;
/** If provided, will be used to reset existing delayed compilation */
clearTimeout?(timeoutId: any): void;
+ preferNonRecursiveWatch?: boolean;
}
interface ProgramHost<T extends BuilderProgram> {
/**
@@ -9776,6 +9854,7 @@ declare namespace ts {
dry?: boolean;
force?: boolean;
verbose?: boolean;
+ stopBuildOnErrors?: boolean;
incremental?: boolean;
assumeChangesOnlyAffectDirectDependencies?: boolean;
declaration?: boolean;
@@ -10743,6 +10822,10 @@ declare namespace ts {
*/
isIncomplete?: true;
entries: CompletionEntry[];
+ /**
+ * Default commit characters for the completion entries.
+ */
+ defaultCommitCharacters?: string[];
}
interface CompletionEntryDataAutoImport {
/**
@@ -10849,6 +10932,10 @@ declare namespace ts {
* is an auto-import.
*/
data?: CompletionEntryData;
+ /**
+ * If this completion entry is selected, typing a commit character will cause the entry to be accepted.
+ */
+ commitCharacters?: string[];
}
interface CompletionEntryLabelDetails {
/**