Update LKG

This commit is contained in:
Mohamed Hegazy 2018-07-06 08:52:36 -07:00
parent bb57c5a6b2
commit 7e1711dfb6
9 changed files with 1322 additions and 1006 deletions

6
lib/protocol.d.ts vendored
View File

@ -591,6 +591,12 @@ declare namespace ts.server.protocol {
interface DefinitionRequest extends FileLocationRequest {
command: CommandTypes.Definition;
}
interface DefinitionAndBoundSpanRequest extends FileLocationRequest {
readonly command: CommandTypes.DefinitionAndBoundSpan;
}
interface DefinitionAndBoundSpanResponse extends Response {
readonly body: DefinitionInfoAndBoundSpan;
}
/**
* Go to type request; value of command field is
* "typeDefinition". Return response giving the file locations that

View File

@ -17529,6 +17529,7 @@ var ts;
function isDeclarationFileName(fileName) {
return ts.fileExtensionIs(fileName, ".d.ts");
}
ts.isDeclarationFileName = isDeclarationFileName;
function processCommentPragmas(context, sourceText) {
var triviaScanner = ts.createScanner(context.languageVersion, false, 0, sourceText);
var pragmas = [];
@ -25567,17 +25568,25 @@ var ts;
function getParentOfSymbol(symbol) {
return getMergedSymbol(symbol.parent && getLateBoundSymbol(symbol.parent));
}
function getContainerOfSymbol(symbol) {
function getContainersOfSymbol(symbol, enclosingDeclaration) {
var container = getParentOfSymbol(symbol);
if (container) {
return container;
var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer);
if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920, false)) {
return ts.concatenate([container], additionalContainers);
}
return ts.append(additionalContainers, container);
}
var candidate = ts.forEach(symbol.declarations, function (d) { return !ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined; });
if (!candidate) {
var candidates = ts.mapDefined(symbol.declarations, function (d) { return !ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined; });
if (!ts.length(candidates)) {
return undefined;
}
var alias = getAliasForSymbolInContainer(candidate, symbol);
return alias ? candidate : undefined;
return ts.mapDefined(candidates, function (candidate) { return getAliasForSymbolInContainer(candidate, symbol) ? candidate : undefined; });
function fileSymbolIfFileSymbolExportEqualsContainer(d) {
var fileSymbol = getExternalModuleContainer(d);
var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=");
return resolveSymbol(exported) === resolveSymbol(container) ? fileSymbol : undefined;
}
}
function getAliasForSymbolInContainer(container, symbol) {
if (container === getParentOfSymbol(symbol)) {
@ -25801,54 +25810,67 @@ var ts;
var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67216319, false);
return access.accessibility === 0;
}
function isSymbolAccessible(symbol, enclosingDeclaration, meaning, shouldComputeAliasesToMakeVisible) {
if (symbol && enclosingDeclaration) {
var initialSymbol = symbol;
var meaningToLook = meaning;
while (symbol) {
var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, false);
if (accessibleSymbolChain) {
var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0], shouldComputeAliasesToMakeVisible);
if (!hasAccessibleDeclarations) {
return {
accessibility: 1,
errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1920) : undefined,
};
}
function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible) {
if (!ts.length(symbols))
return;
var hadAccessibleChain;
for (var _i = 0, _a = symbols; _i < _a.length; _i++) {
var symbol = _a[_i];
var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, false);
if (accessibleSymbolChain) {
hadAccessibleChain = symbol;
var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0], shouldComputeAliasesToMakeVisible);
if (hasAccessibleDeclarations) {
return hasAccessibleDeclarations;
}
else {
if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
return {
accessibility: 0
};
}
}
meaningToLook = getQualifiedLeftMeaning(meaning);
symbol = getContainerOfSymbol(symbol);
}
var symbolExternalModule = ts.forEach(initialSymbol.declarations, getExternalModuleContainer);
else {
if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
return {
accessibility: 0
};
}
}
var parentResult = isAnySymbolAccessible(getContainersOfSymbol(symbol, enclosingDeclaration), enclosingDeclaration, initialSymbol, initialSymbol === symbol ? getQualifiedLeftMeaning(meaning) : meaning, shouldComputeAliasesToMakeVisible);
if (parentResult) {
return parentResult;
}
}
if (hadAccessibleChain) {
return {
accessibility: 1,
errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920) : undefined,
};
}
}
function isSymbolAccessible(symbol, enclosingDeclaration, meaning, shouldComputeAliasesToMakeVisible) {
if (symbol && enclosingDeclaration) {
var result = isAnySymbolAccessible([symbol], enclosingDeclaration, symbol, meaning, shouldComputeAliasesToMakeVisible);
if (result) {
return result;
}
var symbolExternalModule = ts.forEach(symbol.declarations, getExternalModuleContainer);
if (symbolExternalModule) {
var enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration);
if (symbolExternalModule !== enclosingExternalModule) {
return {
accessibility: 2,
errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning),
errorModuleName: symbolToString(symbolExternalModule)
};
}
}
return {
accessibility: 1,
errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning),
};
}
return { accessibility: 0 };
function getExternalModuleContainer(declaration) {
var node = ts.findAncestor(declaration, hasExternalModuleSymbol);
return node && getSymbolOfNode(node);
}
}
function getExternalModuleContainer(declaration) {
var node = ts.findAncestor(declaration, hasExternalModuleSymbol);
return node && getSymbolOfNode(node);
}
function hasExternalModuleSymbol(declaration) {
return ts.isAmbientModule(declaration) || (declaration.kind === 277 && ts.isExternalOrCommonJsModule(declaration));
@ -26580,15 +26602,17 @@ var ts;
return chain;
function getSymbolChain(symbol, meaning, endOfChain) {
var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128));
var parentSymbol;
if (!accessibleSymbolChain ||
needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) {
var parent = getContainerOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol);
if (parent) {
var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), false);
if (parentChain) {
parentSymbol = parent;
accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]);
var parents = getContainersOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol, context.enclosingDeclaration);
if (ts.length(parents)) {
for (var _i = 0, _a = parents; _i < _a.length; _i++) {
var parent = _a[_i];
var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), false);
if (parentChain) {
accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]);
break;
}
}
}
}
@ -26596,8 +26620,10 @@ var ts;
return accessibleSymbolChain;
}
if (endOfChain ||
(yieldModuleSymbol || !(!parentSymbol && ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol))) &&
!(symbol.flags & (2048 | 4096))) {
!(symbol.flags & (2048 | 4096))) {
if (!endOfChain && !yieldModuleSymbol && !!ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
return;
}
return [symbol];
}
}
@ -27046,7 +27072,7 @@ var ts;
return !!target.resolvedReturnType;
}
if (propertyName === 4) {
var bc = target.resolvedBaseConstraint;
var bc = target.immediateBaseConstraint;
return !!bc && bc !== circularConstraintType;
}
return ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName);
@ -29137,15 +29163,21 @@ var ts;
}
return type.resolvedBaseConstraint;
function getBaseConstraint(t) {
if (t.immediateBaseConstraint) {
return t.immediateBaseConstraint === noConstraintType ? undefined : t.immediateBaseConstraint;
}
if (!pushTypeResolution(t, 4)) {
circular = true;
t.immediateBaseConstraint = circularConstraintType;
return undefined;
}
var result = computeBaseConstraint(getSimplifiedType(t));
if (!popTypeResolution()) {
circular = true;
t.immediateBaseConstraint = circularConstraintType;
return undefined;
}
t.immediateBaseConstraint = !result ? noConstraintType : result;
return result;
}
function computeBaseConstraint(t) {

File diff suppressed because it is too large Load Diff

View File

@ -3275,6 +3275,7 @@ declare namespace ts {
aliasSymbol?: Symbol;
aliasTypeArguments?: ReadonlyArray<Type>;
wildcardInstantiation?: Type;
immediateBaseConstraint?: Type;
}
interface IntrinsicType extends Type {
intrinsicName: string;
@ -7450,6 +7451,8 @@ declare namespace ts {
jsDocTypeExpression: JSDocTypeExpression;
diagnostics: Diagnostic[];
} | undefined;
/** @internal */
function isDeclarationFileName(fileName: string): boolean;
interface PragmaContext {
languageVersion: ScriptTarget;
pragmas?: PragmaMap;
@ -8822,6 +8825,16 @@ declare namespace ts {
extendedDiagnostics?: boolean;
}
function createSourceMapWriter(host: EmitHost, writer: EmitTextWriter, compilerOptions?: SourceMapOptions): SourceMapWriter;
interface SourceMapSection {
version: 3;
file: string;
sourceRoot?: string;
sources: string[];
names?: string[];
mappings: string;
sourcesContent?: (string | null)[];
sections?: undefined;
}
}
declare namespace ts {
interface CommentWriter {
@ -8985,10 +8998,14 @@ declare namespace ts {
*/
function createProgram(rootNames: ReadonlyArray<string>, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: ReadonlyArray<Diagnostic>): Program;
function parseConfigHostFromCompilerHost(host: CompilerHost): ParseConfigFileHost;
interface ResolveProjectReferencePathHost {
fileExists(fileName: string): boolean;
}
/**
* Returns the target config filename of a project reference
* Returns the target config filename of a project reference.
* Note: The file might not exist.
*/
function resolveProjectReferencePath(host: CompilerHost | UpToDateHost, ref: ProjectReference): ResolvedConfigFileName;
function resolveProjectReferencePath(host: ResolveProjectReferencePathHost, ref: ProjectReference): ResolvedConfigFileName;
/**
* Returns a DiagnosticMessage if we won't include a resolved module due to its extension.
* The DiagnosticMessage's parameters are the imported module name, and the filename it resolved to.
@ -10044,6 +10061,8 @@ declare namespace ts {
getJsxClosingTagAtPosition(fileName: string, position: number): JsxClosingTagInfo | undefined;
getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan | undefined;
toLineColumnOffset?(fileName: string, position: number): LineAndCharacter;
/** @internal */
getSourceMapper(): SourceMapper;
getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray<number>, formatOptions: FormatCodeSettings, preferences: UserPreferences): ReadonlyArray<CodeFixAction>;
getCombinedCodeFix(scope: CombinedCodeFixScope, fixId: {}, formatOptions: FormatCodeSettings, preferences: UserPreferences): CombinedCodeActions;
applyCodeActionCommand(action: CodeActionCommand): Promise<ApplyCodeActionCommandResult>;
@ -10914,6 +10933,8 @@ declare namespace ts {
function getParentNodeInSpan(node: Node | undefined, file: SourceFile, span: TextSpan): Node | undefined;
function findModifier(node: Node, kind: Modifier["kind"]): Modifier | undefined;
function insertImport(changes: textChanges.ChangeTracker, sourceFile: SourceFile, importDecl: Statement): void;
function textSpansEqual(a: TextSpan | undefined, b: TextSpan | undefined): boolean;
function documentSpansEqual(a: DocumentSpan, b: DocumentSpan): boolean;
}
declare namespace ts {
function isFirstDeclarationOfSymbolParameter(symbol: Symbol): boolean;
@ -11322,6 +11343,14 @@ declare namespace ts.SignatureHelp {
}
function getArgumentInfoForCompletions(node: Node, position: number, sourceFile: SourceFile): ArgumentInfoForCompletions | undefined;
}
declare namespace ts {
interface SourceMapper {
toLineColumnOffset(fileName: string, position: number): LineAndCharacter;
tryGetOriginalLocation(info: sourcemaps.SourceMappableLocation): sourcemaps.SourceMappableLocation | undefined;
clearCache(): void;
}
function getSourceMapper(getCanonicalFileName: GetCanonicalFileName, currentDirectory: string, log: (message: string) => void, host: LanguageServiceHost, getProgram: () => Program): SourceMapper;
}
declare namespace ts {
function computeSuggestionDiagnostics(sourceFile: SourceFile, program: Program, cancellationToken: CancellationToken): DiagnosticWithLocation[];
}
@ -12324,6 +12353,7 @@ declare namespace ts.server.protocol {
DefinitionAndBoundSpanFull = "definitionAndBoundSpan-full",
Implementation = "implementation",
ImplementationFull = "implementation-full",
EmitOutput = "emit-output",
Exit = "exit",
Format = "format",
Formatonkey = "formatonkey",
@ -12646,6 +12676,17 @@ declare namespace ts.server.protocol {
interface DefinitionRequest extends FileLocationRequest {
command: CommandTypes.Definition;
}
interface DefinitionAndBoundSpanRequest extends FileLocationRequest {
readonly command: CommandTypes.DefinitionAndBoundSpan;
}
interface DefinitionAndBoundSpanResponse extends Response {
readonly body: DefinitionInfoAndBoundSpan;
}
interface EmitOutputRequest extends FileRequest {
}
interface EmitOutputResponse extends Response {
readonly body: EmitOutput;
}
interface TypeDefinitionRequest extends FileLocationRequest {
command: CommandTypes.TypeDefinition;
}
@ -12744,6 +12785,13 @@ declare namespace ts.server.protocol {
command: CommandTypes.Rename;
arguments: RenameRequestArgs;
}
interface RenameFullRequest extends FileLocationRequest {
readonly command: CommandTypes.RenameLocationsFull;
readonly arguments: RenameRequestArgs;
}
interface RenameFullResponse extends Response {
readonly body: ReadonlyArray<RenameLocation>;
}
interface RenameInfo {
canRename: boolean;
localizedErrorMessage?: string;
@ -13634,7 +13682,7 @@ declare namespace ts.server {
getCompilerOptions(): CompilerOptions;
getNewLine(): string;
getProjectVersion(): string;
getProjectReferences(): ReadonlyArray<ProjectReference> | undefined;
getProjectReferences(): ReadonlyArray<ProjectReference>;
getScriptFileNames(): string[];
private getOrCreateScriptInfoAndAttachToProject;
getScriptKind(fileName: string): ScriptKind;
@ -13666,6 +13714,7 @@ declare namespace ts.server {
getGlobalProjectErrors(): ReadonlyArray<Diagnostic>;
getAllProjectErrors(): ReadonlyArray<Diagnostic>;
getLanguageService(ensureSynchronized?: boolean): LanguageService;
getSourceMapper(): SourceMapper;
private shouldEmitFile;
getCompileOnSaveAffectedFileList(scriptInfo: ScriptInfo): string[];
emitFile(scriptInfo: ScriptInfo, writeFile: (path: string, data: string, writeByteOrderMark?: boolean) => void): boolean;
@ -13748,7 +13797,7 @@ declare namespace ts.server {
updateGraph(): boolean;
getCachedDirectoryStructureHost(): CachedDirectoryStructureHost;
getConfigFilePath(): NormalizedPath;
getProjectReferences(): ReadonlyArray<ProjectReference> | undefined;
getProjectReferences(): ReadonlyArray<ProjectReference>;
updateReferences(refs: ReadonlyArray<ProjectReference> | undefined): void;
enablePlugins(): void;
getGlobalProjectErrors(): ReadonlyArray<Diagnostic>;
@ -14024,8 +14073,8 @@ declare namespace ts.server {
getSymlinkedProjects(info: ScriptInfo): MultiMap<Project> | undefined;
private watchClosedScriptInfo;
private stopWatchingScriptInfo;
getOrCreateScriptInfoNotOpenedByClientForNormalizedPath(fileName: NormalizedPath, currentDirectory: string, scriptKind: ScriptKind | undefined, hasMixedContent: boolean | undefined, hostToQueryFileExistsOn: DirectoryStructureHost | undefined): ScriptInfo | undefined;
getOrCreateScriptInfoOpenedByClientForNormalizedPath(fileName: NormalizedPath, currentDirectory: string, fileContent: string | undefined, scriptKind: ScriptKind | undefined, hasMixedContent: boolean | undefined): ScriptInfo | undefined;
private getOrCreateScriptInfoNotOpenedByClientForNormalizedPath;
private getOrCreateScriptInfoOpenedByClientForNormalizedPath;
getOrCreateScriptInfoForNormalizedPath(fileName: NormalizedPath, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, hostToQueryFileExistsOn?: {
fileExists(path: string): boolean;
}): ScriptInfo | undefined;
@ -14040,6 +14089,11 @@ declare namespace ts.server {
private removeRootOfInferredProjectIfNowPartOfOtherProject;
private ensureProjectForOpenFiles;
openClientFile(fileName: string, fileContent?: string, scriptKind?: ScriptKind, projectRootPath?: string): OpenConfiguredProjectResult;
getProjectForFileWithoutOpening(fileName: NormalizedPath): {
readonly scriptInfo: ScriptInfo;
readonly projects: ReadonlyArray<Project>;
} | undefined;
fileExists(fileName: NormalizedPath): boolean;
private findExternalProjectContainingOpenScriptInfo;
openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, projectRootPath?: NormalizedPath): OpenConfiguredProjectResult;
private telemetryOnOpenFile;
@ -14137,11 +14191,14 @@ declare namespace ts.server {
private convertToDiagnosticsWithLinePosition;
private getDiagnosticsWorker;
private getDefinition;
private mapDefinitionInfoLocations;
private getDefinitionAndBoundSpan;
private getEmitOutput;
private mapDefinitionInfo;
private static mapToOriginalLocation;
private toFileSpan;
private getTypeDefinition;
private mapImplementationLocations;
private getImplementation;
private getOccurrences;
private getSyntacticDiagnosticsSync;
@ -14156,6 +14213,8 @@ declare namespace ts.server {
private getProjects;
private getDefaultProject;
private getRenameLocations;
private static mapRenameInfo;
private toSpanGroups;
private getReferences;
private openClientFile;
private getPosition;
@ -14194,6 +14253,7 @@ declare namespace ts.server {
private toLocationTextSpan;
private getNavigationTree;
private getNavigateToItems;
private getFullNavigateToItems;
private getSupportedCodeFixes;
private isLocation;
private extractPositionAndRange;

8
lib/typescript.d.ts vendored
View File

@ -4155,10 +4155,14 @@ declare namespace ts {
* @returns A 'Program' object.
*/
function createProgram(rootNames: ReadonlyArray<string>, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: ReadonlyArray<Diagnostic>): Program;
interface ResolveProjectReferencePathHost {
fileExists(fileName: string): boolean;
}
/**
* Returns the target config filename of a project reference
* Returns the target config filename of a project reference.
* Note: The file might not exist.
*/
function resolveProjectReferencePath(host: CompilerHost | UpToDateHost, ref: ProjectReference): ResolvedConfigFileName;
function resolveProjectReferencePath(host: ResolveProjectReferencePathHost, ref: ProjectReference): ResolvedConfigFileName;
}
declare namespace ts {
interface EmitOutput {

View File

@ -21873,9 +21873,11 @@ var ts;
InvalidPosition[InvalidPosition["Value"] = -1] = "Value";
})(InvalidPosition || (InvalidPosition = {}));
})(IncrementalParser || (IncrementalParser = {}));
/** @internal */
function isDeclarationFileName(fileName) {
return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */);
}
ts.isDeclarationFileName = isDeclarationFileName;
/*@internal*/
function processCommentPragmas(context, sourceText) {
var triviaScanner = ts.createScanner(context.languageVersion, /*skipTrivia*/ false, 0 /* Standard */, sourceText);
@ -29647,7 +29649,7 @@ var ts;
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType";
TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType";
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType";
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstraint"] = 4] = "ResolvedBaseConstraint";
TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint";
})(TypeSystemPropertyName || (TypeSystemPropertyName = {}));
var CheckMode;
(function (CheckMode) {
@ -31354,17 +31356,25 @@ var ts;
* Attempts to find the symbol corresponding to the container a symbol is in - usually this
* is just its' `.parent`, but for locals, this value is `undefined`
*/
function getContainerOfSymbol(symbol) {
function getContainersOfSymbol(symbol, enclosingDeclaration) {
var container = getParentOfSymbol(symbol);
if (container) {
return container;
var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer);
if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) {
return ts.concatenate([container], additionalContainers); // This order expresses a preference for the real container if it is in scope
}
return ts.append(additionalContainers, container);
}
var candidate = ts.forEach(symbol.declarations, function (d) { return !ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined; });
if (!candidate) {
var candidates = ts.mapDefined(symbol.declarations, function (d) { return !ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined; });
if (!ts.length(candidates)) {
return undefined;
}
var alias = getAliasForSymbolInContainer(candidate, symbol);
return alias ? candidate : undefined;
return ts.mapDefined(candidates, function (candidate) { return getAliasForSymbolInContainer(candidate, symbol) ? candidate : undefined; });
function fileSymbolIfFileSymbolExportEqualsContainer(d) {
var fileSymbol = getExternalModuleContainer(d);
var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */);
return resolveSymbol(exported) === resolveSymbol(container) ? fileSymbol : undefined;
}
}
function getAliasForSymbolInContainer(container, symbol) {
if (container === getParentOfSymbol(symbol)) {
@ -31615,6 +31625,54 @@ var ts;
var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67216319 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false);
return access.accessibility === 0 /* Accessible */;
}
function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible) {
if (!ts.length(symbols))
return;
var hadAccessibleChain;
for (var _i = 0, _a = symbols; _i < _a.length; _i++) {
var symbol = _a[_i];
// Symbol is accessible if it by itself is accessible
var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, /*useOnlyExternalAliasing*/ false);
if (accessibleSymbolChain) {
hadAccessibleChain = symbol;
var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0], shouldComputeAliasesToMakeVisible);
if (hasAccessibleDeclarations) {
return hasAccessibleDeclarations;
}
}
else {
if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
// Any meaning of a module symbol is always accessible via an `import` type
return {
accessibility: 0 /* Accessible */
};
}
}
// If we haven't got the accessible symbol, it doesn't mean the symbol is actually inaccessible.
// It could be a qualified symbol and hence verify the path
// e.g.:
// module m {
// export class c {
// }
// }
// const x: typeof m.c
// In the above example when we start with checking if typeof m.c symbol is accessible,
// we are going to see if c can be accessed in scope directly.
// But it can't, hence the accessible is going to be undefined, but that doesn't mean m.c is inaccessible
// It is accessible if the parent m is accessible because then m.c can be accessed through qualification
var parentResult = isAnySymbolAccessible(getContainersOfSymbol(symbol, enclosingDeclaration), enclosingDeclaration, initialSymbol, initialSymbol === symbol ? getQualifiedLeftMeaning(meaning) : meaning, shouldComputeAliasesToMakeVisible);
if (parentResult) {
return parentResult;
}
}
if (hadAccessibleChain) {
return {
accessibility: 1 /* NotAccessible */,
errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920 /* Namespace */) : undefined,
};
}
}
/**
* Check if the given symbol in given enclosing declaration is accessible and mark all associated alias to be visible if requested
*
@ -31625,55 +31683,20 @@ var ts;
*/
function isSymbolAccessible(symbol, enclosingDeclaration, meaning, shouldComputeAliasesToMakeVisible) {
if (symbol && enclosingDeclaration) {
var initialSymbol = symbol;
var meaningToLook = meaning;
while (symbol) {
// Symbol is accessible if it by itself is accessible
var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, /*useOnlyExternalAliasing*/ false);
if (accessibleSymbolChain) {
var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0], shouldComputeAliasesToMakeVisible);
if (!hasAccessibleDeclarations) {
return {
accessibility: 1 /* NotAccessible */,
errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1920 /* Namespace */) : undefined,
};
}
return hasAccessibleDeclarations;
}
else {
if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
// Any meaning of a module symbol is always accessible via an `import` type
return {
accessibility: 0 /* Accessible */
};
}
}
// If we haven't got the accessible symbol, it doesn't mean the symbol is actually inaccessible.
// It could be a qualified symbol and hence verify the path
// e.g.:
// module m {
// export class c {
// }
// }
// const x: typeof m.c
// In the above example when we start with checking if typeof m.c symbol is accessible,
// we are going to see if c can be accessed in scope directly.
// But it can't, hence the accessible is going to be undefined, but that doesn't mean m.c is inaccessible
// It is accessible if the parent m is accessible because then m.c can be accessed through qualification
meaningToLook = getQualifiedLeftMeaning(meaning);
symbol = getContainerOfSymbol(symbol);
var result = isAnySymbolAccessible([symbol], enclosingDeclaration, symbol, meaning, shouldComputeAliasesToMakeVisible);
if (result) {
return result;
}
// This could be a symbol that is not exported in the external module
// or it could be a symbol from different external module that is not aliased and hence cannot be named
var symbolExternalModule = ts.forEach(initialSymbol.declarations, getExternalModuleContainer);
var symbolExternalModule = ts.forEach(symbol.declarations, getExternalModuleContainer);
if (symbolExternalModule) {
var enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration);
if (symbolExternalModule !== enclosingExternalModule) {
// name from different external module that is not visible
return {
accessibility: 2 /* CannotBeNamed */,
errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning),
errorModuleName: symbolToString(symbolExternalModule)
};
}
@ -31681,14 +31704,14 @@ var ts;
// Just a local name that is not accessible
return {
accessibility: 1 /* NotAccessible */,
errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning),
};
}
return { accessibility: 0 /* Accessible */ };
function getExternalModuleContainer(declaration) {
var node = ts.findAncestor(declaration, hasExternalModuleSymbol);
return node && getSymbolOfNode(node);
}
}
function getExternalModuleContainer(declaration) {
var node = ts.findAncestor(declaration, hasExternalModuleSymbol);
return node && getSymbolOfNode(node);
}
function hasExternalModuleSymbol(declaration) {
return ts.isAmbientModule(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration));
@ -32465,16 +32488,18 @@ var ts;
/** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */
function getSymbolChain(symbol, meaning, endOfChain) {
var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* UseOnlyExternalAliasing */));
var parentSymbol;
if (!accessibleSymbolChain ||
needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) {
// Go up and add our parent.
var parent = getContainerOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol);
if (parent) {
var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false);
if (parentChain) {
parentSymbol = parent;
accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]);
var parents = getContainersOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol, context.enclosingDeclaration);
if (ts.length(parents)) {
for (var _i = 0, _a = parents; _i < _a.length; _i++) {
var parent = _a[_i];
var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false);
if (parentChain) {
accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]);
break;
}
}
}
}
@ -32484,10 +32509,12 @@ var ts;
if (
// If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols.
endOfChain ||
// If a parent symbol is an anonymous type, don't write it.
!(symbol.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) {
// If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.)
(yieldModuleSymbol || !(!parentSymbol && ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol))) &&
// If a parent symbol is an anonymous type, don't write it.
!(symbol.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) {
if (!endOfChain && !yieldModuleSymbol && !!ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
return;
}
return [symbol];
}
}
@ -32981,8 +33008,8 @@ var ts;
if (propertyName === 3 /* ResolvedReturnType */) {
return !!target.resolvedReturnType;
}
if (propertyName === 4 /* ResolvedBaseConstraint */) {
var bc = target.resolvedBaseConstraint;
if (propertyName === 4 /* ImmediateBaseConstraint */) {
var bc = target.immediateBaseConstraint;
return !!bc && bc !== circularConstraintType;
}
return ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName);
@ -35415,15 +35442,21 @@ var ts;
}
return type.resolvedBaseConstraint;
function getBaseConstraint(t) {
if (!pushTypeResolution(t, 4 /* ResolvedBaseConstraint */)) {
if (t.immediateBaseConstraint) {
return t.immediateBaseConstraint === noConstraintType ? undefined : t.immediateBaseConstraint;
}
if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) {
circular = true;
t.immediateBaseConstraint = circularConstraintType;
return undefined;
}
var result = computeBaseConstraint(getSimplifiedType(t));
if (!popTypeResolution()) {
circular = true;
t.immediateBaseConstraint = circularConstraintType;
return undefined;
}
t.immediateBaseConstraint = !result ? noConstraintType : result;
return result;
}
function computeBaseConstraint(t) {
@ -84139,7 +84172,8 @@ var ts;
}
ts.parseConfigHostFromCompilerHost = parseConfigHostFromCompilerHost;
/**
* Returns the target config filename of a project reference
* Returns the target config filename of a project reference.
* Note: The file might not exist.
*/
function resolveProjectReferencePath(host, ref) {
if (!host.fileExists(ref.path)) {
@ -89463,6 +89497,14 @@ var ts;
}
}
ts.insertImport = insertImport;
function textSpansEqual(a, b) {
return !!a && !!b && a.start === b.start && a.length === b.length;
}
ts.textSpansEqual = textSpansEqual;
function documentSpansEqual(a, b) {
return a.fileName === b.fileName && textSpansEqual(a.textSpan, b.textSpan);
}
ts.documentSpansEqual = documentSpansEqual;
})(ts || (ts = {}));
// Display-part writer helpers
/* @internal */
@ -96111,48 +96153,83 @@ var ts;
var JsDoc;
(function (JsDoc) {
var jsDocTagNames = [
"abstract",
"access",
"alias",
"argument",
"async",
"augments",
"author",
"argument",
"borrows",
"callback",
"class",
"classDesc",
"constant",
"constructor",
"constructs",
"copyright",
"default",
"deprecated",
"description",
"emits",
"enum",
"event",
"example",
"exports",
"extends",
"external",
"field",
"file",
"fileOverview",
"fires",
"function",
"generator",
"global",
"hideConstructor",
"host",
"ignore",
"implements",
"inheritDoc",
"inner",
"instance",
"interface",
"kind",
"lends",
"link",
"license",
"listens",
"member",
"memberOf",
"method",
"mixes",
"module",
"name",
"namespace",
"override",
"package",
"param",
"private",
"prop",
"property",
"protected",
"public",
"readonly",
"requires",
"returns",
"see",
"since",
"static",
"summary",
"template",
"this",
"throws",
"todo",
"tutorial",
"type",
"typedef",
"version"
"var",
"variation",
"version",
"virtual",
"yields"
];
var jsDocTagNameCompletionEntries;
var jsDocTagCompletionEntries;
@ -96474,7 +96551,7 @@ var ts;
var rawItems = [];
var _loop_15 = function (sourceFile) {
cancellationToken.throwIfCancellationRequested();
if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */)) {
if (excludeDtsFiles && sourceFile.isDeclarationFile) {
return "continue";
}
sourceFile.getNamedDeclarations().forEach(function (declarations, name) {
@ -99032,6 +99109,106 @@ var ts;
})(ts || (ts = {}));
/* @internal */
var ts;
(function (ts) {
// Sometimes tools can sometimes see the following line as a source mapping url comment, so we mangle it a bit (the [M])
var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/;
var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/;
var base64UrlRegExp = /^data:(?:application\/json(?:;charset=[uU][tT][fF]-8);base64,([A-Za-z0-9+\/=]+)$)?/;
function getSourceMapper(getCanonicalFileName, currentDirectory, log, host, getProgram) {
var sourcemappedFileCache;
return { tryGetOriginalLocation: tryGetOriginalLocation, toLineColumnOffset: toLineColumnOffset, clearCache: clearCache };
function scanForSourcemapURL(fileName) {
var mappedFile = sourcemappedFileCache.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName));
if (!mappedFile) {
return;
}
var starts = ts.getLineStarts(mappedFile);
for (var index = starts.length - 1; index >= 0; index--) {
var lineText = mappedFile.text.substring(starts[index], starts[index + 1]);
var comment = sourceMapCommentRegExp.exec(lineText);
if (comment) {
return comment[1];
}
// If we see a non-whitespace/map comment-like line, break, to avoid scanning up the entire file
else if (!lineText.match(whitespaceOrMapCommentRegExp)) {
break;
}
}
}
function convertDocumentToSourceMapper(file, contents, mapFileName) {
var maps;
try {
maps = JSON.parse(contents);
}
catch (_a) {
// swallow error
}
if (!maps || !maps.sources || !maps.file || !maps.mappings) {
// obviously invalid map
return file.sourceMapper = ts.sourcemaps.identitySourceMapper;
}
return file.sourceMapper = ts.sourcemaps.decode({
readFile: function (s) { return host.readFile(s); },
fileExists: function (s) { return host.fileExists(s); },
getCanonicalFileName: getCanonicalFileName,
log: log,
}, mapFileName, maps, getProgram(), sourcemappedFileCache);
}
function getSourceMapper(fileName, file) {
if (!host.readFile || !host.fileExists) {
return file.sourceMapper = ts.sourcemaps.identitySourceMapper;
}
if (file.sourceMapper) {
return file.sourceMapper;
}
var mapFileName = scanForSourcemapURL(fileName);
if (mapFileName) {
var match = base64UrlRegExp.exec(mapFileName);
if (match) {
if (match[1]) {
var base64Object = match[1];
return convertDocumentToSourceMapper(file, ts.base64decode(ts.sys, base64Object), fileName);
}
// Not a data URL we can parse, skip it
mapFileName = undefined;
}
}
var possibleMapLocations = [];
if (mapFileName) {
possibleMapLocations.push(mapFileName);
}
possibleMapLocations.push(fileName + ".map");
for (var _i = 0, possibleMapLocations_1 = possibleMapLocations; _i < possibleMapLocations_1.length; _i++) {
var location = possibleMapLocations_1[_i];
var mapPath = ts.toPath(location, ts.getDirectoryPath(fileName), getCanonicalFileName);
if (host.fileExists(mapPath)) {
return convertDocumentToSourceMapper(file, host.readFile(mapPath), mapPath); // TODO: GH#18217
}
}
return file.sourceMapper = ts.sourcemaps.identitySourceMapper;
}
function tryGetOriginalLocation(info) {
if (!ts.isDeclarationFileName(info.fileName))
return undefined;
var file = getProgram().getSourceFile(info.fileName) || sourcemappedFileCache.get(ts.toPath(info.fileName, currentDirectory, getCanonicalFileName));
if (!file)
return undefined;
var newLoc = getSourceMapper(info.fileName, file).getOriginalPosition(info);
return newLoc === info ? undefined : tryGetOriginalLocation(newLoc) || newLoc;
}
function toLineColumnOffset(fileName, position) {
var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
var file = getProgram().getSourceFile(path) || sourcemappedFileCache.get(path); // TODO: GH#18217
return file.getLineAndCharacterOfPosition(position);
}
function clearCache() {
sourcemappedFileCache = ts.createSourceFileLikeCache(host);
}
}
ts.getSourceMapper = getSourceMapper;
})(ts || (ts = {}));
/* @internal */
var ts;
(function (ts) {
function computeSuggestionDiagnostics(sourceFile, program, cancellationToken) {
program.getSemanticDiagnostics(sourceFile, cancellationToken);
@ -110871,7 +111048,6 @@ var ts;
if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) {
ts.localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages();
}
var sourcemappedFileCache;
function log(message) {
if (host.log) {
host.log(message);
@ -110879,6 +111055,7 @@ var ts;
}
var useCaseSensitiveFileNames = ts.hostUsesCaseSensitiveFileNames(host);
var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
var sourceMapper = ts.getSourceMapper(getCanonicalFileName, currentDirectory, log, host, function () { return program; });
function getValidSourceFile(fileName) {
var sourceFile = program.getSourceFile(fileName);
if (!sourceFile) {
@ -110976,7 +111153,7 @@ var ts;
// We reset this cache on structure invalidation so we don't hold on to outdated files for long; however we can't use the `compilerHost` above,
// Because it only functions until `hostCache` is cleared, while we'll potentially need the functionality to lazily read sourcemap files during
// the course of whatever called `synchronizeHostData`
sourcemappedFileCache = ts.createSourceFileLikeCache(host);
sourceMapper.clearCache();
// Make sure all the nodes in the program are both bound, and have their parent
// pointers set property.
program.getTypeChecker();
@ -111175,165 +111352,23 @@ var ts;
}
return checker.getSymbolAtLocation(node);
}
function toLineColumnOffset(fileName, position) {
var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
var file = program.getSourceFile(path) || sourcemappedFileCache.get(path); // TODO: GH#18217
return file.getLineAndCharacterOfPosition(position);
}
// Sometimes tools can sometimes see the following line as a source mapping url comment, so we mangle it a bit (the [M])
var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/;
var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/;
var base64UrlRegExp = /^data:(?:application\/json(?:;charset=[uU][tT][fF]-8);base64,([A-Za-z0-9+\/=]+)$)?/;
function scanForSourcemapURL(fileName) {
var mappedFile = sourcemappedFileCache.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName));
if (!mappedFile) {
return;
}
var starts = ts.getLineStarts(mappedFile);
for (var index = starts.length - 1; index >= 0; index--) {
var lineText = mappedFile.text.substring(starts[index], starts[index + 1]);
var comment = sourceMapCommentRegExp.exec(lineText);
if (comment) {
return comment[1];
}
// If we see a nonwhitespace/map comment-like line, break, to avoid scanning up the entire file
else if (!lineText.match(whitespaceOrMapCommentRegExp)) {
break;
}
}
}
function convertDocumentToSourceMapper(file, contents, mapFileName) {
var maps;
try {
maps = JSON.parse(contents);
}
catch (_a) {
// swallow error
}
if (!maps || !maps.sources || !maps.file || !maps.mappings) {
// obviously invalid map
return file.sourceMapper = ts.sourcemaps.identitySourceMapper;
}
return file.sourceMapper = ts.sourcemaps.decode({
readFile: function (s) { return host.readFile(s); },
fileExists: function (s) { return host.fileExists(s); },
getCanonicalFileName: getCanonicalFileName,
log: log,
}, mapFileName, maps, program, sourcemappedFileCache);
}
function getSourceMapper(fileName, file) {
if (!host.readFile || !host.fileExists) {
return file.sourceMapper = ts.sourcemaps.identitySourceMapper;
}
if (file.sourceMapper) {
return file.sourceMapper;
}
var mapFileName = scanForSourcemapURL(fileName);
if (mapFileName) {
var match = base64UrlRegExp.exec(mapFileName);
if (match) {
if (match[1]) {
var base64Object = match[1];
return convertDocumentToSourceMapper(file, ts.base64decode(ts.sys, base64Object), fileName);
}
// Not a data URL we can parse, skip it
mapFileName = undefined;
}
}
var possibleMapLocations = [];
if (mapFileName) {
possibleMapLocations.push(mapFileName);
}
possibleMapLocations.push(fileName + ".map");
for (var _i = 0, possibleMapLocations_1 = possibleMapLocations; _i < possibleMapLocations_1.length; _i++) {
var location = possibleMapLocations_1[_i];
var mapPath = ts.toPath(location, ts.getDirectoryPath(fileName), getCanonicalFileName);
if (host.fileExists(mapPath)) {
return convertDocumentToSourceMapper(file, host.readFile(mapPath), mapPath); // TODO: GH#18217
}
}
return file.sourceMapper = ts.sourcemaps.identitySourceMapper;
}
function makeGetTargetOfMappedPosition(extract, create) {
return getTargetOfMappedPosition;
function getTargetOfMappedPosition(input, original) {
if (original === void 0) { original = input; }
var info = extract(input);
if (ts.endsWith(info.fileName, ".d.ts" /* Dts */)) {
var file = program.getSourceFile(info.fileName);
if (!file) {
var path = ts.toPath(info.fileName, currentDirectory, getCanonicalFileName);
file = sourcemappedFileCache.get(path);
}
if (!file) {
return input;
}
var mapper = getSourceMapper(info.fileName, file);
var newLoc = mapper.getOriginalPosition(info);
if (newLoc === info)
return input;
return getTargetOfMappedPosition(create(newLoc, input, original), original);
}
return input;
}
}
var getTargetOfMappedDeclarationInfo = makeGetTargetOfMappedPosition(function (info) { return ({ fileName: info.fileName, position: info.textSpan.start }); }, function (newLoc, info, original) { return ({
containerKind: info.containerKind,
containerName: info.containerName,
fileName: newLoc.fileName,
kind: info.kind,
name: info.name,
textSpan: {
start: newLoc.position,
length: info.textSpan.length
},
originalFileName: original.fileName,
originalTextSpan: original.textSpan
}); });
function getTargetOfMappedDeclarationFiles(infos) {
return ts.map(infos, function (d) { return getTargetOfMappedDeclarationInfo(d); });
}
/// Goto definition
function getDefinitionAtPosition(fileName, position) {
synchronizeHostData();
return getTargetOfMappedDeclarationFiles(ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position));
return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position);
}
function getDefinitionAndBoundSpan(fileName, position) {
synchronizeHostData();
var result = ts.GoToDefinition.getDefinitionAndBoundSpan(program, getValidSourceFile(fileName), position);
if (!result)
return result;
var mappedDefs = getTargetOfMappedDeclarationFiles(result.definitions);
if (mappedDefs === result.definitions) {
return result;
}
return {
definitions: mappedDefs,
textSpan: result.textSpan
};
return ts.GoToDefinition.getDefinitionAndBoundSpan(program, getValidSourceFile(fileName), position);
}
function getTypeDefinitionAtPosition(fileName, position) {
synchronizeHostData();
return getTargetOfMappedDeclarationFiles(ts.GoToDefinition.getTypeDefinitionAtPosition(program.getTypeChecker(), getValidSourceFile(fileName), position));
return ts.GoToDefinition.getTypeDefinitionAtPosition(program.getTypeChecker(), getValidSourceFile(fileName), position);
}
/// Goto implementation
var getTargetOfMappedImplementationLocation = makeGetTargetOfMappedPosition(function (info) { return ({ fileName: info.fileName, position: info.textSpan.start }); }, function (newLoc, info) { return ({
fileName: newLoc.fileName,
kind: info.kind,
displayParts: info.displayParts,
textSpan: {
start: newLoc.position,
length: info.textSpan.length
},
originalFileName: info.fileName,
originalTextSpan: info.textSpan
}); });
function getTargetOfMappedImplementationLocations(infos) {
return ts.map(infos, function (d) { return getTargetOfMappedImplementationLocation(d); });
}
function getImplementationAtPosition(fileName, position) {
synchronizeHostData();
return getTargetOfMappedImplementationLocations(ts.FindAllReferences.getImplementationsAtPosition(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position));
return ts.FindAllReferences.getImplementationsAtPosition(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position);
}
/// References and Occurrences
function getOccurrencesAtPosition(fileName, position) {
@ -111384,7 +111419,6 @@ var ts;
synchronizeHostData();
return ts.FindAllReferences.findReferencedSymbols(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position);
}
/// NavigateTo
function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) {
if (excludeDtsFiles === void 0) { excludeDtsFiles = false; }
synchronizeHostData();
@ -111854,7 +111888,8 @@ var ts;
getProgram: getProgram,
getApplicableRefactors: getApplicableRefactors,
getEditsForRefactor: getEditsForRefactor,
toLineColumnOffset: toLineColumnOffset
toLineColumnOffset: sourceMapper.toLineColumnOffset,
getSourceMapper: function () { return sourceMapper; },
};
}
ts.createLanguageService = createLanguageService;

View File

@ -4155,10 +4155,14 @@ declare namespace ts {
* @returns A 'Program' object.
*/
function createProgram(rootNames: ReadonlyArray<string>, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: ReadonlyArray<Diagnostic>): Program;
interface ResolveProjectReferencePathHost {
fileExists(fileName: string): boolean;
}
/**
* Returns the target config filename of a project reference
* Returns the target config filename of a project reference.
* Note: The file might not exist.
*/
function resolveProjectReferencePath(host: CompilerHost | UpToDateHost, ref: ProjectReference): ResolvedConfigFileName;
function resolveProjectReferencePath(host: ResolveProjectReferencePathHost, ref: ProjectReference): ResolvedConfigFileName;
}
declare namespace ts {
interface EmitOutput {

View File

@ -21873,9 +21873,11 @@ var ts;
InvalidPosition[InvalidPosition["Value"] = -1] = "Value";
})(InvalidPosition || (InvalidPosition = {}));
})(IncrementalParser || (IncrementalParser = {}));
/** @internal */
function isDeclarationFileName(fileName) {
return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */);
}
ts.isDeclarationFileName = isDeclarationFileName;
/*@internal*/
function processCommentPragmas(context, sourceText) {
var triviaScanner = ts.createScanner(context.languageVersion, /*skipTrivia*/ false, 0 /* Standard */, sourceText);
@ -29647,7 +29649,7 @@ var ts;
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType";
TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType";
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType";
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstraint"] = 4] = "ResolvedBaseConstraint";
TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint";
})(TypeSystemPropertyName || (TypeSystemPropertyName = {}));
var CheckMode;
(function (CheckMode) {
@ -31354,17 +31356,25 @@ var ts;
* Attempts to find the symbol corresponding to the container a symbol is in - usually this
* is just its' `.parent`, but for locals, this value is `undefined`
*/
function getContainerOfSymbol(symbol) {
function getContainersOfSymbol(symbol, enclosingDeclaration) {
var container = getParentOfSymbol(symbol);
if (container) {
return container;
var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer);
if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) {
return ts.concatenate([container], additionalContainers); // This order expresses a preference for the real container if it is in scope
}
return ts.append(additionalContainers, container);
}
var candidate = ts.forEach(symbol.declarations, function (d) { return !ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined; });
if (!candidate) {
var candidates = ts.mapDefined(symbol.declarations, function (d) { return !ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined; });
if (!ts.length(candidates)) {
return undefined;
}
var alias = getAliasForSymbolInContainer(candidate, symbol);
return alias ? candidate : undefined;
return ts.mapDefined(candidates, function (candidate) { return getAliasForSymbolInContainer(candidate, symbol) ? candidate : undefined; });
function fileSymbolIfFileSymbolExportEqualsContainer(d) {
var fileSymbol = getExternalModuleContainer(d);
var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */);
return resolveSymbol(exported) === resolveSymbol(container) ? fileSymbol : undefined;
}
}
function getAliasForSymbolInContainer(container, symbol) {
if (container === getParentOfSymbol(symbol)) {
@ -31615,6 +31625,54 @@ var ts;
var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67216319 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false);
return access.accessibility === 0 /* Accessible */;
}
function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible) {
if (!ts.length(symbols))
return;
var hadAccessibleChain;
for (var _i = 0, _a = symbols; _i < _a.length; _i++) {
var symbol = _a[_i];
// Symbol is accessible if it by itself is accessible
var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, /*useOnlyExternalAliasing*/ false);
if (accessibleSymbolChain) {
hadAccessibleChain = symbol;
var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0], shouldComputeAliasesToMakeVisible);
if (hasAccessibleDeclarations) {
return hasAccessibleDeclarations;
}
}
else {
if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
// Any meaning of a module symbol is always accessible via an `import` type
return {
accessibility: 0 /* Accessible */
};
}
}
// If we haven't got the accessible symbol, it doesn't mean the symbol is actually inaccessible.
// It could be a qualified symbol and hence verify the path
// e.g.:
// module m {
// export class c {
// }
// }
// const x: typeof m.c
// In the above example when we start with checking if typeof m.c symbol is accessible,
// we are going to see if c can be accessed in scope directly.
// But it can't, hence the accessible is going to be undefined, but that doesn't mean m.c is inaccessible
// It is accessible if the parent m is accessible because then m.c can be accessed through qualification
var parentResult = isAnySymbolAccessible(getContainersOfSymbol(symbol, enclosingDeclaration), enclosingDeclaration, initialSymbol, initialSymbol === symbol ? getQualifiedLeftMeaning(meaning) : meaning, shouldComputeAliasesToMakeVisible);
if (parentResult) {
return parentResult;
}
}
if (hadAccessibleChain) {
return {
accessibility: 1 /* NotAccessible */,
errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920 /* Namespace */) : undefined,
};
}
}
/**
* Check if the given symbol in given enclosing declaration is accessible and mark all associated alias to be visible if requested
*
@ -31625,55 +31683,20 @@ var ts;
*/
function isSymbolAccessible(symbol, enclosingDeclaration, meaning, shouldComputeAliasesToMakeVisible) {
if (symbol && enclosingDeclaration) {
var initialSymbol = symbol;
var meaningToLook = meaning;
while (symbol) {
// Symbol is accessible if it by itself is accessible
var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, /*useOnlyExternalAliasing*/ false);
if (accessibleSymbolChain) {
var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0], shouldComputeAliasesToMakeVisible);
if (!hasAccessibleDeclarations) {
return {
accessibility: 1 /* NotAccessible */,
errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1920 /* Namespace */) : undefined,
};
}
return hasAccessibleDeclarations;
}
else {
if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
// Any meaning of a module symbol is always accessible via an `import` type
return {
accessibility: 0 /* Accessible */
};
}
}
// If we haven't got the accessible symbol, it doesn't mean the symbol is actually inaccessible.
// It could be a qualified symbol and hence verify the path
// e.g.:
// module m {
// export class c {
// }
// }
// const x: typeof m.c
// In the above example when we start with checking if typeof m.c symbol is accessible,
// we are going to see if c can be accessed in scope directly.
// But it can't, hence the accessible is going to be undefined, but that doesn't mean m.c is inaccessible
// It is accessible if the parent m is accessible because then m.c can be accessed through qualification
meaningToLook = getQualifiedLeftMeaning(meaning);
symbol = getContainerOfSymbol(symbol);
var result = isAnySymbolAccessible([symbol], enclosingDeclaration, symbol, meaning, shouldComputeAliasesToMakeVisible);
if (result) {
return result;
}
// This could be a symbol that is not exported in the external module
// or it could be a symbol from different external module that is not aliased and hence cannot be named
var symbolExternalModule = ts.forEach(initialSymbol.declarations, getExternalModuleContainer);
var symbolExternalModule = ts.forEach(symbol.declarations, getExternalModuleContainer);
if (symbolExternalModule) {
var enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration);
if (symbolExternalModule !== enclosingExternalModule) {
// name from different external module that is not visible
return {
accessibility: 2 /* CannotBeNamed */,
errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning),
errorModuleName: symbolToString(symbolExternalModule)
};
}
@ -31681,14 +31704,14 @@ var ts;
// Just a local name that is not accessible
return {
accessibility: 1 /* NotAccessible */,
errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning),
};
}
return { accessibility: 0 /* Accessible */ };
function getExternalModuleContainer(declaration) {
var node = ts.findAncestor(declaration, hasExternalModuleSymbol);
return node && getSymbolOfNode(node);
}
}
function getExternalModuleContainer(declaration) {
var node = ts.findAncestor(declaration, hasExternalModuleSymbol);
return node && getSymbolOfNode(node);
}
function hasExternalModuleSymbol(declaration) {
return ts.isAmbientModule(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration));
@ -32465,16 +32488,18 @@ var ts;
/** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */
function getSymbolChain(symbol, meaning, endOfChain) {
var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* UseOnlyExternalAliasing */));
var parentSymbol;
if (!accessibleSymbolChain ||
needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) {
// Go up and add our parent.
var parent = getContainerOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol);
if (parent) {
var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false);
if (parentChain) {
parentSymbol = parent;
accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]);
var parents = getContainersOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol, context.enclosingDeclaration);
if (ts.length(parents)) {
for (var _i = 0, _a = parents; _i < _a.length; _i++) {
var parent = _a[_i];
var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false);
if (parentChain) {
accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]);
break;
}
}
}
}
@ -32484,10 +32509,12 @@ var ts;
if (
// If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols.
endOfChain ||
// If a parent symbol is an anonymous type, don't write it.
!(symbol.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) {
// If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.)
(yieldModuleSymbol || !(!parentSymbol && ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol))) &&
// If a parent symbol is an anonymous type, don't write it.
!(symbol.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) {
if (!endOfChain && !yieldModuleSymbol && !!ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
return;
}
return [symbol];
}
}
@ -32981,8 +33008,8 @@ var ts;
if (propertyName === 3 /* ResolvedReturnType */) {
return !!target.resolvedReturnType;
}
if (propertyName === 4 /* ResolvedBaseConstraint */) {
var bc = target.resolvedBaseConstraint;
if (propertyName === 4 /* ImmediateBaseConstraint */) {
var bc = target.immediateBaseConstraint;
return !!bc && bc !== circularConstraintType;
}
return ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName);
@ -35415,15 +35442,21 @@ var ts;
}
return type.resolvedBaseConstraint;
function getBaseConstraint(t) {
if (!pushTypeResolution(t, 4 /* ResolvedBaseConstraint */)) {
if (t.immediateBaseConstraint) {
return t.immediateBaseConstraint === noConstraintType ? undefined : t.immediateBaseConstraint;
}
if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) {
circular = true;
t.immediateBaseConstraint = circularConstraintType;
return undefined;
}
var result = computeBaseConstraint(getSimplifiedType(t));
if (!popTypeResolution()) {
circular = true;
t.immediateBaseConstraint = circularConstraintType;
return undefined;
}
t.immediateBaseConstraint = !result ? noConstraintType : result;
return result;
}
function computeBaseConstraint(t) {
@ -84139,7 +84172,8 @@ var ts;
}
ts.parseConfigHostFromCompilerHost = parseConfigHostFromCompilerHost;
/**
* Returns the target config filename of a project reference
* Returns the target config filename of a project reference.
* Note: The file might not exist.
*/
function resolveProjectReferencePath(host, ref) {
if (!host.fileExists(ref.path)) {
@ -89463,6 +89497,14 @@ var ts;
}
}
ts.insertImport = insertImport;
function textSpansEqual(a, b) {
return !!a && !!b && a.start === b.start && a.length === b.length;
}
ts.textSpansEqual = textSpansEqual;
function documentSpansEqual(a, b) {
return a.fileName === b.fileName && textSpansEqual(a.textSpan, b.textSpan);
}
ts.documentSpansEqual = documentSpansEqual;
})(ts || (ts = {}));
// Display-part writer helpers
/* @internal */
@ -96111,48 +96153,83 @@ var ts;
var JsDoc;
(function (JsDoc) {
var jsDocTagNames = [
"abstract",
"access",
"alias",
"argument",
"async",
"augments",
"author",
"argument",
"borrows",
"callback",
"class",
"classDesc",
"constant",
"constructor",
"constructs",
"copyright",
"default",
"deprecated",
"description",
"emits",
"enum",
"event",
"example",
"exports",
"extends",
"external",
"field",
"file",
"fileOverview",
"fires",
"function",
"generator",
"global",
"hideConstructor",
"host",
"ignore",
"implements",
"inheritDoc",
"inner",
"instance",
"interface",
"kind",
"lends",
"link",
"license",
"listens",
"member",
"memberOf",
"method",
"mixes",
"module",
"name",
"namespace",
"override",
"package",
"param",
"private",
"prop",
"property",
"protected",
"public",
"readonly",
"requires",
"returns",
"see",
"since",
"static",
"summary",
"template",
"this",
"throws",
"todo",
"tutorial",
"type",
"typedef",
"version"
"var",
"variation",
"version",
"virtual",
"yields"
];
var jsDocTagNameCompletionEntries;
var jsDocTagCompletionEntries;
@ -96474,7 +96551,7 @@ var ts;
var rawItems = [];
var _loop_15 = function (sourceFile) {
cancellationToken.throwIfCancellationRequested();
if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */)) {
if (excludeDtsFiles && sourceFile.isDeclarationFile) {
return "continue";
}
sourceFile.getNamedDeclarations().forEach(function (declarations, name) {
@ -99032,6 +99109,106 @@ var ts;
})(ts || (ts = {}));
/* @internal */
var ts;
(function (ts) {
// Sometimes tools can sometimes see the following line as a source mapping url comment, so we mangle it a bit (the [M])
var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/;
var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/;
var base64UrlRegExp = /^data:(?:application\/json(?:;charset=[uU][tT][fF]-8);base64,([A-Za-z0-9+\/=]+)$)?/;
function getSourceMapper(getCanonicalFileName, currentDirectory, log, host, getProgram) {
var sourcemappedFileCache;
return { tryGetOriginalLocation: tryGetOriginalLocation, toLineColumnOffset: toLineColumnOffset, clearCache: clearCache };
function scanForSourcemapURL(fileName) {
var mappedFile = sourcemappedFileCache.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName));
if (!mappedFile) {
return;
}
var starts = ts.getLineStarts(mappedFile);
for (var index = starts.length - 1; index >= 0; index--) {
var lineText = mappedFile.text.substring(starts[index], starts[index + 1]);
var comment = sourceMapCommentRegExp.exec(lineText);
if (comment) {
return comment[1];
}
// If we see a non-whitespace/map comment-like line, break, to avoid scanning up the entire file
else if (!lineText.match(whitespaceOrMapCommentRegExp)) {
break;
}
}
}
function convertDocumentToSourceMapper(file, contents, mapFileName) {
var maps;
try {
maps = JSON.parse(contents);
}
catch (_a) {
// swallow error
}
if (!maps || !maps.sources || !maps.file || !maps.mappings) {
// obviously invalid map
return file.sourceMapper = ts.sourcemaps.identitySourceMapper;
}
return file.sourceMapper = ts.sourcemaps.decode({
readFile: function (s) { return host.readFile(s); },
fileExists: function (s) { return host.fileExists(s); },
getCanonicalFileName: getCanonicalFileName,
log: log,
}, mapFileName, maps, getProgram(), sourcemappedFileCache);
}
function getSourceMapper(fileName, file) {
if (!host.readFile || !host.fileExists) {
return file.sourceMapper = ts.sourcemaps.identitySourceMapper;
}
if (file.sourceMapper) {
return file.sourceMapper;
}
var mapFileName = scanForSourcemapURL(fileName);
if (mapFileName) {
var match = base64UrlRegExp.exec(mapFileName);
if (match) {
if (match[1]) {
var base64Object = match[1];
return convertDocumentToSourceMapper(file, ts.base64decode(ts.sys, base64Object), fileName);
}
// Not a data URL we can parse, skip it
mapFileName = undefined;
}
}
var possibleMapLocations = [];
if (mapFileName) {
possibleMapLocations.push(mapFileName);
}
possibleMapLocations.push(fileName + ".map");
for (var _i = 0, possibleMapLocations_1 = possibleMapLocations; _i < possibleMapLocations_1.length; _i++) {
var location = possibleMapLocations_1[_i];
var mapPath = ts.toPath(location, ts.getDirectoryPath(fileName), getCanonicalFileName);
if (host.fileExists(mapPath)) {
return convertDocumentToSourceMapper(file, host.readFile(mapPath), mapPath); // TODO: GH#18217
}
}
return file.sourceMapper = ts.sourcemaps.identitySourceMapper;
}
function tryGetOriginalLocation(info) {
if (!ts.isDeclarationFileName(info.fileName))
return undefined;
var file = getProgram().getSourceFile(info.fileName) || sourcemappedFileCache.get(ts.toPath(info.fileName, currentDirectory, getCanonicalFileName));
if (!file)
return undefined;
var newLoc = getSourceMapper(info.fileName, file).getOriginalPosition(info);
return newLoc === info ? undefined : tryGetOriginalLocation(newLoc) || newLoc;
}
function toLineColumnOffset(fileName, position) {
var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
var file = getProgram().getSourceFile(path) || sourcemappedFileCache.get(path); // TODO: GH#18217
return file.getLineAndCharacterOfPosition(position);
}
function clearCache() {
sourcemappedFileCache = ts.createSourceFileLikeCache(host);
}
}
ts.getSourceMapper = getSourceMapper;
})(ts || (ts = {}));
/* @internal */
var ts;
(function (ts) {
function computeSuggestionDiagnostics(sourceFile, program, cancellationToken) {
program.getSemanticDiagnostics(sourceFile, cancellationToken);
@ -110871,7 +111048,6 @@ var ts;
if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) {
ts.localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages();
}
var sourcemappedFileCache;
function log(message) {
if (host.log) {
host.log(message);
@ -110879,6 +111055,7 @@ var ts;
}
var useCaseSensitiveFileNames = ts.hostUsesCaseSensitiveFileNames(host);
var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
var sourceMapper = ts.getSourceMapper(getCanonicalFileName, currentDirectory, log, host, function () { return program; });
function getValidSourceFile(fileName) {
var sourceFile = program.getSourceFile(fileName);
if (!sourceFile) {
@ -110976,7 +111153,7 @@ var ts;
// We reset this cache on structure invalidation so we don't hold on to outdated files for long; however we can't use the `compilerHost` above,
// Because it only functions until `hostCache` is cleared, while we'll potentially need the functionality to lazily read sourcemap files during
// the course of whatever called `synchronizeHostData`
sourcemappedFileCache = ts.createSourceFileLikeCache(host);
sourceMapper.clearCache();
// Make sure all the nodes in the program are both bound, and have their parent
// pointers set property.
program.getTypeChecker();
@ -111175,165 +111352,23 @@ var ts;
}
return checker.getSymbolAtLocation(node);
}
function toLineColumnOffset(fileName, position) {
var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
var file = program.getSourceFile(path) || sourcemappedFileCache.get(path); // TODO: GH#18217
return file.getLineAndCharacterOfPosition(position);
}
// Sometimes tools can sometimes see the following line as a source mapping url comment, so we mangle it a bit (the [M])
var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/;
var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/;
var base64UrlRegExp = /^data:(?:application\/json(?:;charset=[uU][tT][fF]-8);base64,([A-Za-z0-9+\/=]+)$)?/;
function scanForSourcemapURL(fileName) {
var mappedFile = sourcemappedFileCache.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName));
if (!mappedFile) {
return;
}
var starts = ts.getLineStarts(mappedFile);
for (var index = starts.length - 1; index >= 0; index--) {
var lineText = mappedFile.text.substring(starts[index], starts[index + 1]);
var comment = sourceMapCommentRegExp.exec(lineText);
if (comment) {
return comment[1];
}
// If we see a nonwhitespace/map comment-like line, break, to avoid scanning up the entire file
else if (!lineText.match(whitespaceOrMapCommentRegExp)) {
break;
}
}
}
function convertDocumentToSourceMapper(file, contents, mapFileName) {
var maps;
try {
maps = JSON.parse(contents);
}
catch (_a) {
// swallow error
}
if (!maps || !maps.sources || !maps.file || !maps.mappings) {
// obviously invalid map
return file.sourceMapper = ts.sourcemaps.identitySourceMapper;
}
return file.sourceMapper = ts.sourcemaps.decode({
readFile: function (s) { return host.readFile(s); },
fileExists: function (s) { return host.fileExists(s); },
getCanonicalFileName: getCanonicalFileName,
log: log,
}, mapFileName, maps, program, sourcemappedFileCache);
}
function getSourceMapper(fileName, file) {
if (!host.readFile || !host.fileExists) {
return file.sourceMapper = ts.sourcemaps.identitySourceMapper;
}
if (file.sourceMapper) {
return file.sourceMapper;
}
var mapFileName = scanForSourcemapURL(fileName);
if (mapFileName) {
var match = base64UrlRegExp.exec(mapFileName);
if (match) {
if (match[1]) {
var base64Object = match[1];
return convertDocumentToSourceMapper(file, ts.base64decode(ts.sys, base64Object), fileName);
}
// Not a data URL we can parse, skip it
mapFileName = undefined;
}
}
var possibleMapLocations = [];
if (mapFileName) {
possibleMapLocations.push(mapFileName);
}
possibleMapLocations.push(fileName + ".map");
for (var _i = 0, possibleMapLocations_1 = possibleMapLocations; _i < possibleMapLocations_1.length; _i++) {
var location = possibleMapLocations_1[_i];
var mapPath = ts.toPath(location, ts.getDirectoryPath(fileName), getCanonicalFileName);
if (host.fileExists(mapPath)) {
return convertDocumentToSourceMapper(file, host.readFile(mapPath), mapPath); // TODO: GH#18217
}
}
return file.sourceMapper = ts.sourcemaps.identitySourceMapper;
}
function makeGetTargetOfMappedPosition(extract, create) {
return getTargetOfMappedPosition;
function getTargetOfMappedPosition(input, original) {
if (original === void 0) { original = input; }
var info = extract(input);
if (ts.endsWith(info.fileName, ".d.ts" /* Dts */)) {
var file = program.getSourceFile(info.fileName);
if (!file) {
var path = ts.toPath(info.fileName, currentDirectory, getCanonicalFileName);
file = sourcemappedFileCache.get(path);
}
if (!file) {
return input;
}
var mapper = getSourceMapper(info.fileName, file);
var newLoc = mapper.getOriginalPosition(info);
if (newLoc === info)
return input;
return getTargetOfMappedPosition(create(newLoc, input, original), original);
}
return input;
}
}
var getTargetOfMappedDeclarationInfo = makeGetTargetOfMappedPosition(function (info) { return ({ fileName: info.fileName, position: info.textSpan.start }); }, function (newLoc, info, original) { return ({
containerKind: info.containerKind,
containerName: info.containerName,
fileName: newLoc.fileName,
kind: info.kind,
name: info.name,
textSpan: {
start: newLoc.position,
length: info.textSpan.length
},
originalFileName: original.fileName,
originalTextSpan: original.textSpan
}); });
function getTargetOfMappedDeclarationFiles(infos) {
return ts.map(infos, function (d) { return getTargetOfMappedDeclarationInfo(d); });
}
/// Goto definition
function getDefinitionAtPosition(fileName, position) {
synchronizeHostData();
return getTargetOfMappedDeclarationFiles(ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position));
return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position);
}
function getDefinitionAndBoundSpan(fileName, position) {
synchronizeHostData();
var result = ts.GoToDefinition.getDefinitionAndBoundSpan(program, getValidSourceFile(fileName), position);
if (!result)
return result;
var mappedDefs = getTargetOfMappedDeclarationFiles(result.definitions);
if (mappedDefs === result.definitions) {
return result;
}
return {
definitions: mappedDefs,
textSpan: result.textSpan
};
return ts.GoToDefinition.getDefinitionAndBoundSpan(program, getValidSourceFile(fileName), position);
}
function getTypeDefinitionAtPosition(fileName, position) {
synchronizeHostData();
return getTargetOfMappedDeclarationFiles(ts.GoToDefinition.getTypeDefinitionAtPosition(program.getTypeChecker(), getValidSourceFile(fileName), position));
return ts.GoToDefinition.getTypeDefinitionAtPosition(program.getTypeChecker(), getValidSourceFile(fileName), position);
}
/// Goto implementation
var getTargetOfMappedImplementationLocation = makeGetTargetOfMappedPosition(function (info) { return ({ fileName: info.fileName, position: info.textSpan.start }); }, function (newLoc, info) { return ({
fileName: newLoc.fileName,
kind: info.kind,
displayParts: info.displayParts,
textSpan: {
start: newLoc.position,
length: info.textSpan.length
},
originalFileName: info.fileName,
originalTextSpan: info.textSpan
}); });
function getTargetOfMappedImplementationLocations(infos) {
return ts.map(infos, function (d) { return getTargetOfMappedImplementationLocation(d); });
}
function getImplementationAtPosition(fileName, position) {
synchronizeHostData();
return getTargetOfMappedImplementationLocations(ts.FindAllReferences.getImplementationsAtPosition(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position));
return ts.FindAllReferences.getImplementationsAtPosition(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position);
}
/// References and Occurrences
function getOccurrencesAtPosition(fileName, position) {
@ -111384,7 +111419,6 @@ var ts;
synchronizeHostData();
return ts.FindAllReferences.findReferencedSymbols(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position);
}
/// NavigateTo
function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) {
if (excludeDtsFiles === void 0) { excludeDtsFiles = false; }
synchronizeHostData();
@ -111854,7 +111888,8 @@ var ts;
getProgram: getProgram,
getApplicableRefactors: getApplicableRefactors,
getEditsForRefactor: getEditsForRefactor,
toLineColumnOffset: toLineColumnOffset
toLineColumnOffset: sourceMapper.toLineColumnOffset,
getSourceMapper: function () { return sourceMapper; },
};
}
ts.createLanguageService = createLanguageService;

View File

@ -21885,9 +21885,11 @@ var ts;
InvalidPosition[InvalidPosition["Value"] = -1] = "Value";
})(InvalidPosition || (InvalidPosition = {}));
})(IncrementalParser || (IncrementalParser = {}));
/** @internal */
function isDeclarationFileName(fileName) {
return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */);
}
ts.isDeclarationFileName = isDeclarationFileName;
/*@internal*/
function processCommentPragmas(context, sourceText) {
var triviaScanner = ts.createScanner(context.languageVersion, /*skipTrivia*/ false, 0 /* Standard */, sourceText);
@ -29659,7 +29661,7 @@ var ts;
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType";
TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType";
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType";
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstraint"] = 4] = "ResolvedBaseConstraint";
TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint";
})(TypeSystemPropertyName || (TypeSystemPropertyName = {}));
var CheckMode;
(function (CheckMode) {
@ -31366,17 +31368,25 @@ var ts;
* Attempts to find the symbol corresponding to the container a symbol is in - usually this
* is just its' `.parent`, but for locals, this value is `undefined`
*/
function getContainerOfSymbol(symbol) {
function getContainersOfSymbol(symbol, enclosingDeclaration) {
var container = getParentOfSymbol(symbol);
if (container) {
return container;
var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer);
if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) {
return ts.concatenate([container], additionalContainers); // This order expresses a preference for the real container if it is in scope
}
return ts.append(additionalContainers, container);
}
var candidate = ts.forEach(symbol.declarations, function (d) { return !ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined; });
if (!candidate) {
var candidates = ts.mapDefined(symbol.declarations, function (d) { return !ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined; });
if (!ts.length(candidates)) {
return undefined;
}
var alias = getAliasForSymbolInContainer(candidate, symbol);
return alias ? candidate : undefined;
return ts.mapDefined(candidates, function (candidate) { return getAliasForSymbolInContainer(candidate, symbol) ? candidate : undefined; });
function fileSymbolIfFileSymbolExportEqualsContainer(d) {
var fileSymbol = getExternalModuleContainer(d);
var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */);
return resolveSymbol(exported) === resolveSymbol(container) ? fileSymbol : undefined;
}
}
function getAliasForSymbolInContainer(container, symbol) {
if (container === getParentOfSymbol(symbol)) {
@ -31627,6 +31637,54 @@ var ts;
var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67216319 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false);
return access.accessibility === 0 /* Accessible */;
}
function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible) {
if (!ts.length(symbols))
return;
var hadAccessibleChain;
for (var _i = 0, _a = symbols; _i < _a.length; _i++) {
var symbol = _a[_i];
// Symbol is accessible if it by itself is accessible
var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, /*useOnlyExternalAliasing*/ false);
if (accessibleSymbolChain) {
hadAccessibleChain = symbol;
var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0], shouldComputeAliasesToMakeVisible);
if (hasAccessibleDeclarations) {
return hasAccessibleDeclarations;
}
}
else {
if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
// Any meaning of a module symbol is always accessible via an `import` type
return {
accessibility: 0 /* Accessible */
};
}
}
// If we haven't got the accessible symbol, it doesn't mean the symbol is actually inaccessible.
// It could be a qualified symbol and hence verify the path
// e.g.:
// module m {
// export class c {
// }
// }
// const x: typeof m.c
// In the above example when we start with checking if typeof m.c symbol is accessible,
// we are going to see if c can be accessed in scope directly.
// But it can't, hence the accessible is going to be undefined, but that doesn't mean m.c is inaccessible
// It is accessible if the parent m is accessible because then m.c can be accessed through qualification
var parentResult = isAnySymbolAccessible(getContainersOfSymbol(symbol, enclosingDeclaration), enclosingDeclaration, initialSymbol, initialSymbol === symbol ? getQualifiedLeftMeaning(meaning) : meaning, shouldComputeAliasesToMakeVisible);
if (parentResult) {
return parentResult;
}
}
if (hadAccessibleChain) {
return {
accessibility: 1 /* NotAccessible */,
errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920 /* Namespace */) : undefined,
};
}
}
/**
* Check if the given symbol in given enclosing declaration is accessible and mark all associated alias to be visible if requested
*
@ -31637,55 +31695,20 @@ var ts;
*/
function isSymbolAccessible(symbol, enclosingDeclaration, meaning, shouldComputeAliasesToMakeVisible) {
if (symbol && enclosingDeclaration) {
var initialSymbol = symbol;
var meaningToLook = meaning;
while (symbol) {
// Symbol is accessible if it by itself is accessible
var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, /*useOnlyExternalAliasing*/ false);
if (accessibleSymbolChain) {
var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0], shouldComputeAliasesToMakeVisible);
if (!hasAccessibleDeclarations) {
return {
accessibility: 1 /* NotAccessible */,
errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1920 /* Namespace */) : undefined,
};
}
return hasAccessibleDeclarations;
}
else {
if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
// Any meaning of a module symbol is always accessible via an `import` type
return {
accessibility: 0 /* Accessible */
};
}
}
// If we haven't got the accessible symbol, it doesn't mean the symbol is actually inaccessible.
// It could be a qualified symbol and hence verify the path
// e.g.:
// module m {
// export class c {
// }
// }
// const x: typeof m.c
// In the above example when we start with checking if typeof m.c symbol is accessible,
// we are going to see if c can be accessed in scope directly.
// But it can't, hence the accessible is going to be undefined, but that doesn't mean m.c is inaccessible
// It is accessible if the parent m is accessible because then m.c can be accessed through qualification
meaningToLook = getQualifiedLeftMeaning(meaning);
symbol = getContainerOfSymbol(symbol);
var result = isAnySymbolAccessible([symbol], enclosingDeclaration, symbol, meaning, shouldComputeAliasesToMakeVisible);
if (result) {
return result;
}
// This could be a symbol that is not exported in the external module
// or it could be a symbol from different external module that is not aliased and hence cannot be named
var symbolExternalModule = ts.forEach(initialSymbol.declarations, getExternalModuleContainer);
var symbolExternalModule = ts.forEach(symbol.declarations, getExternalModuleContainer);
if (symbolExternalModule) {
var enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration);
if (symbolExternalModule !== enclosingExternalModule) {
// name from different external module that is not visible
return {
accessibility: 2 /* CannotBeNamed */,
errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning),
errorModuleName: symbolToString(symbolExternalModule)
};
}
@ -31693,14 +31716,14 @@ var ts;
// Just a local name that is not accessible
return {
accessibility: 1 /* NotAccessible */,
errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning),
};
}
return { accessibility: 0 /* Accessible */ };
function getExternalModuleContainer(declaration) {
var node = ts.findAncestor(declaration, hasExternalModuleSymbol);
return node && getSymbolOfNode(node);
}
}
function getExternalModuleContainer(declaration) {
var node = ts.findAncestor(declaration, hasExternalModuleSymbol);
return node && getSymbolOfNode(node);
}
function hasExternalModuleSymbol(declaration) {
return ts.isAmbientModule(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration));
@ -32477,16 +32500,18 @@ var ts;
/** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */
function getSymbolChain(symbol, meaning, endOfChain) {
var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* UseOnlyExternalAliasing */));
var parentSymbol;
if (!accessibleSymbolChain ||
needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) {
// Go up and add our parent.
var parent = getContainerOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol);
if (parent) {
var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false);
if (parentChain) {
parentSymbol = parent;
accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]);
var parents = getContainersOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol, context.enclosingDeclaration);
if (ts.length(parents)) {
for (var _i = 0, _a = parents; _i < _a.length; _i++) {
var parent = _a[_i];
var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false);
if (parentChain) {
accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]);
break;
}
}
}
}
@ -32496,10 +32521,12 @@ var ts;
if (
// If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols.
endOfChain ||
// If a parent symbol is an anonymous type, don't write it.
!(symbol.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) {
// If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.)
(yieldModuleSymbol || !(!parentSymbol && ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol))) &&
// If a parent symbol is an anonymous type, don't write it.
!(symbol.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) {
if (!endOfChain && !yieldModuleSymbol && !!ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
return;
}
return [symbol];
}
}
@ -32993,8 +33020,8 @@ var ts;
if (propertyName === 3 /* ResolvedReturnType */) {
return !!target.resolvedReturnType;
}
if (propertyName === 4 /* ResolvedBaseConstraint */) {
var bc = target.resolvedBaseConstraint;
if (propertyName === 4 /* ImmediateBaseConstraint */) {
var bc = target.immediateBaseConstraint;
return !!bc && bc !== circularConstraintType;
}
return ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName);
@ -35427,15 +35454,21 @@ var ts;
}
return type.resolvedBaseConstraint;
function getBaseConstraint(t) {
if (!pushTypeResolution(t, 4 /* ResolvedBaseConstraint */)) {
if (t.immediateBaseConstraint) {
return t.immediateBaseConstraint === noConstraintType ? undefined : t.immediateBaseConstraint;
}
if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) {
circular = true;
t.immediateBaseConstraint = circularConstraintType;
return undefined;
}
var result = computeBaseConstraint(getSimplifiedType(t));
if (!popTypeResolution()) {
circular = true;
t.immediateBaseConstraint = circularConstraintType;
return undefined;
}
t.immediateBaseConstraint = !result ? noConstraintType : result;
return result;
}
function computeBaseConstraint(t) {
@ -84151,7 +84184,8 @@ var ts;
}
ts.parseConfigHostFromCompilerHost = parseConfigHostFromCompilerHost;
/**
* Returns the target config filename of a project reference
* Returns the target config filename of a project reference.
* Note: The file might not exist.
*/
function resolveProjectReferencePath(host, ref) {
if (!host.fileExists(ref.path)) {