Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds 'lib' reference directives #23893

Merged
merged 16 commits into from
Jun 4, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/compiler/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace ts {
return map;
}

export function createMapFromTemplate<T>(template?: MapLike<T>): Map<T> {
export function createMapFromTemplate<T>(template: MapLike<T>): Map<T> {
const map: Map<T> = new MapCtr<T>();

// Copies keys/values from template. Note that for..in will not throw if
Expand Down Expand Up @@ -1749,7 +1749,7 @@ namespace ts {
* Case-sensitive comparisons compare both strings one code-point at a time using the integer
* value of each code-point after applying `toUpperCase` to each string. We always map both
* strings to their upper-case form as some unicode characters do not properly round-trip to
* lowercase (such as `` (German sharp capital s)).
* lowercase (such as `ẞ` (German sharp capital s)).
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this intentional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what caused that to change, but I'll revert.

*/
export function equateStringsCaseInsensitive(a: string, b: string) {
return a === b
Expand Down Expand Up @@ -1800,7 +1800,7 @@ namespace ts {
* Case-insensitive comparisons compare both strings one code-point at a time using the integer
* value of each code-point after applying `toUpperCase` to each string. We always map both
* strings to their upper-case form as some unicode characters do not properly round-trip to
* lowercase (such as `` (German sharp capital s)).
* lowercase (such as `ẞ` (German sharp capital s)).
*/
export function compareStringsCaseInsensitive(a: string, b: string) {
if (a === b) return Comparison.EqualTo;
Expand Down Expand Up @@ -1872,7 +1872,7 @@ namespace ts {
//
// For case insensitive comparisons we always map both strings to their
// upper-case form as some unicode characters do not properly round-trip to
// lowercase (such as `` (German sharp capital s)).
// lowercase (such as `ẞ` (German sharp capital s)).
return (a, b) => compareWithCallback(a, b, compareDictionaryOrder);

function compareDictionaryOrder(a: string, b: string) {
Expand Down
9 changes: 7 additions & 2 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2357,14 +2357,19 @@
"category": "Error",
"code": 2724
},
"Cannot find lib definition for '{0}'.": {
"Class name cannot be 'Object' when targeting ES5 with module {0}.": {
"category": "Error",
"code": 2725
},
"Cannot find lib definition for '{0}'. Did you mean '{1}'?": {
"Cannot find lib definition for '{0}'.": {
"category": "Error",
"code": 2726
},
"Cannot find lib definition for '{0}'. Did you mean '{1}'?": {
"category": "Error",
"code": 2727
},

"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
"code": 4000
Expand Down
8 changes: 4 additions & 4 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7762,11 +7762,11 @@ 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.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 });
else if (arg!.arguments.path) {
referencedFiles.push({ pos: arg!.arguments.path!.pos, end: arg!.arguments.path!.end, fileName: arg!.arguments.path!.value });
}
else {
reportDiagnostic(arg!.range.pos, arg!.range.end - arg!.range.pos, Diagnostics.Invalid_reference_directive_syntax);
Expand Down
16 changes: 8 additions & 8 deletions src/compiler/program.ts
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ namespace ts {
let program: Program;
let processingDefaultLibFiles: SourceFile[] | undefined;
let processingOtherFiles: SourceFile[] | undefined;
let files: SourceFile[] | undefined;
let files: SourceFile[];
let commonSourceDirectory: string;
let diagnosticsProducingTypeChecker: TypeChecker;
let noDiagnosticsTypeChecker: TypeChecker;
Expand Down Expand Up @@ -736,7 +736,7 @@ namespace ts {
return libs.length + 2;
}

function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string): ResolvedModuleWithFailedLookupLocations {
function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined {
return moduleResolutionCache && resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache);
}

Expand Down Expand Up @@ -1894,7 +1894,7 @@ namespace ts {
/** This has side effects through `findSourceFile`. */
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, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId),
fileName => findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile!, refPos!, refEnd!, packageId), // TODO: GH#18217
(diagnostic, ...args) => {
fileProcessingDiagnostics.add(refFile !== undefined && refEnd !== undefined && refPos !== undefined
? createFileDiagnostic(refFile, refPos, refEnd - refPos, diagnostic, ...args)
Expand Down Expand Up @@ -2002,7 +2002,7 @@ namespace ts {
redirectTargetsSet.set(fileFromPackageId.path, true);
filesByName.set(path, dupFile);
sourceFileToPackageName.set(path, packageId.name);
processingOtherFiles.push(dupFile);
processingOtherFiles!.push(dupFile);
return dupFile;
}
else if (file) {
Expand Down Expand Up @@ -2046,10 +2046,10 @@ namespace ts {
processImportedModules(file);

if (isDefaultLib) {
processingDefaultLibFiles.push(file);
processingDefaultLibFiles!.push(file);
}
else {
processingOtherFiles.push(file);
processingOtherFiles!.push(file);
}
}

Expand Down Expand Up @@ -2111,7 +2111,7 @@ namespace ts {
if (resolvedTypeReferenceDirective) {
if (resolvedTypeReferenceDirective.primary) {
// resolved from the primary path
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd);
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName!, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); // TODO: GH#18217
}
else {
// If we already resolved to this file, it must have been a secondary reference. Check file contents
Expand All @@ -2134,7 +2134,7 @@ namespace ts {
}
else {
// First resolution of this library
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd);
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName!, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/harness/unittests/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ namespace ts {
function baselineDeclarationTransform(text: string, opts: TranspileOptions) {
const fs = vfs.createFromFileSystem(Harness.IO, /*caseSensitive*/ true, { documents: [new documents.TextDocument("/.src/index.ts", text)] });
const host = new fakes.CompilerHost(fs, opts.compilerOptions);
const program = createProgram(["/.src/index.ts"], opts.compilerOptions, host);
const program = createProgram(["/.src/index.ts"], opts.compilerOptions!, host);
program.emit(program.getSourceFile("/.src/index.ts"), (p, s, bom) => host.writeFile(p, s, bom), /*cancellationToken*/ undefined, /*onlyDts*/ true, opts.transformers);
return fs.readFileSync("/.src/index.d.ts").toString();
}
Expand Down
4 changes: 2 additions & 2 deletions src/services/preProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ namespace ts {
importedFiles.push(decl.ref);
}
}
return { referencedFiles: pragmaContext.referencedFiles, typeReferenceDirectives: pragmaContext.typeReferenceDirectives, libReferenceDirectives: pragmaContext.libReferenceDirectives, 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
Expand All @@ -355,7 +355,7 @@ namespace ts {
}
}
}
return { referencedFiles: pragmaContext.referencedFiles, typeReferenceDirectives: pragmaContext.typeReferenceDirectives, libReferenceDirectives: pragmaContext.libReferenceDirectives, importedFiles, isLibFile: pragmaContext.hasNoDefaultLib, ambientExternalModules: ambientModuleNames };
return { referencedFiles: pragmaContext.referencedFiles, typeReferenceDirectives: pragmaContext.typeReferenceDirectives, libReferenceDirectives: pragmaContext.libReferenceDirectives, importedFiles, isLibFile: !!pragmaContext.hasNoDefaultLib, ambientExternalModules: ambientModuleNames };
}
}
}
2 changes: 1 addition & 1 deletion tests/baselines/reference/collectionPatternNoError.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface MsgConstructor<T extends Message> {

new(data: Array<{}>): T;
>data : Symbol(data, Decl(collectionPatternNoError.ts, 1, 6))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>T : Symbol(T, Decl(collectionPatternNoError.ts, 0, 25))
}
class Message {
Expand Down
12 changes: 6 additions & 6 deletions tests/baselines/reference/enumConstantMembers.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ enum E5 {

e = NaN,
>e : Symbol(E5.e, Decl(enumConstantMembers.ts, 24, 18))
>NaN : Symbol(NaN, Decl(lib.d.ts, --, --))
>NaN : Symbol(NaN, Decl(lib.es5.d.ts, --, --))

f = Infinity,
>f : Symbol(E5.f, Decl(enumConstantMembers.ts, 25, 12))
>Infinity : Symbol(Infinity, Decl(lib.d.ts, --, --))
>Infinity : Symbol(Infinity, Decl(lib.es5.d.ts, --, --))

g = -Infinity
>g : Symbol(E5.g, Decl(enumConstantMembers.ts, 26, 17))
>Infinity : Symbol(Infinity, Decl(lib.d.ts, --, --))
>Infinity : Symbol(Infinity, Decl(lib.es5.d.ts, --, --))
}

const enum E6 {
Expand All @@ -86,14 +86,14 @@ const enum E6 {

e = NaN,
>e : Symbol(E6.e, Decl(enumConstantMembers.ts, 34, 18))
>NaN : Symbol(NaN, Decl(lib.d.ts, --, --))
>NaN : Symbol(NaN, Decl(lib.es5.d.ts, --, --))

f = Infinity,
>f : Symbol(E6.f, Decl(enumConstantMembers.ts, 35, 12))
>Infinity : Symbol(Infinity, Decl(lib.d.ts, --, --))
>Infinity : Symbol(Infinity, Decl(lib.es5.d.ts, --, --))

g = -Infinity
>g : Symbol(E6.g, Decl(enumConstantMembers.ts, 36, 17))
>Infinity : Symbol(Infinity, Decl(lib.d.ts, --, --))
>Infinity : Symbol(Infinity, Decl(lib.es5.d.ts, --, --))
}

30 changes: 15 additions & 15 deletions tests/baselines/reference/intersectionsOfLargeUnions.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
export function assertIsElement(node: Node | null): node is Element {
>assertIsElement : Symbol(assertIsElement, Decl(intersectionsOfLargeUnions.ts, 0, 0))
>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 2, 32))
>Node : Symbol(Node, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Node : Symbol(Node, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 2, 32))
>Element : Symbol(Element, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Element : Symbol(Element, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))

let nodeType = node === null ? null : node.nodeType;
>nodeType : Symbol(nodeType, Decl(intersectionsOfLargeUnions.ts, 3, 7))
>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 2, 32))
>node.nodeType : Symbol(Node.nodeType, Decl(lib.d.ts, --, --))
>node.nodeType : Symbol(Node.nodeType, Decl(lib.dom.d.ts, --, --))
>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 2, 32))
>nodeType : Symbol(Node.nodeType, Decl(lib.d.ts, --, --))
>nodeType : Symbol(Node.nodeType, Decl(lib.dom.d.ts, --, --))

return nodeType === 1;
>nodeType : Symbol(nodeType, Decl(intersectionsOfLargeUnions.ts, 3, 7))
Expand All @@ -24,14 +24,14 @@ export function assertNodeTagName<

T extends keyof ElementTagNameMap,
>T : Symbol(T, Decl(intersectionsOfLargeUnions.ts, 7, 34))
>ElementTagNameMap : Symbol(ElementTagNameMap, Decl(lib.d.ts, --, --))
>ElementTagNameMap : Symbol(ElementTagNameMap, Decl(lib.dom.d.ts, --, --))

U extends ElementTagNameMap[T]>(node: Node | null, tagName: T): node is U {
>U : Symbol(U, Decl(intersectionsOfLargeUnions.ts, 8, 38))
>ElementTagNameMap : Symbol(ElementTagNameMap, Decl(lib.d.ts, --, --))
>ElementTagNameMap : Symbol(ElementTagNameMap, Decl(lib.dom.d.ts, --, --))
>T : Symbol(T, Decl(intersectionsOfLargeUnions.ts, 7, 34))
>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 9, 36))
>Node : Symbol(Node, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Node : Symbol(Node, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
>tagName : Symbol(tagName, Decl(intersectionsOfLargeUnions.ts, 9, 54))
>T : Symbol(T, Decl(intersectionsOfLargeUnions.ts, 7, 34))
>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 9, 36))
Expand All @@ -43,11 +43,11 @@ export function assertNodeTagName<

const nodeTagName = node.tagName.toLowerCase();
>nodeTagName : Symbol(nodeTagName, Decl(intersectionsOfLargeUnions.ts, 11, 13))
>node.tagName.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --))
>node.tagName : Symbol(Element.tagName, Decl(lib.d.ts, --, --))
>node.tagName.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
>node.tagName : Symbol(Element.tagName, Decl(lib.dom.d.ts, --, --))
>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 9, 36))
>tagName : Symbol(Element.tagName, Decl(lib.d.ts, --, --))
>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --))
>tagName : Symbol(Element.tagName, Decl(lib.dom.d.ts, --, --))
>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))

return nodeTagName === tagName;
>nodeTagName : Symbol(nodeTagName, Decl(intersectionsOfLargeUnions.ts, 11, 13))
Expand All @@ -61,20 +61,20 @@ export function assertNodeProperty<

T extends keyof ElementTagNameMap,
>T : Symbol(T, Decl(intersectionsOfLargeUnions.ts, 17, 35))
>ElementTagNameMap : Symbol(ElementTagNameMap, Decl(lib.d.ts, --, --))
>ElementTagNameMap : Symbol(ElementTagNameMap, Decl(lib.dom.d.ts, --, --))

P extends keyof ElementTagNameMap[T],
>P : Symbol(P, Decl(intersectionsOfLargeUnions.ts, 18, 38))
>ElementTagNameMap : Symbol(ElementTagNameMap, Decl(lib.d.ts, --, --))
>ElementTagNameMap : Symbol(ElementTagNameMap, Decl(lib.dom.d.ts, --, --))
>T : Symbol(T, Decl(intersectionsOfLargeUnions.ts, 17, 35))

V extends HTMLElementTagNameMap[T][P]>(node: Node | null, tagName: T, prop: P, value: V) {
>V : Symbol(V, Decl(intersectionsOfLargeUnions.ts, 19, 41))
>HTMLElementTagNameMap : Symbol(HTMLElementTagNameMap, Decl(lib.d.ts, --, --))
>HTMLElementTagNameMap : Symbol(HTMLElementTagNameMap, Decl(lib.dom.d.ts, --, --))
>T : Symbol(T, Decl(intersectionsOfLargeUnions.ts, 17, 35))
>P : Symbol(P, Decl(intersectionsOfLargeUnions.ts, 18, 38))
>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 20, 43))
>Node : Symbol(Node, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Node : Symbol(Node, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
>tagName : Symbol(tagName, Decl(intersectionsOfLargeUnions.ts, 20, 61))
>T : Symbol(T, Decl(intersectionsOfLargeUnions.ts, 17, 35))
>prop : Symbol(prop, Decl(intersectionsOfLargeUnions.ts, 20, 73))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ Zet.prototype.add = function(v, id) {
>Zet.prototype : Symbol(Zet.add, Decl(templateTagOnConstructorFunctions.js, 12, 1))
>Zet : Symbol(Zet, Decl(templateTagOnConstructorFunctions.js, 0, 0))
>prototype : Symbol(Function.prototype, Decl(lib.es5.d.ts, --, --))
>add : Symbol(Zet.add, Decl(templateTagOnConstructorFunctions.js, 9, 1))
>v : Symbol(v, Decl(templateTagOnConstructorFunctions.js, 14, 29))
>id : Symbol(id, Decl(templateTagOnConstructorFunctions.js, 14, 31))
>add : Symbol(Zet.add, Decl(templateTagOnConstructorFunctions.js, 12, 1))
>v : Symbol(v, Decl(templateTagOnConstructorFunctions.js, 17, 29))
>id : Symbol(id, Decl(templateTagOnConstructorFunctions.js, 17, 31))

this.u = v || this.t
>this.u : Symbol(Zet.u, Decl(templateTagOnConstructorFunctions.js, 8, 17), Decl(templateTagOnConstructorFunctions.js, 17, 37))
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.