diff --git a/src/compiler/core.ts b/src/compiler/core.ts index db076ab5dad..239607142eb 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2029,110 +2029,6 @@ namespace ts { return res > max ? undefined : res; } - export function normalizeSlashes(path: string): string { - return path.replace(/\\/g, "/"); - } - - /** - * Returns length of path root (i.e. length of "/", "x:/", "//server/share/, file:///user/files") - */ - export function getRootLength(path: string): number { - if (path.charCodeAt(0) === CharacterCodes.slash) { - if (path.charCodeAt(1) !== CharacterCodes.slash) return 1; - const p1 = path.indexOf("/", 2); - if (p1 < 0) return 2; - const p2 = path.indexOf("/", p1 + 1); - if (p2 < 0) return p1 + 1; - return p2 + 1; - } - if (path.charCodeAt(1) === CharacterCodes.colon) { - if (path.charCodeAt(2) === CharacterCodes.slash || path.charCodeAt(2) === CharacterCodes.backslash) return 3; - } - // Per RFC 1738 'file' URI schema has the shape file:/// - // if is omitted then it is assumed that host value is 'localhost', - // however slash after the omitted is not removed. - // file:///folder1/file1 - this is a correct URI - // file://folder2/file2 - this is an incorrect URI - if (path.lastIndexOf("file:///", 0) === 0) { - return "file:///".length; - } - const idx = path.indexOf("://"); - if (idx !== -1) { - return idx + "://".length; - } - return 0; - } - - /** - * Internally, we represent paths as strings with '/' as the directory separator. - * When we make system calls (eg: LanguageServiceHost.getDirectory()), - * we expect the host to correctly handle paths in our specified format. - */ - export const directorySeparator = "/"; - const directorySeparatorCharCode = CharacterCodes.slash; - function getNormalizedParts(normalizedSlashedPath: string, rootLength: number): string[] { - const parts = normalizedSlashedPath.substr(rootLength).split(directorySeparator); - const normalized: string[] = []; - for (const part of parts) { - if (part !== ".") { - if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") { - normalized.pop(); - } - else { - // A part may be an empty string (which is 'falsy') if the path had consecutive slashes, - // e.g. "path//file.ts". Drop these before re-joining the parts. - if (part) { - normalized.push(part); - } - } - } - } - - return normalized; - } - - export function normalizePath(path: string): string { - return normalizePathAndParts(path).path; - } - - export function normalizePathAndParts(path: string): { path: string, parts: string[] } { - path = normalizeSlashes(path); - const rootLength = getRootLength(path); - const root = path.substr(0, rootLength); - const parts = getNormalizedParts(path, rootLength); - if (parts.length) { - const joinedParts = root + parts.join(directorySeparator); - return { path: pathEndsWithDirectorySeparator(path) ? joinedParts + directorySeparator : joinedParts, parts }; - } - else { - return { path: root, parts }; - } - } - - /** A path ending with '/' refers to a directory only, never a file. */ - export function pathEndsWithDirectorySeparator(path: string): boolean { - return path.charCodeAt(path.length - 1) === directorySeparatorCharCode; - } - - /** - * Returns the path except for its basename. Eg: - * - * /path/to/file.ext -> /path/to - */ - export function getDirectoryPath(path: Path): Path; - export function getDirectoryPath(path: string): string; - export function getDirectoryPath(path: string): string { - return path.substr(0, Math.max(getRootLength(path), path.lastIndexOf(directorySeparator))); - } - - export function isUrl(path: string) { - return path && !isRootedDiskPath(path) && stringContains(path, "://"); - } - - export function pathIsRelative(path: string): boolean { - return /^\.\.?($|[\\/])/.test(path); - } - export function getEmitScriptTarget(compilerOptions: CompilerOptions) { return compilerOptions.target || ScriptTarget.ES3; } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index c12e0a9931b..7b3a9733599 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2356,6 +2356,14 @@ "category": "Error", "code": 2724 }, + "Cannot find lib definition for '{0}'.": { + "category": "Error", + "code": 2725 + }, + "Cannot find lib definition for '{0}'. Did you mean '{1}'?": { + "category": "Error", + "code": 2726 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 735de930ae9..d0e07e514d6 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -2417,12 +2417,13 @@ namespace ts { // Top-level nodes - export function updateSourceFileNode(node: SourceFile, statements: ReadonlyArray, isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"], hasNoDefaultLib?: boolean) { + export function updateSourceFileNode(node: SourceFile, statements: ReadonlyArray, isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"], hasNoDefaultLib?: boolean, libReferences?: SourceFile["libReferenceDirectives"]) { if ( node.statements !== statements || (isDeclarationFile !== undefined && node.isDeclarationFile !== isDeclarationFile) || (referencedFiles !== undefined && node.referencedFiles !== referencedFiles) || (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || + (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib) ) { const updated = createSynthesizedNode(SyntaxKind.SourceFile); @@ -2436,6 +2437,7 @@ namespace ts { updated.referencedFiles = referencedFiles === undefined ? node.referencedFiles : referencedFiles; updated.typeReferenceDirectives = typeReferences === undefined ? node.typeReferenceDirectives : typeReferences; updated.hasNoDefaultLib = hasNoDefaultLib === undefined ? node.hasNoDefaultLib : hasNoDefaultLib; + updated.libReferenceDirectives = libReferences === undefined ? node.libReferenceDirectives : libReferences; if (node.amdDependencies !== undefined) updated.amdDependencies = node.amdDependencies; if (node.moduleName !== undefined) updated.moduleName = node.moduleName; if (node.languageVariant !== undefined) updated.languageVariant = node.languageVariant; diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index b84c8ca004f..c7fa4a9c0eb 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -7592,6 +7592,7 @@ namespace ts { checkJsDirective?: CheckJsDirective; referencedFiles: FileReference[]; typeReferenceDirectives: FileReference[]; + libReferenceDirectives: FileReference[]; amdDependencies: AmdDependency[]; hasNoDefaultLib?: boolean; moduleName?: string; @@ -7645,6 +7646,7 @@ namespace ts { context.checkJsDirective = undefined; context.referencedFiles = []; context.typeReferenceDirectives = []; + context.libReferenceDirectives = []; context.amdDependencies = []; context.hasNoDefaultLib = false; context.pragmas.forEach((entryOrList, key) => { @@ -7654,6 +7656,7 @@ namespace ts { case "reference": { const referencedFiles = context.referencedFiles; const typeReferenceDirectives = context.typeReferenceDirectives; + const libReferenceDirectives = context.libReferenceDirectives; forEach(toArray(entryOrList), (arg: PragmaPsuedoMap["reference"]) => { if (arg.arguments["no-default-lib"]) { context.hasNoDefaultLib = true; @@ -7661,6 +7664,9 @@ namespace ts { else if (arg.arguments.types) { typeReferenceDirectives.push({ pos: arg.arguments.types.pos, end: arg.arguments.types.end, fileName: arg.arguments.types.value }); } + else if (arg.arguments.lib) { + libReferenceDirectives.push({ pos: arg.arguments.lib.pos, end: arg.arguments.lib.end, fileName: arg.arguments.lib.value }); + } else if (arg.arguments.path) { referencedFiles.push({ pos: arg.arguments.path.pos, end: arg.arguments.path.end, fileName: arg.arguments.path.value }); } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 4f052581c20..8fba4480c55 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -584,7 +584,7 @@ namespace ts { const shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); const structuralIsReused = tryReuseStructureFromOldProgram(); if (structuralIsReused !== StructureIsReused.Completely) { - forEach(rootNames, name => processRootFile(name, /*isDefaultLib*/ false)); + forEach(rootNames, name => processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false)); // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders const typeReferences: string[] = getAutomaticTypeDirectiveNames(options, host); @@ -608,11 +608,11 @@ namespace ts { // otherwise, using options specified in '--lib' instead of '--target' default library file const defaultLibraryFileName = getDefaultLibraryFileName(); if (!options.lib && defaultLibraryFileName) { - processRootFile(defaultLibraryFileName, /*isDefaultLib*/ true); + processRootFile(defaultLibraryFileName, /*isDefaultLib*/ true, /*ignoreNoDefaultLib*/ false); } else { forEach(options.lib, libFileName => { - processRootFile(combinePaths(defaultLibraryPath, libFileName), /*isDefaultLib*/ true); + processRootFile(combinePaths(defaultLibraryPath, libFileName), /*isDefaultLib*/ true, /*ignoreNoDefaultLib*/ false); }); } } @@ -964,6 +964,11 @@ namespace ts { if (fileChanged) { // The `newSourceFile` object was created for the new program. + if (!arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { + // 'lib' references has changed. Matches behavior in chagnesAffectModuleResolution + return oldProgram.structureIsReused = StructureIsReused.Not; + } + if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed // this will affect if default library is injected into the list of files @@ -1579,8 +1584,8 @@ namespace ts { return configFileParsingDiagnostics || emptyArray; } - function processRootFile(fileName: string, isDefaultLib: boolean) { - processSourceFile(normalizePath(fileName), isDefaultLib, /*packageId*/ undefined); + function processRootFile(fileName: string, isDefaultLib: boolean, ignoreNoDefaultLib: boolean) { + processSourceFile(normalizePath(fileName), isDefaultLib, ignoreNoDefaultLib, /*packageId*/ undefined); } function fileReferenceIsEqualTo(a: FileReference, b: FileReference): boolean { @@ -1747,9 +1752,9 @@ namespace ts { } /** This has side effects through `findSourceFile`. */ - function processSourceFile(fileName: string, isDefaultLib: boolean, packageId: PackageId | undefined, refFile?: SourceFile, refPos?: number, refEnd?: number): void { + function processSourceFile(fileName: string, isDefaultLib: boolean, ignoreNoDefaultLib: boolean, packageId: PackageId | undefined, refFile?: SourceFile, refPos?: number, refEnd?: number): void { getSourceFileFromReferenceWorker(fileName, - fileName => findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, packageId), + fileName => findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId), (diagnostic, ...args) => { fileProcessingDiagnostics.add(refFile !== undefined && refEnd !== undefined && refPos !== undefined ? createFileDiagnostic(refFile, refPos, refEnd - refPos, diagnostic, ...args) @@ -1787,7 +1792,7 @@ namespace ts { } // Get source file from normalized fileName - function findSourceFile(fileName: string, path: Path, isDefaultLib: boolean, refFile: SourceFile, refPos: number, refEnd: number, packageId: PackageId | undefined): SourceFile | undefined { + function findSourceFile(fileName: string, path: Path, isDefaultLib: boolean, ignoreNoDefaultLib: boolean, refFile: SourceFile, refPos: number, refEnd: number, packageId: PackageId | undefined): SourceFile | undefined { if (filesByName.has(path)) { const file = filesByName.get(path); // try to check if we've already seen this file but with a different casing in path @@ -1802,6 +1807,7 @@ namespace ts { sourceFilesFoundSearchingNodeModules.set(file.path, false); if (!options.noResolve) { processReferencedFiles(file, isDefaultLib); + processLibReferenceDirectives(file); processTypeReferenceDirectives(file); } @@ -1867,10 +1873,11 @@ namespace ts { } } - skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; + skipDefaultLib = skipDefaultLib || (file.hasNoDefaultLib && !ignoreNoDefaultLib); if (!options.noResolve) { processReferencedFiles(file, isDefaultLib); + processLibReferenceDirectives(file); processTypeReferenceDirectives(file); } @@ -1891,7 +1898,7 @@ namespace ts { function processReferencedFiles(file: SourceFile, isDefaultLib: boolean) { forEach(file.referencedFiles, ref => { const referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); - processSourceFile(referencedFileName, isDefaultLib, /*packageId*/ undefined, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined, file, ref.pos, ref.end); }); } @@ -1922,7 +1929,7 @@ namespace ts { if (resolvedTypeReferenceDirective) { if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -1945,7 +1952,7 @@ namespace ts { } else { // First resolution of this library - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); } } } @@ -1958,6 +1965,23 @@ namespace ts { } } + function processLibReferenceDirectives(file: SourceFile) { + forEach(file.libReferenceDirectives, libReference => { + const libName = libReference.fileName.toLocaleLowerCase(); + const libFileName = libMap.get(libName); + if (libFileName) { + // we ignore any 'no-default-lib' reference set on this file. + processRootFile(combinePaths(defaultLibraryPath, libFileName), /*isDefaultLib*/ true, /*ignoreNoDefaultLib*/ true); + } + else { + const unqualifiedLibName = removeSuffix(removePrefix(libName, "lib."), ".d.ts"); + const suggestion = getSpellingSuggestion(unqualifiedLibName, libs, identity); + const message = suggestion ? Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : Diagnostics.Cannot_find_lib_definition_for_0; + fileProcessingDiagnostics.add(createDiagnostic(file, libReference.pos, libReference.end, message, libName, suggestion)); + } + }); + } + function createDiagnostic(refFile: SourceFile, refPos: number, refEnd: number, message: DiagnosticMessage, ...args: any[]): Diagnostic { if (refFile === undefined || refPos === undefined || refEnd === undefined) { return createCompilerDiagnostic(message, ...args); @@ -2018,7 +2042,7 @@ namespace ts { else if (shouldAddFile) { const path = toPath(resolvedFileName); const pos = skipTrivia(file.text, file.imports[i].pos); - findSourceFile(resolvedFileName, path, /*isDefaultLib*/ false, file, pos, file.imports[i].end, resolution.packageId); + findSourceFile(resolvedFileName, path, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, file, pos, file.imports[i].end, resolution.packageId); } if (isFromNodeModulesSearch) { diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index 67e4fa31cb2..66b8d696cf9 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -156,12 +156,12 @@ namespace ts { [createModifier(SyntaxKind.DeclareKeyword)], createLiteral(getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), createModuleBlock(setTextRange(createNodeArray(filterCandidateImports(statements)), sourceFile.statements)) - )], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false); + )], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; const updated = visitNodes(sourceFile.statements, visitDeclarationStatements); - return updateSourceFileNode(sourceFile, filterCandidateImports(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false); + return updateSourceFileNode(sourceFile, filterCandidateImports(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); } )); bundle.syntheticFileReferences = []; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 4f48fe96a87..a60c12f6c23 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2544,6 +2544,7 @@ namespace ts { moduleName: string; referencedFiles: ReadonlyArray; typeReferenceDirectives: ReadonlyArray; + libReferenceDirectives: ReadonlyArray; languageVariant: LanguageVariant; isDeclarationFile: boolean; @@ -5304,8 +5305,12 @@ namespace ts { } /* @internal */ - export interface PragmaDefinition { - args?: [PragmaArgumentSpecification] | [PragmaArgumentSpecification, PragmaArgumentSpecification] | [PragmaArgumentSpecification, PragmaArgumentSpecification, PragmaArgumentSpecification]; + export interface PragmaDefinition { + args?: + | [PragmaArgumentSpecification] + | [PragmaArgumentSpecification, PragmaArgumentSpecification] + | [PragmaArgumentSpecification, PragmaArgumentSpecification, PragmaArgumentSpecification] + | [PragmaArgumentSpecification, PragmaArgumentSpecification, PragmaArgumentSpecification, PragmaArgumentSpecification]; // If not present, defaults to PragmaKindFlags.Default kind?: PragmaKindFlags; } @@ -5314,7 +5319,7 @@ namespace ts { * This function only exists to cause exact types to be inferred for all the literals within `commentPragmas` */ /* @internal */ - function _contextuallyTypePragmas}, K1 extends string, K2 extends string, K3 extends string>(args: T): T { + function _contextuallyTypePragmas}, K1 extends string, K2 extends string, K3 extends string, K4 extends string>(args: T): T { return args; } @@ -5325,6 +5330,7 @@ namespace ts { "reference": { args: [ { name: "types", optional: true, captureSpan: true }, + { name: "lib", optional: true, captureSpan: true }, { name: "path", optional: true, captureSpan: true }, { name: "no-default-lib", optional: true } ], @@ -5365,13 +5371,15 @@ namespace ts { */ /* @internal */ type PragmaArgumentType = - T extends { args: [PragmaArgumentSpecification, PragmaArgumentSpecification, PragmaArgumentSpecification] } - ? PragmaArgTypeOptional & PragmaArgTypeOptional & PragmaArgTypeOptional - : T extends { args: [PragmaArgumentSpecification, PragmaArgumentSpecification] } - ? PragmaArgTypeOptional & PragmaArgTypeOptional - : T extends { args: [PragmaArgumentSpecification] } - ? PragmaArgTypeOptional - : object; + T extends { args: [PragmaArgumentSpecification, PragmaArgumentSpecification, PragmaArgumentSpecification, PragmaArgumentSpecification] } + ? PragmaArgTypeOptional & PragmaArgTypeOptional & PragmaArgTypeOptional & PragmaArgTypeOptional + : T extends { args: [PragmaArgumentSpecification, PragmaArgumentSpecification, PragmaArgumentSpecification] } + ? PragmaArgTypeOptional & PragmaArgTypeOptional & PragmaArgTypeOptional + : T extends { args: [PragmaArgumentSpecification, PragmaArgumentSpecification] } + ? PragmaArgTypeOptional & PragmaArgTypeOptional + : T extends { args: [PragmaArgumentSpecification] } + ? PragmaArgTypeOptional + : object; // The above fallback to `object` when there's no args to allow `{}` (as intended), but not the number 2, for example // TODO: Swap to `undefined` for a cleaner API once strictNullChecks is enabled diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 34d6f775a74..3553ee301df 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -574,7 +574,8 @@ namespace Harness.LanguageService { importedFiles: [], ambientExternalModules: [], isLibFile: shimResult.isLibFile, - typeReferenceDirectives: [] + typeReferenceDirectives: [], + libReferenceDirectives: [] }; ts.forEach(shimResult.referencedFiles, refFile => { diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index 6ca728444f2..2c968671a1a 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -1,4 +1,4 @@ -/// +/// interface DOMTokenList { [Symbol.iterator](): IterableIterator; diff --git a/src/lib/es2015.d.ts b/src/lib/es2015.d.ts index 36f22af6241..e81e7fdd3ef 100644 --- a/src/lib/es2015.d.ts +++ b/src/lib/es2015.d.ts @@ -1,10 +1,10 @@ -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// \ No newline at end of file +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// \ No newline at end of file diff --git a/src/lib/es2015.full.d.ts b/src/lib/es2015.full.d.ts new file mode 100644 index 00000000000..4652bbb84c5 --- /dev/null +++ b/src/lib/es2015.full.d.ts @@ -0,0 +1,14 @@ +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// \ No newline at end of file diff --git a/src/lib/es2015.iterable.d.ts b/src/lib/es2015.iterable.d.ts index ccb7df6be69..b7c04c60ce0 100644 --- a/src/lib/es2015.iterable.d.ts +++ b/src/lib/es2015.iterable.d.ts @@ -1,4 +1,4 @@ -/// +/// interface SymbolConstructor { /** diff --git a/src/lib/es2015.symbol.wellknown.d.ts b/src/lib/es2015.symbol.wellknown.d.ts index 681b6e8edfa..948c8129a92 100644 --- a/src/lib/es2015.symbol.wellknown.d.ts +++ b/src/lib/es2015.symbol.wellknown.d.ts @@ -1,4 +1,4 @@ -/// +/// interface SymbolConstructor { /** diff --git a/src/lib/es2016.d.ts b/src/lib/es2016.d.ts index 34f833d621b..fc1aab7798c 100644 --- a/src/lib/es2016.d.ts +++ b/src/lib/es2016.d.ts @@ -1,2 +1,2 @@ -/// -/// \ No newline at end of file +/// +/// \ No newline at end of file diff --git a/src/lib/es2016.full.d.ts b/src/lib/es2016.full.d.ts new file mode 100644 index 00000000000..0f1fd4349da --- /dev/null +++ b/src/lib/es2016.full.d.ts @@ -0,0 +1,5 @@ +/// +/// +/// +/// +/// \ No newline at end of file diff --git a/src/lib/es2017.d.ts b/src/lib/es2017.d.ts index 87aa273140b..74e5bea1180 100644 --- a/src/lib/es2017.d.ts +++ b/src/lib/es2017.d.ts @@ -1,6 +1,6 @@ -/// -/// -/// -/// -/// -/// +/// +/// +/// +/// +/// +/// diff --git a/src/lib/es2017.full.d.ts b/src/lib/es2017.full.d.ts new file mode 100644 index 00000000000..82c358f31e1 --- /dev/null +++ b/src/lib/es2017.full.d.ts @@ -0,0 +1,5 @@ +/// +/// +/// +/// +/// \ No newline at end of file diff --git a/src/lib/es2017.sharedmemory.d.ts b/src/lib/es2017.sharedmemory.d.ts index b9a9b0f7e10..018a2f162a5 100644 --- a/src/lib/es2017.sharedmemory.d.ts +++ b/src/lib/es2017.sharedmemory.d.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// interface SharedArrayBuffer { /** diff --git a/src/lib/es2018.d.ts b/src/lib/es2018.d.ts index 54d108440e0..1d0e0c94d2c 100644 --- a/src/lib/es2018.d.ts +++ b/src/lib/es2018.d.ts @@ -1,4 +1,4 @@ -/// -/// -/// -/// +/// +/// +/// +/// diff --git a/src/lib/es2018.full.d.ts b/src/lib/es2018.full.d.ts new file mode 100644 index 00000000000..0f38d44ca5e --- /dev/null +++ b/src/lib/es2018.full.d.ts @@ -0,0 +1,5 @@ +/// +/// +/// +/// +/// \ No newline at end of file diff --git a/src/lib/es5.full.d.ts b/src/lib/es5.full.d.ts new file mode 100644 index 00000000000..5bbe6663b9f --- /dev/null +++ b/src/lib/es5.full.d.ts @@ -0,0 +1,4 @@ +/// +/// +/// +/// diff --git a/src/lib/esnext.asynciterable.d.ts b/src/lib/esnext.asynciterable.d.ts index 8379ba5ba6c..11093af623d 100644 --- a/src/lib/esnext.asynciterable.d.ts +++ b/src/lib/esnext.asynciterable.d.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// interface SymbolConstructor { /** diff --git a/src/lib/esnext.d.ts b/src/lib/esnext.d.ts index 831d241cc3c..50b179191ad 100644 --- a/src/lib/esnext.d.ts +++ b/src/lib/esnext.d.ts @@ -1,3 +1,3 @@ -/// -/// -/// +/// +/// +/// diff --git a/src/lib/esnext.full.d.ts b/src/lib/esnext.full.d.ts new file mode 100644 index 00000000000..2a8029d3a80 --- /dev/null +++ b/src/lib/esnext.full.d.ts @@ -0,0 +1,5 @@ +/// +/// +/// +/// +/// \ No newline at end of file diff --git a/src/lib/libs.json b/src/lib/libs.json index 1385365efff..d3803464818 100644 --- a/src/lib/libs.json +++ b/src/lib/libs.json @@ -39,6 +39,7 @@ "es2015.full", "es2016.full", "es2017.full", + "es2018.full", "esnext.full" ], "paths": { @@ -46,57 +47,5 @@ "webworker.generated": "lib.webworker.d.ts", "es5.full": "lib.d.ts", "es2015.full": "lib.es6.d.ts" - }, - "sources": { - "es5.full": [ - "es5.d.ts", - "dom.generated.d.ts", - "webworker.importscripts.d.ts", - "scripthost.d.ts" - ], - "es2015.full": [ - "es5.d.ts", - "es2015.core.d.ts", - "es2015.collection.d.ts", - "es2015.generator.d.ts", - "es2015.iterable.d.ts", - "es2015.promise.d.ts", - "es2015.proxy.d.ts", - "es2015.reflect.d.ts", - "es2015.symbol.d.ts", - "es2015.symbol.wellknown.d.ts", - "dom.generated.d.ts", - "webworker.importscripts.d.ts", - "scripthost.d.ts", - "dom.iterable.d.ts" - ], - "es2016.full": [ - "es2016.d.ts", - "dom.generated.d.ts", - "webworker.importscripts.d.ts", - "scripthost.d.ts", - "dom.iterable.d.ts" - ], - "es2017.full": [ - "es2017.d.ts", - "dom.generated.d.ts", - "webworker.importscripts.d.ts", - "scripthost.d.ts", - "dom.iterable.d.ts" - ], - "es2018.full": [ - "es2018.d.ts", - "dom.generated.d.ts", - "webworker.importscripts.d.ts", - "scripthost.d.ts", - "dom.iterable.d.ts" - ], - "esnext.full": [ - "esnext.d.ts", - "dom.generated.d.ts", - "webworker.importscripts.d.ts", - "scripthost.d.ts", - "dom.iterable.d.ts" - ] } } \ No newline at end of file diff --git a/src/lib/webworker.generated.d.ts b/src/lib/webworker.generated.d.ts index b83072a9698..558acc14d12 100644 --- a/src/lib/webworker.generated.d.ts +++ b/src/lib/webworker.generated.d.ts @@ -1,3 +1,5 @@ +/// + ///////////////////////////// /// Worker APIs ///////////////////////////// @@ -1397,28 +1399,28 @@ declare var URL: { }; interface URLSearchParams { - /** - * Appends a specified key/value pair as a new search parameter. + /** + * Appends a specified key/value pair as a new search parameter. */ append(name: string, value: string): void; - /** - * Deletes the given search parameter, and its associated value, from the list of all search parameters. + /** + * Deletes the given search parameter, and its associated value, from the list of all search parameters. */ delete(name: string): void; - /** - * Returns the first value associated to the given search parameter. + /** + * Returns the first value associated to the given search parameter. */ get(name: string): string | null; - /** - * Returns all the values association with a given search parameter. + /** + * Returns all the values association with a given search parameter. */ getAll(name: string): string[]; - /** - * Returns a Boolean indicating if such a search parameter exists. + /** + * Returns a Boolean indicating if such a search parameter exists. */ has(name: string): boolean; - /** - * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. + /** + * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. */ set(name: string, value: string): void; } @@ -1710,7 +1712,6 @@ declare var navigator: WorkerNavigator; declare function clearImmediate(handle: number): void; declare function clearInterval(handle: number): void; declare function clearTimeout(handle: number): void; -declare function importScripts(...urls: string[]): void; declare function setImmediate(handler: any, ...args: any[]): number; declare function setInterval(handler: any, timeout?: any, ...args: any[]): number; declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number; diff --git a/src/services/preProcess.ts b/src/services/preProcess.ts index 6c5f6c1b2ff..174b3fa5ffc 100644 --- a/src/services/preProcess.ts +++ b/src/services/preProcess.ts @@ -6,6 +6,7 @@ namespace ts { checkJsDirective: undefined, referencedFiles: [], typeReferenceDirectives: [], + libReferenceDirectives: [], amdDependencies: [], hasNoDefaultLib: undefined, moduleName: undefined @@ -336,7 +337,7 @@ namespace ts { importedFiles.push(decl.ref); } } - return { referencedFiles: pragmaContext.referencedFiles, typeReferenceDirectives: pragmaContext.typeReferenceDirectives, importedFiles, isLibFile: pragmaContext.hasNoDefaultLib, ambientExternalModules: undefined }; + return { referencedFiles: pragmaContext.referencedFiles, typeReferenceDirectives: pragmaContext.typeReferenceDirectives, libReferenceDirectives: pragmaContext.libReferenceDirectives, importedFiles, isLibFile: pragmaContext.hasNoDefaultLib, ambientExternalModules: undefined }; } else { // for global scripts ambient modules still can have augmentations - look for ambient modules with depth > 0 @@ -354,7 +355,7 @@ namespace ts { } } } - return { referencedFiles: pragmaContext.referencedFiles, typeReferenceDirectives: pragmaContext.typeReferenceDirectives, importedFiles, isLibFile: pragmaContext.hasNoDefaultLib, ambientExternalModules: ambientModuleNames }; + return { referencedFiles: pragmaContext.referencedFiles, typeReferenceDirectives: pragmaContext.typeReferenceDirectives, libReferenceDirectives: pragmaContext.libReferenceDirectives, importedFiles, isLibFile: pragmaContext.hasNoDefaultLib, ambientExternalModules: ambientModuleNames }; } } } diff --git a/src/services/services.ts b/src/services/services.ts index f17b7698a87..96f995690e8 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -544,6 +544,7 @@ namespace ts { public moduleName: string; public referencedFiles: FileReference[]; public typeReferenceDirectives: FileReference[]; + public libReferenceDirectives: FileReference[]; public syntacticDiagnostics: Diagnostic[]; public parseDiagnostics: Diagnostic[]; diff --git a/src/services/shims.ts b/src/services/shims.ts index d0735cc1717..00268c3ef23 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -1103,7 +1103,8 @@ namespace ts { importedFiles: this.convertFileReferences(result.importedFiles), ambientExternalModules: result.ambientExternalModules, isLibFile: result.isLibFile, - typeReferenceDirectives: this.convertFileReferences(result.typeReferenceDirectives) + typeReferenceDirectives: this.convertFileReferences(result.typeReferenceDirectives), + libReferenceDirectives: this.convertFileReferences(result.libReferenceDirectives) }; }); } diff --git a/src/services/types.ts b/src/services/types.ts index 31baf7df399..1f5c3ba08ed 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -151,9 +151,11 @@ namespace ts { return new StringScriptSnapshot(text); } } + export interface PreProcessedFileInfo { referencedFiles: FileReference[]; typeReferenceDirectives: FileReference[]; + libReferenceDirectives: FileReference[]; importedFiles: FileReference[]; ambientExternalModules: string[]; isLibFile: boolean; diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index cda7e745657..3225122cc9a 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -1630,6 +1630,7 @@ declare namespace ts { moduleName: string; referencedFiles: ReadonlyArray; typeReferenceDirectives: ReadonlyArray; + libReferenceDirectives: ReadonlyArray; languageVariant: LanguageVariant; isDeclarationFile: boolean; /** @@ -3722,7 +3723,7 @@ declare namespace ts { function updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment; function createEnumMember(name: string | PropertyName, initializer?: Expression): EnumMember; function updateEnumMember(node: EnumMember, name: PropertyName, initializer: Expression | undefined): EnumMember; - function updateSourceFileNode(node: SourceFile, statements: ReadonlyArray, isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"], hasNoDefaultLib?: boolean): SourceFile; + function updateSourceFileNode(node: SourceFile, statements: ReadonlyArray, isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"], hasNoDefaultLib?: boolean, libReferences?: SourceFile["libReferenceDirectives"]): SourceFile; /** * Creates a shallow, memberwise clone of a node for mutation. */ @@ -4364,6 +4365,7 @@ declare namespace ts { interface PreProcessedFileInfo { referencedFiles: FileReference[]; typeReferenceDirectives: FileReference[]; + libReferenceDirectives: FileReference[]; importedFiles: FileReference[]; ambientExternalModules: string[]; isLibFile: boolean; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 2f7a9537504..80d8a5b8148 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -1630,6 +1630,7 @@ declare namespace ts { moduleName: string; referencedFiles: ReadonlyArray; typeReferenceDirectives: ReadonlyArray; + libReferenceDirectives: ReadonlyArray; languageVariant: LanguageVariant; isDeclarationFile: boolean; /** @@ -3722,7 +3723,7 @@ declare namespace ts { function updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment; function createEnumMember(name: string | PropertyName, initializer?: Expression): EnumMember; function updateEnumMember(node: EnumMember, name: PropertyName, initializer: Expression | undefined): EnumMember; - function updateSourceFileNode(node: SourceFile, statements: ReadonlyArray, isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"], hasNoDefaultLib?: boolean): SourceFile; + function updateSourceFileNode(node: SourceFile, statements: ReadonlyArray, isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"], hasNoDefaultLib?: boolean, libReferences?: SourceFile["libReferenceDirectives"]): SourceFile; /** * Creates a shallow, memberwise clone of a node for mutation. */ @@ -4364,6 +4365,7 @@ declare namespace ts { interface PreProcessedFileInfo { referencedFiles: FileReference[]; typeReferenceDirectives: FileReference[]; + libReferenceDirectives: FileReference[]; importedFiles: FileReference[]; ambientExternalModules: string[]; isLibFile: boolean;