From 3c59481a92370f2c11c512f447bef21d6aec8f1f Mon Sep 17 00:00:00 2001 From: Zhengbo Li Date: Thu, 4 Jun 2015 16:06:12 -0700 Subject: [PATCH 01/18] Add missing overloads for texImage2D and texSubImage2D --- src/lib/dom.generated.d.ts | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/lib/dom.generated.d.ts b/src/lib/dom.generated.d.ts index 5a4151c0c1c..e1f06f11009 100644 --- a/src/lib/dom.generated.d.ts +++ b/src/lib/dom.generated.d.ts @@ -7677,10 +7677,10 @@ declare var MediaQueryList: { interface MediaSource extends EventTarget { activeSourceBuffers: SourceBufferList; duration: number; - readyState: string; + readyState: number; sourceBuffers: SourceBufferList; addSourceBuffer(type: string): SourceBuffer; - endOfStream(error?: string): void; + endOfStream(error?: number): void; removeSourceBuffer(sourceBuffer: SourceBuffer): void; } @@ -8409,7 +8409,7 @@ declare var PopStateEvent: { interface Position { coords: Coordinates; - timestamp: Date; + timestamp: number; } declare var Position: { @@ -11090,9 +11090,17 @@ interface WebGLRenderingContext { stencilMaskSeparate(face: number, mask: number): void; stencilOp(fail: number, zfail: number, zpass: number): void; stencilOpSeparate(face: number, fail: number, zfail: number, zpass: number): void; + texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels: ArrayBufferView): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, image: HTMLImageElement): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, canvas: HTMLCanvasElement): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, video: HTMLVideoElement): void; texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageData): void; texParameterf(target: number, pname: number, param: number): void; texParameteri(target: number, pname: number, param: number): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, image: HTMLImageElement): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, canvas: HTMLCanvasElement): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, video: HTMLVideoElement): void; texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageData): void; uniform1f(location: WebGLUniformLocation, x: number): void; uniform1fv(location: WebGLUniformLocation, v: any): void; @@ -12332,10 +12340,11 @@ interface DocumentEvent { createEvent(eventInterface:"AriaRequestEvent"): AriaRequestEvent; createEvent(eventInterface:"AudioProcessingEvent"): AudioProcessingEvent; createEvent(eventInterface:"BeforeUnloadEvent"): BeforeUnloadEvent; + createEvent(eventInterface:"ClipboardEvent"): ClipboardEvent; createEvent(eventInterface:"CloseEvent"): CloseEvent; createEvent(eventInterface:"CommandEvent"): CommandEvent; createEvent(eventInterface:"CompositionEvent"): CompositionEvent; - createEvent(eventInterface: "CustomEvent"): CustomEvent; + createEvent(eventInterface:"CustomEvent"): CustomEvent; createEvent(eventInterface:"DeviceMotionEvent"): DeviceMotionEvent; createEvent(eventInterface:"DeviceOrientationEvent"): DeviceOrientationEvent; createEvent(eventInterface:"DragEvent"): DragEvent; @@ -12358,8 +12367,6 @@ interface DocumentEvent { createEvent(eventInterface:"MouseEvent"): MouseEvent; createEvent(eventInterface:"MouseEvents"): MouseEvent; createEvent(eventInterface:"MouseWheelEvent"): MouseWheelEvent; - createEvent(eventInterface:"MSGestureEvent"): MSGestureEvent; - createEvent(eventInterface:"MSPointerEvent"): MSPointerEvent; createEvent(eventInterface:"MutationEvent"): MutationEvent; createEvent(eventInterface:"MutationEvents"): MutationEvent; createEvent(eventInterface:"NavigationCompletedEvent"): NavigationCompletedEvent; @@ -12971,4 +12978,4 @@ declare function addEventListener(type: "unload", listener: (ev: Event) => any, declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; \ No newline at end of file +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; From 6f45524b9ff0f35ac75dd7889ee817bcbb14fe50 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 4 Jun 2015 16:35:30 -0700 Subject: [PATCH 02/18] Update LKG --- bin/lib.d.ts | 20 ++++++++++++++------ bin/lib.dom.d.ts | 21 ++++++++++++++------- bin/lib.es6.d.ts | 20 ++++++++++++++------ bin/tsc.js | 13 +++++++++---- bin/tsserver.js | 13 +++++++++---- bin/typescript.js | 18 ++++++++++++++---- bin/typescriptServices.js | 18 ++++++++++++++---- 7 files changed, 88 insertions(+), 35 deletions(-) diff --git a/bin/lib.d.ts b/bin/lib.d.ts index e583f1ac783..4724459e73d 100644 --- a/bin/lib.d.ts +++ b/bin/lib.d.ts @@ -11335,10 +11335,10 @@ declare var MediaQueryList: { interface MediaSource extends EventTarget { activeSourceBuffers: SourceBufferList; duration: number; - readyState: string; + readyState: number; sourceBuffers: SourceBufferList; addSourceBuffer(type: string): SourceBuffer; - endOfStream(error?: string): void; + endOfStream(error?: number): void; removeSourceBuffer(sourceBuffer: SourceBuffer): void; } @@ -12067,7 +12067,7 @@ declare var PopStateEvent: { interface Position { coords: Coordinates; - timestamp: Date; + timestamp: number; } declare var Position: { @@ -14748,9 +14748,17 @@ interface WebGLRenderingContext { stencilMaskSeparate(face: number, mask: number): void; stencilOp(fail: number, zfail: number, zpass: number): void; stencilOpSeparate(face: number, fail: number, zfail: number, zpass: number): void; + texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels: ArrayBufferView): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, image: HTMLImageElement): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, canvas: HTMLCanvasElement): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, video: HTMLVideoElement): void; texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageData): void; texParameterf(target: number, pname: number, param: number): void; texParameteri(target: number, pname: number, param: number): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, image: HTMLImageElement): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, canvas: HTMLCanvasElement): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, video: HTMLVideoElement): void; texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageData): void; uniform1f(location: WebGLUniformLocation, x: number): void; uniform1fv(location: WebGLUniformLocation, v: any): void; @@ -15990,10 +15998,11 @@ interface DocumentEvent { createEvent(eventInterface:"AriaRequestEvent"): AriaRequestEvent; createEvent(eventInterface:"AudioProcessingEvent"): AudioProcessingEvent; createEvent(eventInterface:"BeforeUnloadEvent"): BeforeUnloadEvent; + createEvent(eventInterface:"ClipboardEvent"): ClipboardEvent; createEvent(eventInterface:"CloseEvent"): CloseEvent; createEvent(eventInterface:"CommandEvent"): CommandEvent; createEvent(eventInterface:"CompositionEvent"): CompositionEvent; - createEvent(eventInterface: "CustomEvent"): CustomEvent; + createEvent(eventInterface:"CustomEvent"): CustomEvent; createEvent(eventInterface:"DeviceMotionEvent"): DeviceMotionEvent; createEvent(eventInterface:"DeviceOrientationEvent"): DeviceOrientationEvent; createEvent(eventInterface:"DragEvent"): DragEvent; @@ -16016,8 +16025,6 @@ interface DocumentEvent { createEvent(eventInterface:"MouseEvent"): MouseEvent; createEvent(eventInterface:"MouseEvents"): MouseEvent; createEvent(eventInterface:"MouseWheelEvent"): MouseWheelEvent; - createEvent(eventInterface:"MSGestureEvent"): MSGestureEvent; - createEvent(eventInterface:"MSPointerEvent"): MSPointerEvent; createEvent(eventInterface:"MutationEvent"): MutationEvent; createEvent(eventInterface:"MutationEvents"): MutationEvent; createEvent(eventInterface:"NavigationCompletedEvent"): NavigationCompletedEvent; @@ -16630,6 +16637,7 @@ declare function addEventListener(type: "volumechange", listener: (ev: Event) => declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + ///////////////////////////// /// WorkerGlobalScope APIs ///////////////////////////// diff --git a/bin/lib.dom.d.ts b/bin/lib.dom.d.ts index 142486a1662..7d83676acc7 100644 --- a/bin/lib.dom.d.ts +++ b/bin/lib.dom.d.ts @@ -10165,10 +10165,10 @@ declare var MediaQueryList: { interface MediaSource extends EventTarget { activeSourceBuffers: SourceBufferList; duration: number; - readyState: string; + readyState: number; sourceBuffers: SourceBufferList; addSourceBuffer(type: string): SourceBuffer; - endOfStream(error?: string): void; + endOfStream(error?: number): void; removeSourceBuffer(sourceBuffer: SourceBuffer): void; } @@ -10897,7 +10897,7 @@ declare var PopStateEvent: { interface Position { coords: Coordinates; - timestamp: Date; + timestamp: number; } declare var Position: { @@ -13578,9 +13578,17 @@ interface WebGLRenderingContext { stencilMaskSeparate(face: number, mask: number): void; stencilOp(fail: number, zfail: number, zpass: number): void; stencilOpSeparate(face: number, fail: number, zfail: number, zpass: number): void; + texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels: ArrayBufferView): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, image: HTMLImageElement): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, canvas: HTMLCanvasElement): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, video: HTMLVideoElement): void; texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageData): void; texParameterf(target: number, pname: number, param: number): void; texParameteri(target: number, pname: number, param: number): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, image: HTMLImageElement): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, canvas: HTMLCanvasElement): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, video: HTMLVideoElement): void; texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageData): void; uniform1f(location: WebGLUniformLocation, x: number): void; uniform1fv(location: WebGLUniformLocation, v: any): void; @@ -14820,10 +14828,11 @@ interface DocumentEvent { createEvent(eventInterface:"AriaRequestEvent"): AriaRequestEvent; createEvent(eventInterface:"AudioProcessingEvent"): AudioProcessingEvent; createEvent(eventInterface:"BeforeUnloadEvent"): BeforeUnloadEvent; + createEvent(eventInterface:"ClipboardEvent"): ClipboardEvent; createEvent(eventInterface:"CloseEvent"): CloseEvent; createEvent(eventInterface:"CommandEvent"): CommandEvent; createEvent(eventInterface:"CompositionEvent"): CompositionEvent; - createEvent(eventInterface: "CustomEvent"): CustomEvent; + createEvent(eventInterface:"CustomEvent"): CustomEvent; createEvent(eventInterface:"DeviceMotionEvent"): DeviceMotionEvent; createEvent(eventInterface:"DeviceOrientationEvent"): DeviceOrientationEvent; createEvent(eventInterface:"DragEvent"): DragEvent; @@ -14846,8 +14855,6 @@ interface DocumentEvent { createEvent(eventInterface:"MouseEvent"): MouseEvent; createEvent(eventInterface:"MouseEvents"): MouseEvent; createEvent(eventInterface:"MouseWheelEvent"): MouseWheelEvent; - createEvent(eventInterface:"MSGestureEvent"): MSGestureEvent; - createEvent(eventInterface:"MSPointerEvent"): MSPointerEvent; createEvent(eventInterface:"MutationEvent"): MutationEvent; createEvent(eventInterface:"MutationEvents"): MutationEvent; createEvent(eventInterface:"NavigationCompletedEvent"): NavigationCompletedEvent; @@ -15459,4 +15466,4 @@ declare function addEventListener(type: "unload", listener: (ev: Event) => any, declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; \ No newline at end of file +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; diff --git a/bin/lib.es6.d.ts b/bin/lib.es6.d.ts index d6ca7245140..396361a49f5 100644 --- a/bin/lib.es6.d.ts +++ b/bin/lib.es6.d.ts @@ -12716,10 +12716,10 @@ declare var MediaQueryList: { interface MediaSource extends EventTarget { activeSourceBuffers: SourceBufferList; duration: number; - readyState: string; + readyState: number; sourceBuffers: SourceBufferList; addSourceBuffer(type: string): SourceBuffer; - endOfStream(error?: string): void; + endOfStream(error?: number): void; removeSourceBuffer(sourceBuffer: SourceBuffer): void; } @@ -13448,7 +13448,7 @@ declare var PopStateEvent: { interface Position { coords: Coordinates; - timestamp: Date; + timestamp: number; } declare var Position: { @@ -16129,9 +16129,17 @@ interface WebGLRenderingContext { stencilMaskSeparate(face: number, mask: number): void; stencilOp(fail: number, zfail: number, zpass: number): void; stencilOpSeparate(face: number, fail: number, zfail: number, zpass: number): void; + texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels: ArrayBufferView): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, image: HTMLImageElement): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, canvas: HTMLCanvasElement): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, video: HTMLVideoElement): void; texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageData): void; texParameterf(target: number, pname: number, param: number): void; texParameteri(target: number, pname: number, param: number): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, image: HTMLImageElement): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, canvas: HTMLCanvasElement): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, video: HTMLVideoElement): void; texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageData): void; uniform1f(location: WebGLUniformLocation, x: number): void; uniform1fv(location: WebGLUniformLocation, v: any): void; @@ -17371,10 +17379,11 @@ interface DocumentEvent { createEvent(eventInterface:"AriaRequestEvent"): AriaRequestEvent; createEvent(eventInterface:"AudioProcessingEvent"): AudioProcessingEvent; createEvent(eventInterface:"BeforeUnloadEvent"): BeforeUnloadEvent; + createEvent(eventInterface:"ClipboardEvent"): ClipboardEvent; createEvent(eventInterface:"CloseEvent"): CloseEvent; createEvent(eventInterface:"CommandEvent"): CommandEvent; createEvent(eventInterface:"CompositionEvent"): CompositionEvent; - createEvent(eventInterface: "CustomEvent"): CustomEvent; + createEvent(eventInterface:"CustomEvent"): CustomEvent; createEvent(eventInterface:"DeviceMotionEvent"): DeviceMotionEvent; createEvent(eventInterface:"DeviceOrientationEvent"): DeviceOrientationEvent; createEvent(eventInterface:"DragEvent"): DragEvent; @@ -17397,8 +17406,6 @@ interface DocumentEvent { createEvent(eventInterface:"MouseEvent"): MouseEvent; createEvent(eventInterface:"MouseEvents"): MouseEvent; createEvent(eventInterface:"MouseWheelEvent"): MouseWheelEvent; - createEvent(eventInterface:"MSGestureEvent"): MSGestureEvent; - createEvent(eventInterface:"MSPointerEvent"): MSPointerEvent; createEvent(eventInterface:"MutationEvent"): MutationEvent; createEvent(eventInterface:"MutationEvents"): MutationEvent; createEvent(eventInterface:"NavigationCompletedEvent"): NavigationCompletedEvent; @@ -18011,6 +18018,7 @@ declare function addEventListener(type: "volumechange", listener: (ev: Event) => declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + ///////////////////////////// /// WorkerGlobalScope APIs ///////////////////////////// diff --git a/bin/tsc.js b/bin/tsc.js index a6d28976046..e7a41e8aa7e 100644 --- a/bin/tsc.js +++ b/bin/tsc.js @@ -21533,7 +21533,12 @@ var ts; return result; } function parenthesizeForAccess(expr) { - if (ts.isLeftHandSideExpression(expr) && expr.kind !== 159 && expr.kind !== 7) { + while (expr.kind === 161) { + expr = expr.expression; + } + if (ts.isLeftHandSideExpression(expr) && + expr.kind !== 159 && + expr.kind !== 7) { return expr; } var node = ts.createSynthesizedNode(162); @@ -21740,7 +21745,7 @@ var ts; } } function emitParenExpression(node) { - if (!node.parent || node.parent.kind !== 164) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 164) { if (node.expression.kind === 161) { var operand = node.expression.expression; while (operand.kind == 161) { @@ -23727,7 +23732,7 @@ var ts; emitDeclarationName(node); write("\", "); emitDeclarationName(node); - write(")"); + write(");"); } emitExportMemberAssignments(node.name); } @@ -23835,7 +23840,7 @@ var ts; emitDeclarationName(node); write("\", "); emitDeclarationName(node); - write(")"); + write(");"); } emitExportMemberAssignments(node.name); } diff --git a/bin/tsserver.js b/bin/tsserver.js index 194f0768196..8536491127d 100644 --- a/bin/tsserver.js +++ b/bin/tsserver.js @@ -21923,7 +21923,12 @@ var ts; return result; } function parenthesizeForAccess(expr) { - if (ts.isLeftHandSideExpression(expr) && expr.kind !== 159 && expr.kind !== 7) { + while (expr.kind === 161) { + expr = expr.expression; + } + if (ts.isLeftHandSideExpression(expr) && + expr.kind !== 159 && + expr.kind !== 7) { return expr; } var node = ts.createSynthesizedNode(162); @@ -22130,7 +22135,7 @@ var ts; } } function emitParenExpression(node) { - if (!node.parent || node.parent.kind !== 164) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 164) { if (node.expression.kind === 161) { var operand = node.expression.expression; while (operand.kind == 161) { @@ -24117,7 +24122,7 @@ var ts; emitDeclarationName(node); write("\", "); emitDeclarationName(node); - write(")"); + write(");"); } emitExportMemberAssignments(node.name); } @@ -24225,7 +24230,7 @@ var ts; emitDeclarationName(node); write("\", "); emitDeclarationName(node); - write(")"); + write(");"); } emitExportMemberAssignments(node.name); } diff --git a/bin/typescript.js b/bin/typescript.js index dac610e2504..b393f2ee881 100644 --- a/bin/typescript.js +++ b/bin/typescript.js @@ -25628,6 +25628,11 @@ var ts; return result; } function parenthesizeForAccess(expr) { + // When diagnosing whether the expression needs parentheses, the decision should be based + // on the innermost expression in a chain of nested type assertions. + while (expr.kind === 161 /* TypeAssertionExpression */) { + expr = expr.expression; + } // isLeftHandSideExpression is almost the correct criterion for when it is not necessary // to parenthesize the expression before a dot. The known exceptions are: // @@ -25636,7 +25641,9 @@ var ts; // NumberLiteral // 1.x -> not the same as (1).x // - if (ts.isLeftHandSideExpression(expr) && expr.kind !== 159 /* NewExpression */ && expr.kind !== 7 /* NumericLiteral */) { + if (ts.isLeftHandSideExpression(expr) && + expr.kind !== 159 /* NewExpression */ && + expr.kind !== 7 /* NumericLiteral */) { return expr; } var node = ts.createSynthesizedNode(162 /* ParenthesizedExpression */); @@ -25867,7 +25874,10 @@ var ts; } } function emitParenExpression(node) { - if (!node.parent || node.parent.kind !== 164 /* ArrowFunction */) { + // If the node is synthesized, it means the emitter put the parentheses there, + // not the user. If we didn't want them, the emitter would not have put them + // there. + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 164 /* ArrowFunction */) { if (node.expression.kind === 161 /* TypeAssertionExpression */) { var operand = node.expression.expression; // Make sure we consider all nested cast expressions, e.g.: @@ -28149,7 +28159,7 @@ var ts; emitDeclarationName(node); write("\", "); emitDeclarationName(node); - write(")"); + write(");"); } emitExportMemberAssignments(node.name); } @@ -28259,7 +28269,7 @@ var ts; emitDeclarationName(node); write("\", "); emitDeclarationName(node); - write(")"); + write(");"); } emitExportMemberAssignments(node.name); } diff --git a/bin/typescriptServices.js b/bin/typescriptServices.js index dac610e2504..b393f2ee881 100644 --- a/bin/typescriptServices.js +++ b/bin/typescriptServices.js @@ -25628,6 +25628,11 @@ var ts; return result; } function parenthesizeForAccess(expr) { + // When diagnosing whether the expression needs parentheses, the decision should be based + // on the innermost expression in a chain of nested type assertions. + while (expr.kind === 161 /* TypeAssertionExpression */) { + expr = expr.expression; + } // isLeftHandSideExpression is almost the correct criterion for when it is not necessary // to parenthesize the expression before a dot. The known exceptions are: // @@ -25636,7 +25641,9 @@ var ts; // NumberLiteral // 1.x -> not the same as (1).x // - if (ts.isLeftHandSideExpression(expr) && expr.kind !== 159 /* NewExpression */ && expr.kind !== 7 /* NumericLiteral */) { + if (ts.isLeftHandSideExpression(expr) && + expr.kind !== 159 /* NewExpression */ && + expr.kind !== 7 /* NumericLiteral */) { return expr; } var node = ts.createSynthesizedNode(162 /* ParenthesizedExpression */); @@ -25867,7 +25874,10 @@ var ts; } } function emitParenExpression(node) { - if (!node.parent || node.parent.kind !== 164 /* ArrowFunction */) { + // If the node is synthesized, it means the emitter put the parentheses there, + // not the user. If we didn't want them, the emitter would not have put them + // there. + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 164 /* ArrowFunction */) { if (node.expression.kind === 161 /* TypeAssertionExpression */) { var operand = node.expression.expression; // Make sure we consider all nested cast expressions, e.g.: @@ -28149,7 +28159,7 @@ var ts; emitDeclarationName(node); write("\", "); emitDeclarationName(node); - write(")"); + write(");"); } emitExportMemberAssignments(node.name); } @@ -28259,7 +28269,7 @@ var ts; emitDeclarationName(node); write("\", "); emitDeclarationName(node); - write(")"); + write(");"); } emitExportMemberAssignments(node.name); } From 7c8a50336d6c1bb56d0daef91cf52d05fc12ff56 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 3 Jun 2015 14:55:42 -0700 Subject: [PATCH 03/18] emit module name for system modules, add moduleName argument to 'transpile' function Conflicts: src/services/services.ts --- src/compiler/emitter.ts | 10 +++++++--- src/compiler/parser.ts | 2 +- src/compiler/types.ts | 2 +- src/services/services.ts | 7 +++++-- .../baselines/reference/systemModule12.errors.txt | 10 ++++++++++ tests/baselines/reference/systemModule12.js | 14 ++++++++++++++ tests/cases/compiler/systemModule12.ts | 5 +++++ 7 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 tests/baselines/reference/systemModule12.errors.txt create mode 100644 tests/baselines/reference/systemModule12.js create mode 100644 tests/cases/compiler/systemModule12.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 165f0da5cfd..7d0a29f9e26 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -5477,7 +5477,11 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { Debug.assert(!exportFunctionForFile); // make sure that name of 'exports' function does not conflict with existing identifiers exportFunctionForFile = makeUniqueName("exports"); - write("System.register(["); + write("System.register("); + if (node.moduleName) { + write(`"${node.moduleName}", `); + } + write("[") for (let i = 0; i < externalImports.length; ++i) { let text = getExternalModuleNameText(externalImports[i]); if (i !== 0) { @@ -5563,8 +5567,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { writeLine(); write("define("); - if (node.amdModuleName) { - write("\"" + node.amdModuleName + "\", "); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); } emitAMDDependencies(node, /*includeNonAmdDependencies*/ true); write(") {"); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 055fc1b6f74..07da065c1ae 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4820,7 +4820,7 @@ module ts { sourceFile.referencedFiles = referencedFiles; sourceFile.amdDependencies = amdDependencies; - sourceFile.amdModuleName = amdModuleName; + sourceFile.moduleName = amdModuleName; } function setExternalModuleIndicator(sourceFile: SourceFile) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1db5e57d298..1a72e9fc94a 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1001,7 +1001,7 @@ module ts { text: string; amdDependencies: {path: string; name: string}[]; - amdModuleName: string; + moduleName: string; referencedFiles: FileReference[]; hasNoDefaultLib: boolean; diff --git a/src/services/services.ts b/src/services/services.ts index 6a497c87307..ece411ae1ea 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -735,7 +735,7 @@ module ts { public endOfFileToken: Node; public amdDependencies: { name: string; path: string }[]; - public amdModuleName: string; + public moduleName: string; public referencedFiles: FileReference[]; public syntacticDiagnostics: Diagnostic[]; @@ -1766,7 +1766,7 @@ module ts { * - noLib = true * - noResolve = true */ - export function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string { + export function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string { let options = compilerOptions ? clone(compilerOptions) : getDefaultCompilerOptions(); options.isolatedModules = true; @@ -1785,6 +1785,9 @@ module ts { // Parse let inputFileName = fileName || "module.ts"; let sourceFile = createSourceFile(inputFileName, input, options.target); + if (moduleName) { + sourceFile.moduleName = moduleName; + } // Store syntactic diagnostics if (diagnostics && sourceFile.parseDiagnostics) { diff --git a/tests/baselines/reference/systemModule12.errors.txt b/tests/baselines/reference/systemModule12.errors.txt new file mode 100644 index 00000000000..5c89e2e65d6 --- /dev/null +++ b/tests/baselines/reference/systemModule12.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/systemModule12.ts(3,15): error TS2307: Cannot find module 'file1'. + + +==== tests/cases/compiler/systemModule12.ts (1 errors) ==== + + /// + import n from 'file1' + ~~~~~~~ +!!! error TS2307: Cannot find module 'file1'. + \ No newline at end of file diff --git a/tests/baselines/reference/systemModule12.js b/tests/baselines/reference/systemModule12.js new file mode 100644 index 00000000000..0b5f5a3e850 --- /dev/null +++ b/tests/baselines/reference/systemModule12.js @@ -0,0 +1,14 @@ +//// [systemModule12.ts] + +/// +import n from 'file1' + + +//// [systemModule12.js] +System.register("NamedModule", [], function(exports_1) { + return { + setters:[], + execute: function() { + } + } +}); diff --git a/tests/cases/compiler/systemModule12.ts b/tests/cases/compiler/systemModule12.ts new file mode 100644 index 00000000000..690fabc0a28 --- /dev/null +++ b/tests/cases/compiler/systemModule12.ts @@ -0,0 +1,5 @@ +// @module: system +// @isolatedModules: true + +/// +import n from 'file1' From 3c630aa247e079af94a6dd045a7d07cad7cb2b26 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 4 Jun 2015 22:22:25 -0700 Subject: [PATCH 04/18] added tests --- tests/cases/unittests/transpile.ts | 33 +++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/tests/cases/unittests/transpile.ts b/tests/cases/unittests/transpile.ts index c906c03a9e0..7aa9106880b 100644 --- a/tests/cases/unittests/transpile.ts +++ b/tests/cases/unittests/transpile.ts @@ -3,9 +3,9 @@ module ts { describe("Transpile", () => { - function runTest(input: string, compilerOptions: ts.CompilerOptions = {}, expectedOutput?: string, expectedDiagnosticCodes: number[] = []): void { + function runTest(input: string, compilerOptions: ts.CompilerOptions = {}, moduleName?: string, expectedOutput?: string, expectedDiagnosticCodes: number[] = []): void { let diagnostics: Diagnostic[] = []; - let result = transpile(input, compilerOptions, "file.ts", diagnostics); + let result = transpile(input, compilerOptions, "file.ts", diagnostics, moduleName); for (let i = 0; i < expectedDiagnosticCodes.length; i++) { assert.equal(expectedDiagnosticCodes[i], diagnostics[i] && diagnostics[i].code, `Could not find expeced diagnostic.`); @@ -19,41 +19,54 @@ module ts { it("Generates correct compilerOptions diagnostics", () => { // Expecting 5047: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." - runTest(`var x = 0;`, {}, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ [5047]); + runTest(`var x = 0;`, {}, /*moduleName*/undefined, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ [5047]); }); it("Generates no diagnostics with valid inputs", () => { // No errors - runTest(`var x = 0;`, { module: ModuleKind.CommonJS }, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ []); + runTest(`var x = 0;`, { module: ModuleKind.CommonJS }, /*moduleName*/undefined, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ []); }); it("Generates no diagnostics for missing file references", () => { runTest(`/// var x = 0;`, - { module: ModuleKind.CommonJS }, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ []); + { module: ModuleKind.CommonJS }, /*moduleName*/undefined, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ []); }); it("Generates no diagnostics for missing module imports", () => { runTest(`import {a} from "module2";`, - { module: ModuleKind.CommonJS }, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ []); + { module: ModuleKind.CommonJS }, /*moduleName*/undefined, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ []); }); it("Generates expected syntactic diagnostics", () => { runTest(`a b`, - { module: ModuleKind.CommonJS }, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ [1005]); /// 1005: ';' Expected + { module: ModuleKind.CommonJS }, /*moduleName*/undefined, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ [1005]); /// 1005: ';' Expected }); it("Does not generate semantic diagnostics", () => { runTest(`var x: string = 0;`, - { module: ModuleKind.CommonJS }, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ []); + { module: ModuleKind.CommonJS }, /*moduleName*/undefined, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ []); }); it("Generates module output", () => { - runTest(`var x = 0;`, { module: ModuleKind.AMD }, `define(["require", "exports"], function (require, exports) {\r\n var x = 0;\r\n});\r\n`); + runTest(`var x = 0;`, { module: ModuleKind.AMD }, /*moduleName*/undefined, `define(["require", "exports"], function (require, exports) {\r\n var x = 0;\r\n});\r\n`); }); it("Uses correct newLine character", () => { - runTest(`var x = 0;`, { module: ModuleKind.CommonJS, newLine: NewLineKind.LineFeed }, `var x = 0;\n`, /*expectedDiagnosticCodes*/ []); + runTest(`var x = 0;`, { module: ModuleKind.CommonJS, newLine: NewLineKind.LineFeed }, /*moduleName*/undefined, `var x = 0;\n`, /*expectedDiagnosticCodes*/ []); + }); + + it("Sets module name", () => { + let output = + `System.register("NamedModule", [], function(exports_1) {\n var x;\n` + + ` return {\n` + + ` setters:[],\n` + + ` execute: function() {\n` + + ` var x = 1;\n` + + ` }\n` + + ` }\n` + + `});\n`; + runTest("var x = 1;", { module: ModuleKind.System, newLine: NewLineKind.LineFeed }, "NamedModule", output) }); }); } From 26a1ed60171236ea9af4dcc2991537d134eb3164 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Mon, 8 Jun 2015 18:31:56 -0700 Subject: [PATCH 05/18] move temp declarations out of object literal --- src/compiler/emitter.ts | 2 +- tests/baselines/reference/systemModule8.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 165f0da5cfd..5919e62633a 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -5327,10 +5327,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { emitSetters(exportStarFunction); writeLine(); emitExecute(node, startIndex); - emitTempDeclarations(/*newLine*/ true) decreaseIndent(); writeLine(); write("}"); // return + emitTempDeclarations(/*newLine*/ true) } function emitSetters(exportStarFunction: string) { diff --git a/tests/baselines/reference/systemModule8.js b/tests/baselines/reference/systemModule8.js index 578814d0ab2..14f7a4c6fbe 100644 --- a/tests/baselines/reference/systemModule8.js +++ b/tests/baselines/reference/systemModule8.js @@ -66,6 +66,6 @@ System.register([], function(exports_1) { exports_1("x", x = _b[_i][0]); } } - var _a; } + var _a; }); From 185b2aff088b0c8ad0bf6b04b7511f0bbd5ed146 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Mon, 8 Jun 2015 22:46:59 -0700 Subject: [PATCH 06/18] added missing semicolon --- src/compiler/emitter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 5919e62633a..857a5404524 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -5330,7 +5330,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { decreaseIndent(); writeLine(); write("}"); // return - emitTempDeclarations(/*newLine*/ true) + emitTempDeclarations(/*newLine*/ true); } function emitSetters(exportStarFunction: string) { From d0763060c9c837d6c3a235e58271313e54cb3146 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 10 Jun 2015 12:32:24 -0700 Subject: [PATCH 07/18] added more tests --- tests/baselines/reference/systemModule13.js | 21 ++++++++++++ .../reference/systemModule13.symbols | 17 ++++++++++ .../baselines/reference/systemModule13.types | 32 +++++++++++++++++++ tests/cases/compiler/systemModule13.ts | 5 +++ 4 files changed, 75 insertions(+) create mode 100644 tests/baselines/reference/systemModule13.js create mode 100644 tests/baselines/reference/systemModule13.symbols create mode 100644 tests/baselines/reference/systemModule13.types create mode 100644 tests/cases/compiler/systemModule13.ts diff --git a/tests/baselines/reference/systemModule13.js b/tests/baselines/reference/systemModule13.js new file mode 100644 index 00000000000..c66e123c738 --- /dev/null +++ b/tests/baselines/reference/systemModule13.js @@ -0,0 +1,21 @@ +//// [systemModule13.ts] + +export let [x,y,z] = [1, 2, 3]; +export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}}; +for ([x] of [[1]]) {} + +//// [systemModule13.js] +System.register([], function(exports_1) { + var x, y, z, z0, z1; + return { + setters:[], + execute: function() { + _a = [1, 2, 3], exports_1("x", x = _a[0]), exports_1("y", y = _a[1]), exports_1("z", z = _a[2]); + _b = { a: true, b: { c: "123" } }, exports_1("z0", z0 = _b.a), exports_1("z1", z1 = _b.b.c); + for (var _i = 0, _c = [[1]]; _i < _c.length; _i++) { + exports_1("x", x = _c[_i][0]); + } + } + } + var _a, _b; +}); diff --git a/tests/baselines/reference/systemModule13.symbols b/tests/baselines/reference/systemModule13.symbols new file mode 100644 index 00000000000..d9e64335c2b --- /dev/null +++ b/tests/baselines/reference/systemModule13.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/systemModule13.ts === + +export let [x,y,z] = [1, 2, 3]; +>x : Symbol(x, Decl(systemModule13.ts, 1, 12)) +>y : Symbol(y, Decl(systemModule13.ts, 1, 14)) +>z : Symbol(z, Decl(systemModule13.ts, 1, 16)) + +export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}}; +>z0 : Symbol(z0, Decl(systemModule13.ts, 2, 14)) +>z1 : Symbol(z1, Decl(systemModule13.ts, 2, 25)) +>a : Symbol(a, Decl(systemModule13.ts, 2, 36)) +>b : Symbol(b, Decl(systemModule13.ts, 2, 44)) +>c : Symbol(c, Decl(systemModule13.ts, 2, 49)) + +for ([x] of [[1]]) {} +>x : Symbol(x, Decl(systemModule13.ts, 1, 12)) + diff --git a/tests/baselines/reference/systemModule13.types b/tests/baselines/reference/systemModule13.types new file mode 100644 index 00000000000..35f22be98b8 --- /dev/null +++ b/tests/baselines/reference/systemModule13.types @@ -0,0 +1,32 @@ +=== tests/cases/compiler/systemModule13.ts === + +export let [x,y,z] = [1, 2, 3]; +>x : number +>y : number +>z : number +>[1, 2, 3] : [number, number, number] +>1 : number +>2 : number +>3 : number + +export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}}; +>a : any +>z0 : boolean +>b : any +>c : any +>z1 : string +>{a: true, b: {c: "123"}} : { a: boolean; b: { c: string; }; } +>a : boolean +>true : boolean +>b : { c: string; } +>{c: "123"} : { c: string; } +>c : string +>"123" : string + +for ([x] of [[1]]) {} +>[x] : number[] +>x : number +>[[1]] : number[][] +>[1] : number[] +>1 : number + diff --git a/tests/cases/compiler/systemModule13.ts b/tests/cases/compiler/systemModule13.ts new file mode 100644 index 00000000000..2f92d99ab21 --- /dev/null +++ b/tests/cases/compiler/systemModule13.ts @@ -0,0 +1,5 @@ +// @module: system + +export let [x,y,z] = [1, 2, 3]; +export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}}; +for ([x] of [[1]]) {} \ No newline at end of file From 25c093673cceb508a4d7f855754c0b9006a0e5f8 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 3 Jun 2015 13:48:34 -0700 Subject: [PATCH 08/18] introduce FileMap to store mappings with filenames as keys --- src/compiler/core.ts | 32 +++++++++++++++++++++++ src/compiler/program.ts | 17 ++++++------ src/services/services.ts | 56 +++++++++++++++++++++------------------- src/services/shims.ts | 10 ++++++- 4 files changed, 80 insertions(+), 35 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index c753f7ff42d..bba10a635e4 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -15,6 +15,38 @@ module ts { True = -1 } + export class FileMap { + private files: Map = {}; + + constructor(private getCanonicalFileName: (fileName: string) => string) { + } + + public set(fileName: string, value: T) { + this.files[this.normalizeKey(fileName)] = value; + } + + public get(fileName: string) { + return this.files[this.normalizeKey(fileName)]; + } + + public contains(fileName: string) { + return hasProperty(this.files, this.normalizeKey(fileName)); + } + + public delete(fileName: string) { + let key = this.normalizeKey(fileName); + delete this.files[key]; + } + + public forEachValue(f: (value: T) => void) { + forEachValue(this.files, f); + } + + private normalizeKey(key: string) { + return this.getCanonicalFileName(normalizeSlashes(key)); + } + } + export const enum Comparison { LessThan = -1, EqualTo = 0, diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 0af94b3d854..fa794bbb77e 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -143,7 +143,6 @@ module ts { export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program { let program: Program; let files: SourceFile[] = []; - let filesByName: Map = {}; let diagnostics = createDiagnosticCollection(); let seenNoDefaultLib = options.noLib; let commonSourceDirectory: string; @@ -153,6 +152,8 @@ module ts { let start = new Date().getTime(); host = host || createCompilerHost(options); + let filesByName: FileMap = new FileMap(host.getCanonicalFileName); + forEach(rootNames, name => processRootFile(name, false)); if (!seenNoDefaultLib) { processRootFile(host.getDefaultLibFileName(options), true); @@ -233,8 +234,7 @@ module ts { } function getSourceFile(fileName: string) { - fileName = host.getCanonicalFileName(normalizeSlashes(fileName)); - return hasProperty(filesByName, fileName) ? filesByName[fileName] : undefined; + return filesByName.get(fileName); } function getDiagnosticsHelper(sourceFile: SourceFile, getDiagnostics: (sourceFile: SourceFile) => Diagnostic[]): Diagnostic[] { @@ -352,19 +352,19 @@ module ts { // Get source file from normalized fileName function findSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refStart?: number, refLength?: number): SourceFile { let canonicalName = host.getCanonicalFileName(normalizeSlashes(fileName)); - if (hasProperty(filesByName, canonicalName)) { + if (filesByName.contains(canonicalName)) { // We've already looked for this file, use cached result return getSourceFileFromCache(fileName, canonicalName, /*useAbsolutePath*/ false); } else { let normalizedAbsolutePath = getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); let canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); - if (hasProperty(filesByName, canonicalAbsolutePath)) { + if (filesByName.contains(canonicalAbsolutePath)) { return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, /*useAbsolutePath*/ true); } // We haven't looked for this file, do so now and cache result - let file = filesByName[canonicalName] = host.getSourceFile(fileName, options.target, hostErrorMessage => { + let file = host.getSourceFile(fileName, options.target, hostErrorMessage => { if (refFile) { diagnostics.add(createFileDiagnostic(refFile, refStart, refLength, Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); @@ -373,11 +373,12 @@ module ts { diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } }); + filesByName.set(canonicalName, file); if (file) { seenNoDefaultLib = seenNoDefaultLib || file.hasNoDefaultLib; // Set the source file for normalized absolute path - filesByName[canonicalAbsolutePath] = file; + filesByName.set(canonicalAbsolutePath, file); if (!options.noResolve) { let basePath = getDirectoryPath(fileName); @@ -396,7 +397,7 @@ module ts { } function getSourceFileFromCache(fileName: string, canonicalName: string, useAbsolutePath: boolean): SourceFile { - let file = filesByName[canonicalName]; + let file = filesByName.get(canonicalName); if (file && host.useCaseSensitiveFileNames()) { let sourceFileName = useAbsolutePath ? getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { diff --git a/src/services/services.ts b/src/services/services.ts index ece411ae1ea..b6f95c2f13a 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -960,6 +960,7 @@ module ts { log? (s: string): void; trace? (s: string): void; error? (s: string): void; + useCaseSensitiveFileNames? (): boolean; } // @@ -1630,12 +1631,12 @@ module ts { // at each language service public entry point, since we don't know when // set of scripts handled by the host changes. class HostCache { - private fileNameToEntry: Map; + private fileNameToEntry: FileMap; private _compilationSettings: CompilerOptions; - constructor(private host: LanguageServiceHost, private getCanonicalFileName: (fileName: string) => string) { + constructor(private host: LanguageServiceHost, getCanonicalFileName: (fileName: string) => string) { // script id => script index - this.fileNameToEntry = {}; + this.fileNameToEntry = new FileMap(getCanonicalFileName); // Initialize the list with the root file names let rootFileNames = host.getScriptFileNames(); @@ -1651,10 +1652,6 @@ module ts { return this._compilationSettings; } - private normalizeFileName(fileName: string): string { - return this.getCanonicalFileName(normalizeSlashes(fileName)); - } - private createEntry(fileName: string) { let entry: HostFileInformation; let scriptSnapshot = this.host.getScriptSnapshot(fileName); @@ -1666,15 +1663,16 @@ module ts { }; } - return this.fileNameToEntry[this.normalizeFileName(fileName)] = entry; + this.fileNameToEntry.set(fileName, entry); + return entry; } private getEntry(fileName: string): HostFileInformation { - return lookUp(this.fileNameToEntry, this.normalizeFileName(fileName)); + return this.fileNameToEntry.get(fileName); } private contains(fileName: string): boolean { - return hasProperty(this.fileNameToEntry, this.normalizeFileName(fileName)); + return this.fileNameToEntry.contains(fileName); } public getOrCreateEntry(fileName: string): HostFileInformation { @@ -1688,10 +1686,9 @@ module ts { public getRootFileNames(): string[] { let fileNames: string[] = []; - forEachKey(this.fileNameToEntry, key => { - let entry = this.getEntry(key); - if (entry) { - fileNames.push(entry.hostFileName); + this.fileNameToEntry.forEachValue(value => { + if (value) { + fileNames.push(value.hostFileName); } }); @@ -1885,20 +1882,28 @@ module ts { return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents:*/ true); } - export function createDocumentRegistry(): DocumentRegistry { + function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string { + return useCaseSensitivefileNames + ? ((fileName) => fileName) + : ((fileName) => fileName.toLowerCase()); + } + + + export function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry { // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have // for those settings. - let buckets: Map> = {}; + let buckets: Map> = {}; + let getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames || false); function getKeyFromCompilationSettings(settings: CompilerOptions): string { return "_" + settings.target; // + "|" + settings.propagateEnumConstantoString() } - function getBucketForCompilationSettings(settings: CompilerOptions, createIfMissing: boolean): Map { + function getBucketForCompilationSettings(settings: CompilerOptions, createIfMissing: boolean): FileMap { let key = getKeyFromCompilationSettings(settings); let bucket = lookUp(buckets, key); if (!bucket && createIfMissing) { - buckets[key] = bucket = {}; + buckets[key] = bucket = new FileMap(getCanonicalFileName); } return bucket; } @@ -1908,7 +1913,7 @@ module ts { let entries = lookUp(buckets, name); let sourceFiles: { name: string; refCount: number; references: string[]; }[] = []; for (let i in entries) { - let entry = entries[i]; + let entry = entries.get(i); sourceFiles.push({ name: i, refCount: entry.languageServiceRefCount, @@ -1940,18 +1945,19 @@ module ts { acquiring: boolean): SourceFile { let bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true); - let entry = lookUp(bucket, fileName); + let entry = bucket.get(fileName); if (!entry) { Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); // Have never seen this file with these settings. Create a new source file for it. let sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents:*/ false); - bucket[fileName] = entry = { + entry = { sourceFile: sourceFile, languageServiceRefCount: 0, owners: [] }; + bucket.set(fileName, entry); } else { // We have an entry for this file. However, it may be for a different version of @@ -1979,12 +1985,12 @@ module ts { let bucket = getBucketForCompilationSettings(compilationSettings, false); Debug.assert(bucket !== undefined); - let entry = lookUp(bucket, fileName); + let entry = bucket.get(fileName); entry.languageServiceRefCount--; Debug.assert(entry.languageServiceRefCount >= 0); if (entry.languageServiceRefCount === 0) { - delete bucket[fileName]; + bucket.delete(fileName); } } @@ -2412,9 +2418,7 @@ module ts { } } - function getCanonicalFileName(fileName: string) { - return useCaseSensitivefileNames ? fileName : fileName.toLowerCase(); - } + let getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames); function getValidSourceFile(fileName: string): SourceFile { fileName = normalizeSlashes(fileName); diff --git a/src/services/shims.ts b/src/services/shims.ts index d3f59737538..4dfab444cde 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -56,6 +56,7 @@ module ts { getDefaultLibFileName(options: string): string; getNewLine?(): string; getProjectVersion?(): string; + useCaseSensitiveFileNames?(): boolean; } /** Public interface of the the of a config service shim instance.*/ @@ -270,6 +271,10 @@ module ts { return this.shimHost.getProjectVersion(); } + public useCaseSensitiveFileNames(): boolean { + return this.shimHost.useCaseSensitiveFileNames && this.useCaseSensitiveFileNames(); + } + public getCompilationSettings(): CompilerOptions { var settingsJson = this.shimHost.getCompilationSettings(); if (settingsJson == null || settingsJson == "") { @@ -909,7 +914,7 @@ module ts { export class TypeScriptServicesFactory implements ShimFactory { private _shims: Shim[] = []; - private documentRegistry: DocumentRegistry = createDocumentRegistry(); + private documentRegistry: DocumentRegistry; /* * Returns script API version. @@ -920,6 +925,9 @@ module ts { public createLanguageServiceShim(host: LanguageServiceShimHost): LanguageServiceShim { try { + if (this.documentRegistry === undefined) { + this.documentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + } var hostAdapter = new LanguageServiceShimHostAdapter(host); var languageService = createLanguageService(hostAdapter, this.documentRegistry); return new LanguageServiceShimObject(this, host, languageService); From b4f1df2afa039e3c31fd833a2483de5124cb4f90 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 3 Jun 2015 15:22:17 -0700 Subject: [PATCH 09/18] address PR feedback --- src/compiler/core.ts | 38 +++++++++++++++++++++----------------- src/compiler/program.ts | 2 +- src/compiler/types.ts | 8 ++++++++ src/services/services.ts | 6 +++--- src/services/shims.ts | 2 +- 5 files changed, 34 insertions(+), 22 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index bba10a635e4..1f04f9968ca 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -15,35 +15,39 @@ module ts { True = -1 } - export class FileMap { - private files: Map = {}; - - constructor(private getCanonicalFileName: (fileName: string) => string) { + export function createFileMap(getCanonicalFileName: (fileName: string) => string): FileMap { + let files: Map = {}; + return { + get, + set, + contains, + delete: deleteItem, + forEachValue: forEachValueInMap } - public set(fileName: string, value: T) { - this.files[this.normalizeKey(fileName)] = value; + function set(fileName: string, value: T) { + files[normalizeKey(fileName)] = value; } - public get(fileName: string) { - return this.files[this.normalizeKey(fileName)]; + function get(fileName: string) { + return files[normalizeKey(fileName)]; } - public contains(fileName: string) { - return hasProperty(this.files, this.normalizeKey(fileName)); + function contains(fileName: string) { + return hasProperty(files, normalizeKey(fileName)); } - public delete(fileName: string) { - let key = this.normalizeKey(fileName); - delete this.files[key]; + function deleteItem (fileName: string) { + let key = normalizeKey(fileName); + delete files[key]; } - public forEachValue(f: (value: T) => void) { - forEachValue(this.files, f); + function forEachValueInMap(f: (value: T) => void) { + forEachValue(files, f); } - private normalizeKey(key: string) { - return this.getCanonicalFileName(normalizeSlashes(key)); + function normalizeKey(key: string) { + return getCanonicalFileName(normalizeSlashes(key)); } } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index fa794bbb77e..5c40230484a 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -152,7 +152,7 @@ module ts { let start = new Date().getTime(); host = host || createCompilerHost(options); - let filesByName: FileMap = new FileMap(host.getCanonicalFileName); + let filesByName = createFileMap(host.getCanonicalFileName); forEach(rootNames, name => processRootFile(name, false)); if (!seenNoDefaultLib) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1a72e9fc94a..c3ce9d44ae3 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3,6 +3,14 @@ module ts { [index: string]: T; } + export interface FileMap { + get(fileName: string): T; + set(fileName: string, value: T): void; + contains(fileName: string): boolean; + delete(fileName: string): void; + forEachValue(f: (v: T) => void): void; + } + export interface TextRange { pos: number; end: number; diff --git a/src/services/services.ts b/src/services/services.ts index b6f95c2f13a..2329eeb2e83 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1636,7 +1636,7 @@ module ts { constructor(private host: LanguageServiceHost, getCanonicalFileName: (fileName: string) => string) { // script id => script index - this.fileNameToEntry = new FileMap(getCanonicalFileName); + this.fileNameToEntry = createFileMap(getCanonicalFileName); // Initialize the list with the root file names let rootFileNames = host.getScriptFileNames(); @@ -1893,7 +1893,7 @@ module ts { // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have // for those settings. let buckets: Map> = {}; - let getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames || false); + let getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); function getKeyFromCompilationSettings(settings: CompilerOptions): string { return "_" + settings.target; // + "|" + settings.propagateEnumConstantoString() @@ -1903,7 +1903,7 @@ module ts { let key = getKeyFromCompilationSettings(settings); let bucket = lookUp(buckets, key); if (!bucket && createIfMissing) { - buckets[key] = bucket = new FileMap(getCanonicalFileName); + buckets[key] = bucket = createFileMap(getCanonicalFileName); } return bucket; } diff --git a/src/services/shims.ts b/src/services/shims.ts index 4dfab444cde..004393fb3b5 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -272,7 +272,7 @@ module ts { } public useCaseSensitiveFileNames(): boolean { - return this.shimHost.useCaseSensitiveFileNames && this.useCaseSensitiveFileNames(); + return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; } public getCompilationSettings(): CompilerOptions { From 522248a042cd08594a2de4e0475c0f72f4bf9ba1 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 4 Jun 2015 11:18:05 -0700 Subject: [PATCH 10/18] rename 'FileMap.delete' to 'FileMap.remove' --- src/compiler/core.ts | 4 ++-- src/compiler/types.ts | 2 +- src/services/services.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 1f04f9968ca..d9a1fc5368a 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -21,7 +21,7 @@ module ts { get, set, contains, - delete: deleteItem, + remove, forEachValue: forEachValueInMap } @@ -37,7 +37,7 @@ module ts { return hasProperty(files, normalizeKey(fileName)); } - function deleteItem (fileName: string) { + function remove (fileName: string) { let key = normalizeKey(fileName); delete files[key]; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index c3ce9d44ae3..e1f565969d8 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -7,7 +7,7 @@ module ts { get(fileName: string): T; set(fileName: string, value: T): void; contains(fileName: string): boolean; - delete(fileName: string): void; + remove(fileName: string): void; forEachValue(f: (v: T) => void): void; } diff --git a/src/services/services.ts b/src/services/services.ts index 2329eeb2e83..521c6db155a 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1990,7 +1990,7 @@ module ts { Debug.assert(entry.languageServiceRefCount >= 0); if (entry.languageServiceRefCount === 0) { - bucket.delete(fileName); + bucket.remove(fileName); } } From 54edbaeea72af18b7536f1d4564a7b5164dc6515 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Mon, 15 Jun 2015 16:28:29 -0700 Subject: [PATCH 11/18] Parse class member with a missing identifier in the presence of a modifier --- src/compiler/parser.ts | 4 +-- ...lassMemberWithMissingIdentifier.errors.txt | 12 ++++++++ .../classMemberWithMissingIdentifier.js | 12 ++++++++ ...assMemberWithMissingIdentifier2.errors.txt | 30 +++++++++++++++++++ .../classMemberWithMissingIdentifier2.js | 13 ++++++++ .../classMemberWithMissingIdentifier.ts | 3 ++ .../classMemberWithMissingIdentifier2.ts | 3 ++ 7 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/classMemberWithMissingIdentifier.errors.txt create mode 100644 tests/baselines/reference/classMemberWithMissingIdentifier.js create mode 100644 tests/baselines/reference/classMemberWithMissingIdentifier2.errors.txt create mode 100644 tests/baselines/reference/classMemberWithMissingIdentifier2.js create mode 100644 tests/cases/compiler/classMemberWithMissingIdentifier.ts create mode 100644 tests/cases/compiler/classMemberWithMissingIdentifier2.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 07da065c1ae..35ef6393748 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4207,7 +4207,7 @@ module ts { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } - if (decorators) { + if (decorators || modifiers) { // treat this as a property declaration with a missing name. let name = createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name, /*questionToken*/ undefined); @@ -4729,7 +4729,7 @@ module ts { case SyntaxKind.ImportKeyword: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); default: - if (decorators) { + if (decorators || modifiers) { // We reached this point because we encountered an AtToken and assumed a declaration would // follow. For recovery and error reporting purposes, return an incomplete declaration. let node = createMissingNode(SyntaxKind.MissingDeclaration, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected); diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier.errors.txt b/tests/baselines/reference/classMemberWithMissingIdentifier.errors.txt new file mode 100644 index 00000000000..4bbc2d8167d --- /dev/null +++ b/tests/baselines/reference/classMemberWithMissingIdentifier.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/classMemberWithMissingIdentifier.ts(2,11): error TS1146: Declaration expected. +tests/cases/compiler/classMemberWithMissingIdentifier.ts(2,12): error TS1005: '=' expected. + + +==== tests/cases/compiler/classMemberWithMissingIdentifier.ts (2 errors) ==== + class C { + public {}; + +!!! error TS1146: Declaration expected. + ~ +!!! error TS1005: '=' expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier.js b/tests/baselines/reference/classMemberWithMissingIdentifier.js new file mode 100644 index 00000000000..cd1825d0da0 --- /dev/null +++ b/tests/baselines/reference/classMemberWithMissingIdentifier.js @@ -0,0 +1,12 @@ +//// [classMemberWithMissingIdentifier.ts] +class C { + public {}; +} + +//// [classMemberWithMissingIdentifier.js] +var C = (function () { + function C() { + this. = {}; + } + return C; +})(); diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier2.errors.txt b/tests/baselines/reference/classMemberWithMissingIdentifier2.errors.txt new file mode 100644 index 00000000000..b21e062e3b0 --- /dev/null +++ b/tests/baselines/reference/classMemberWithMissingIdentifier2.errors.txt @@ -0,0 +1,30 @@ +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,11): error TS1146: Declaration expected. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,12): error TS1005: '=' expected. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,14): error TS2304: Cannot find name 'name'. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,18): error TS1005: ']' expected. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,19): error TS2304: Cannot find name 'string'. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,25): error TS1005: ',' expected. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,26): error TS1136: Property assignment expected. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,27): error TS2304: Cannot find name 'VariableDeclaration'. + + +==== tests/cases/compiler/classMemberWithMissingIdentifier2.ts (8 errors) ==== + class C { + public {[name:string]:VariableDeclaration}; + +!!! error TS1146: Declaration expected. + ~ +!!! error TS1005: '=' expected. + ~~~~ +!!! error TS2304: Cannot find name 'name'. + ~ +!!! error TS1005: ']' expected. + ~~~~~~ +!!! error TS2304: Cannot find name 'string'. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1136: Property assignment expected. + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'VariableDeclaration'. + } \ No newline at end of file diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier2.js b/tests/baselines/reference/classMemberWithMissingIdentifier2.js new file mode 100644 index 00000000000..e8494755b22 --- /dev/null +++ b/tests/baselines/reference/classMemberWithMissingIdentifier2.js @@ -0,0 +1,13 @@ +//// [classMemberWithMissingIdentifier2.ts] +class C { + public {[name:string]:VariableDeclaration}; +} + +//// [classMemberWithMissingIdentifier2.js] +var C = (function () { + function C() { + this. = (_a = {}, _a[name] = string, _a.VariableDeclaration = VariableDeclaration, _a); + var _a; + } + return C; +})(); diff --git a/tests/cases/compiler/classMemberWithMissingIdentifier.ts b/tests/cases/compiler/classMemberWithMissingIdentifier.ts new file mode 100644 index 00000000000..01ba223f4c4 --- /dev/null +++ b/tests/cases/compiler/classMemberWithMissingIdentifier.ts @@ -0,0 +1,3 @@ +class C { + public {}; +} \ No newline at end of file diff --git a/tests/cases/compiler/classMemberWithMissingIdentifier2.ts b/tests/cases/compiler/classMemberWithMissingIdentifier2.ts new file mode 100644 index 00000000000..e1618659797 --- /dev/null +++ b/tests/cases/compiler/classMemberWithMissingIdentifier2.ts @@ -0,0 +1,3 @@ +class C { + public {[name:string]:VariableDeclaration}; +} \ No newline at end of file From 41e39735e88301c38ca89e98e0cdfaa42d8301e0 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Tue, 16 Jun 2015 17:06:00 -0700 Subject: [PATCH 12/18] Make resolveName ignore export specifiers without calling getSymbol --- src/compiler/checker.ts | 33 ++++++++++++++----- ...rtSpecifierAndExportedMemberDeclaration.js | 15 +++++++++ ...cifierAndExportedMemberDeclaration.symbols | 27 +++++++++++++++ ...pecifierAndExportedMemberDeclaration.types | 27 +++++++++++++++ ...cifierAndLocalMemberDeclaration.errors.txt | 18 ++++++++++ ...xportSpecifierAndLocalMemberDeclaration.js | 15 +++++++++ ...rtSpecifierReferencingOuterDeclaration1.js | 8 +++++ ...cifierReferencingOuterDeclaration1.symbols | 14 ++++++++ ...pecifierReferencingOuterDeclaration1.types | 14 ++++++++ ...rtSpecifierReferencingOuterDeclaration2.js | 11 +++++++ ...cifierReferencingOuterDeclaration2.symbols | 14 ++++++++ ...pecifierReferencingOuterDeclaration2.types | 14 ++++++++ ...ierReferencingOuterDeclaration3.errors.txt | 13 ++++++++ ...rtSpecifierReferencingOuterDeclaration3.js | 10 ++++++ ...ierReferencingOuterDeclaration4.errors.txt | 13 ++++++++ ...rtSpecifierReferencingOuterDeclaration4.js | 13 ++++++++ ...rtSpecifierAndExportedMemberDeclaration.ts | 12 +++++++ ...xportSpecifierAndLocalMemberDeclaration.ts | 12 +++++++ ...rtSpecifierReferencingOuterDeclaration1.ts | 5 +++ ...rtSpecifierReferencingOuterDeclaration2.ts | 7 ++++ ...rtSpecifierReferencingOuterDeclaration3.ts | 7 ++++ ...rtSpecifierReferencingOuterDeclaration4.ts | 9 +++++ 22 files changed, 303 insertions(+), 8 deletions(-) create mode 100644 tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.js create mode 100644 tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.symbols create mode 100644 tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.types create mode 100644 tests/baselines/reference/exportSpecifierAndLocalMemberDeclaration.errors.txt create mode 100644 tests/baselines/reference/exportSpecifierAndLocalMemberDeclaration.js create mode 100644 tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.js create mode 100644 tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.symbols create mode 100644 tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.types create mode 100644 tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.js create mode 100644 tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.symbols create mode 100644 tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.types create mode 100644 tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.errors.txt create mode 100644 tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.js create mode 100644 tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.errors.txt create mode 100644 tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.js create mode 100644 tests/cases/compiler/exportSpecifierAndExportedMemberDeclaration.ts create mode 100644 tests/cases/compiler/exportSpecifierAndLocalMemberDeclaration.ts create mode 100644 tests/cases/compiler/exportSpecifierReferencingOuterDeclaration1.ts create mode 100644 tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2.ts create mode 100644 tests/cases/compiler/exportSpecifierReferencingOuterDeclaration3.ts create mode 100644 tests/cases/compiler/exportSpecifierReferencingOuterDeclaration4.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8ee39ab18f3..d296ea5fa22 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -344,21 +344,38 @@ module ts { case SyntaxKind.SourceFile: if (!isExternalModule(location)) break; case SyntaxKind.ModuleDeclaration: - if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & SymbolFlags.ModuleMember)) { - if (result.flags & meaning || !(result.flags & SymbolFlags.Alias && getDeclarationOfAliasSymbol(result).kind === SyntaxKind.ExportSpecifier)) { - break loop; - } - result = undefined; - } - else if (location.kind === SyntaxKind.SourceFile || + let moduleExports = getSymbolOfNode(location).exports; + if (location.kind === SyntaxKind.SourceFile || (location.kind === SyntaxKind.ModuleDeclaration && (location).name.kind === SyntaxKind.StringLiteral)) { - result = getSymbolOfNode(location).exports["default"]; + + // It's an external module. Because of module/namespace merging, a module's exports are in scope, + // yet we never want to treat an export specifier as putting a member in scope. Therefore, + // if the name we find is purely an export specifier, it is not actually considered in scope. + // Two things to note about this: + // 1. We have to check this without calling getSymbol. The problem with calling getSymbol + // on an export specifier is that it might find the export specifier itself, and try to + // resolve it as an alias. This will cause the checker to consider the export specifier + // a circular alias reference when it might not be. + // 2. We check === SymbolFlags.Alias in order to check that the symbol is *purely* + // an alias. If we used &, we'd be throwing out symbols that have non alias aspects, + // which is not the desired behavior. + if (hasProperty(moduleExports, name) && + moduleExports[name].flags === SymbolFlags.Alias && + getDeclarationOfKind(moduleExports[name], SyntaxKind.ExportSpecifier)) { + break; + } + + result = moduleExports["default"]; let localSymbol = getLocalSymbolForExportDefault(result); if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; } result = undefined; } + + if (result = getSymbol(moduleExports, name, meaning & SymbolFlags.ModuleMember)) { + break loop; + } break; case SyntaxKind.EnumDeclaration: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & SymbolFlags.EnumMember)) { diff --git a/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.js b/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.js new file mode 100644 index 00000000000..3fc40121011 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.js @@ -0,0 +1,15 @@ +//// [exportSpecifierAndExportedMemberDeclaration.ts] +declare module "m2" { + export module X { + interface I { } + } + function Y(); + export { Y as X }; + function Z(): X.I; +} + +declare module "m2" { + function Z2(): X.I; +} + +//// [exportSpecifierAndExportedMemberDeclaration.js] diff --git a/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.symbols b/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.symbols new file mode 100644 index 00000000000..7e2de735c47 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.symbols @@ -0,0 +1,27 @@ +=== tests/cases/compiler/exportSpecifierAndExportedMemberDeclaration.ts === +declare module "m2" { + export module X { +>X : Symbol(X, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 0, 21), Decl(exportSpecifierAndExportedMemberDeclaration.ts, 5, 12)) + + interface I { } +>I : Symbol(I, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 1, 21)) + } + function Y(); +>Y : Symbol(Y, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 3, 5)) + + export { Y as X }; +>Y : Symbol(X, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 0, 21), Decl(exportSpecifierAndExportedMemberDeclaration.ts, 5, 12)) +>X : Symbol(X, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 0, 21), Decl(exportSpecifierAndExportedMemberDeclaration.ts, 5, 12)) + + function Z(): X.I; +>Z : Symbol(Z, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 5, 22)) +>X : Symbol(X, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 0, 21), Decl(exportSpecifierAndExportedMemberDeclaration.ts, 5, 12)) +>I : Symbol(X.I, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 1, 21)) +} + +declare module "m2" { + function Z2(): X.I; +>Z2 : Symbol(Z2, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 9, 21)) +>X : Symbol(X, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 0, 21), Decl(exportSpecifierAndExportedMemberDeclaration.ts, 5, 12)) +>I : Symbol(X.I, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 1, 21)) +} diff --git a/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.types b/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.types new file mode 100644 index 00000000000..931552819c7 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.types @@ -0,0 +1,27 @@ +=== tests/cases/compiler/exportSpecifierAndExportedMemberDeclaration.ts === +declare module "m2" { + export module X { +>X : () => any + + interface I { } +>I : I + } + function Y(); +>Y : () => any + + export { Y as X }; +>Y : () => any +>X : () => any + + function Z(): X.I; +>Z : () => X.I +>X : any +>I : X.I +} + +declare module "m2" { + function Z2(): X.I; +>Z2 : () => X.I +>X : any +>I : X.I +} diff --git a/tests/baselines/reference/exportSpecifierAndLocalMemberDeclaration.errors.txt b/tests/baselines/reference/exportSpecifierAndLocalMemberDeclaration.errors.txt new file mode 100644 index 00000000000..eb444919f2c --- /dev/null +++ b/tests/baselines/reference/exportSpecifierAndLocalMemberDeclaration.errors.txt @@ -0,0 +1,18 @@ +tests/cases/compiler/exportSpecifierAndLocalMemberDeclaration.ts(11,20): error TS2503: Cannot find namespace 'X'. + + +==== tests/cases/compiler/exportSpecifierAndLocalMemberDeclaration.ts (1 errors) ==== + declare module "m2" { + module X { + interface I { } + } + function Y(); + export { Y as X }; + function Z(): X.I; + } + + declare module "m2" { + function Z2(): X.I; + ~ +!!! error TS2503: Cannot find namespace 'X'. + } \ No newline at end of file diff --git a/tests/baselines/reference/exportSpecifierAndLocalMemberDeclaration.js b/tests/baselines/reference/exportSpecifierAndLocalMemberDeclaration.js new file mode 100644 index 00000000000..d99ff3627ed --- /dev/null +++ b/tests/baselines/reference/exportSpecifierAndLocalMemberDeclaration.js @@ -0,0 +1,15 @@ +//// [exportSpecifierAndLocalMemberDeclaration.ts] +declare module "m2" { + module X { + interface I { } + } + function Y(); + export { Y as X }; + function Z(): X.I; +} + +declare module "m2" { + function Z2(): X.I; +} + +//// [exportSpecifierAndLocalMemberDeclaration.js] diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.js b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.js new file mode 100644 index 00000000000..003956e2822 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.js @@ -0,0 +1,8 @@ +//// [exportSpecifierReferencingOuterDeclaration1.ts] +declare module X { export interface bar { } } +declare module "m" { + export { X }; + export function foo(): X.bar; +} + +//// [exportSpecifierReferencingOuterDeclaration1.js] diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.symbols b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.symbols new file mode 100644 index 00000000000..16abde86d32 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration1.ts === +declare module X { export interface bar { } } +>X : Symbol(X, Decl(exportSpecifierReferencingOuterDeclaration1.ts, 0, 0)) +>bar : Symbol(bar, Decl(exportSpecifierReferencingOuterDeclaration1.ts, 0, 18)) + +declare module "m" { + export { X }; +>X : Symbol(X, Decl(exportSpecifierReferencingOuterDeclaration1.ts, 2, 12)) + + export function foo(): X.bar; +>foo : Symbol(foo, Decl(exportSpecifierReferencingOuterDeclaration1.ts, 2, 17)) +>X : Symbol(X, Decl(exportSpecifierReferencingOuterDeclaration1.ts, 0, 0)) +>bar : Symbol(X.bar, Decl(exportSpecifierReferencingOuterDeclaration1.ts, 0, 18)) +} diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.types b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.types new file mode 100644 index 00000000000..be03554a1b0 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration1.ts === +declare module X { export interface bar { } } +>X : any +>bar : bar + +declare module "m" { + export { X }; +>X : any + + export function foo(): X.bar; +>foo : () => X.bar +>X : any +>bar : X.bar +} diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.js b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.js new file mode 100644 index 00000000000..e8e96784083 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.js @@ -0,0 +1,11 @@ +//// [tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2.ts] //// + +//// [exportSpecifierReferencingOuterDeclaration2_A.ts] +declare module X { export interface bar { } } + +//// [exportSpecifierReferencingOuterDeclaration2_B.ts] +export { X }; +export declare function foo(): X.bar; + +//// [exportSpecifierReferencingOuterDeclaration2_A.js] +//// [exportSpecifierReferencingOuterDeclaration2_B.js] diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.symbols b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.symbols new file mode 100644 index 00000000000..9a57645b1cb --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_A.ts === +declare module X { export interface bar { } } +>X : Symbol(X, Decl(exportSpecifierReferencingOuterDeclaration2_A.ts, 0, 0)) +>bar : Symbol(bar, Decl(exportSpecifierReferencingOuterDeclaration2_A.ts, 0, 18)) + +=== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_B.ts === +export { X }; +>X : Symbol(X, Decl(exportSpecifierReferencingOuterDeclaration2_B.ts, 0, 8)) + +export declare function foo(): X.bar; +>foo : Symbol(foo, Decl(exportSpecifierReferencingOuterDeclaration2_B.ts, 0, 13)) +>X : Symbol(X, Decl(exportSpecifierReferencingOuterDeclaration2_A.ts, 0, 0)) +>bar : Symbol(X.bar, Decl(exportSpecifierReferencingOuterDeclaration2_A.ts, 0, 18)) + diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.types b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.types new file mode 100644 index 00000000000..fa59948c116 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_A.ts === +declare module X { export interface bar { } } +>X : any +>bar : bar + +=== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_B.ts === +export { X }; +>X : any + +export declare function foo(): X.bar; +>foo : () => X.bar +>X : any +>bar : X.bar + diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.errors.txt b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.errors.txt new file mode 100644 index 00000000000..e144c48bea4 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/exportSpecifierReferencingOuterDeclaration3.ts(6,30): error TS2305: Module 'X' has no exported member 'bar'. + + +==== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration3.ts (1 errors) ==== + declare module X { export interface bar { } } + declare module "m" { + module X { export interface foo { } } + export { X }; + export function foo(): X.foo; + export function bar(): X.bar; // error + ~~~ +!!! error TS2305: Module 'X' has no exported member 'bar'. + } \ No newline at end of file diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.js b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.js new file mode 100644 index 00000000000..0f6fff977da --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.js @@ -0,0 +1,10 @@ +//// [exportSpecifierReferencingOuterDeclaration3.ts] +declare module X { export interface bar { } } +declare module "m" { + module X { export interface foo { } } + export { X }; + export function foo(): X.foo; + export function bar(): X.bar; // error +} + +//// [exportSpecifierReferencingOuterDeclaration3.js] diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.errors.txt b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.errors.txt new file mode 100644 index 00000000000..6ac67c70d17 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_B.ts(4,34): error TS2305: Module 'X' has no exported member 'bar'. + + +==== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_A.ts (0 errors) ==== + declare module X { export interface bar { } } + +==== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_B.ts (1 errors) ==== + declare module X { export interface foo { } } + export { X }; + export declare function foo(): X.foo; + export declare function bar(): X.bar; // error + ~~~ +!!! error TS2305: Module 'X' has no exported member 'bar'. \ No newline at end of file diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.js b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.js new file mode 100644 index 00000000000..4edb5f711a6 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/exportSpecifierReferencingOuterDeclaration4.ts] //// + +//// [exportSpecifierReferencingOuterDeclaration2_A.ts] +declare module X { export interface bar { } } + +//// [exportSpecifierReferencingOuterDeclaration2_B.ts] +declare module X { export interface foo { } } +export { X }; +export declare function foo(): X.foo; +export declare function bar(): X.bar; // error + +//// [exportSpecifierReferencingOuterDeclaration2_A.js] +//// [exportSpecifierReferencingOuterDeclaration2_B.js] diff --git a/tests/cases/compiler/exportSpecifierAndExportedMemberDeclaration.ts b/tests/cases/compiler/exportSpecifierAndExportedMemberDeclaration.ts new file mode 100644 index 00000000000..1c20ffb0437 --- /dev/null +++ b/tests/cases/compiler/exportSpecifierAndExportedMemberDeclaration.ts @@ -0,0 +1,12 @@ +declare module "m2" { + export module X { + interface I { } + } + function Y(); + export { Y as X }; + function Z(): X.I; +} + +declare module "m2" { + function Z2(): X.I; +} \ No newline at end of file diff --git a/tests/cases/compiler/exportSpecifierAndLocalMemberDeclaration.ts b/tests/cases/compiler/exportSpecifierAndLocalMemberDeclaration.ts new file mode 100644 index 00000000000..5f942a75a74 --- /dev/null +++ b/tests/cases/compiler/exportSpecifierAndLocalMemberDeclaration.ts @@ -0,0 +1,12 @@ +declare module "m2" { + module X { + interface I { } + } + function Y(); + export { Y as X }; + function Z(): X.I; +} + +declare module "m2" { + function Z2(): X.I; +} \ No newline at end of file diff --git a/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration1.ts b/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration1.ts new file mode 100644 index 00000000000..e3d0a9000ab --- /dev/null +++ b/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration1.ts @@ -0,0 +1,5 @@ +declare module X { export interface bar { } } +declare module "m" { + export { X }; + export function foo(): X.bar; +} \ No newline at end of file diff --git a/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2.ts b/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2.ts new file mode 100644 index 00000000000..683358a0e3b --- /dev/null +++ b/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2.ts @@ -0,0 +1,7 @@ +// @module: commonjs +// @Filename: exportSpecifierReferencingOuterDeclaration2_A.ts +declare module X { export interface bar { } } + +// @Filename: exportSpecifierReferencingOuterDeclaration2_B.ts +export { X }; +export declare function foo(): X.bar; \ No newline at end of file diff --git a/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration3.ts b/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration3.ts new file mode 100644 index 00000000000..d4ddf3cc4a6 --- /dev/null +++ b/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration3.ts @@ -0,0 +1,7 @@ +declare module X { export interface bar { } } +declare module "m" { + module X { export interface foo { } } + export { X }; + export function foo(): X.foo; + export function bar(): X.bar; // error +} \ No newline at end of file diff --git a/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration4.ts b/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration4.ts new file mode 100644 index 00000000000..5beaf1de126 --- /dev/null +++ b/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration4.ts @@ -0,0 +1,9 @@ +// @module: commonjs +// @Filename: exportSpecifierReferencingOuterDeclaration2_A.ts +declare module X { export interface bar { } } + +// @Filename: exportSpecifierReferencingOuterDeclaration2_B.ts +declare module X { export interface foo { } } +export { X }; +export declare function foo(): X.foo; +export declare function bar(): X.bar; // error \ No newline at end of file From 752e0ba00384a8664d7f6cafec588e88c5f30226 Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Thu, 18 Jun 2015 23:04:05 +0800 Subject: [PATCH 13/18] Fixes type predicate crash bug --- src/compiler/checker.ts | 1 + .../expressions/typeGuards/typeGuardFunctionErrors.ts | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index efc3e32166e..0861cd96a01 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5761,6 +5761,7 @@ namespace ts { let signature = getResolvedSignature(expr); if (signature.typePredicate && + expr.arguments[signature.typePredicate.parameterIndex] && getSymbolAtLocation(expr.arguments[signature.typePredicate.parameterIndex]) === symbol) { if (!assumeTrue) { diff --git a/tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts b/tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts index e157b2afe36..688099280c5 100644 --- a/tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts +++ b/tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts @@ -23,6 +23,10 @@ function hasMissingIsKeyword(): x { return true; } +function hasMissingParameter(): x is A { + return true; +} + function hasMissingTypeInTypeGuardType(x): x is { return true; } @@ -132,4 +136,10 @@ function b6([a, b, p1], p2, p3): p1 is A { function b7({a, b, c: {p1}}, p2, p3): p1 is A { return true; +} + +// Should not crash the compiler +var x: A; +if (hasMissingParameter()) { + x.propA; } \ No newline at end of file From 84bb38415f2e0f47c8197ac6491abace54c58742 Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Thu, 18 Jun 2015 23:23:47 +0800 Subject: [PATCH 14/18] Accepts baselines --- .../typeGuardFunctionErrors.errors.txt | 69 +++++++++++-------- .../reference/typeGuardFunctionErrors.js | 18 +++++ 2 files changed, 59 insertions(+), 28 deletions(-) diff --git a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt index 1542bbe0fee..499a51035f2 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt +++ b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt @@ -1,42 +1,43 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(15,12): error TS2322: Type 'string' is not assignable to type 'boolean'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(22,33): error TS2304: Cannot find name 'x'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(26,10): error TS2391: Function implementation is missing or not immediately following the declaration. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(27,5): error TS1131: Property or signature expected. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(28,1): error TS1128: Declaration or statement expected. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(30,38): error TS1225: Cannot find parameter 'x'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(34,51): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(26,33): error TS1225: Cannot find parameter 'x'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(30,10): error TS2391: Function implementation is missing or not immediately following the declaration. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(31,5): error TS1131: Property or signature expected. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(32,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(34,38): error TS1225: Cannot find parameter 'x'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(38,51): error TS2322: Type 'B' is not assignable to type 'A'. Property 'propA' is missing in type 'B'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(38,56): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(42,56): error TS2322: Type 'T[]' is not assignable to type 'string'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(56,7): error TS2339: Property 'propB' does not exist on type 'A'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(61,7): error TS2339: Property 'propB' does not exist on type 'A'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(66,7): error TS2339: Property 'propB' does not exist on type 'A'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(71,46): error TS2345: Argument of type '(p1: any) => boolean' is not assignable to parameter of type '(p1: any) => boolean'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(42,56): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(46,56): error TS2322: Type 'T[]' is not assignable to type 'string'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(60,7): error TS2339: Property 'propB' does not exist on type 'A'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(65,7): error TS2339: Property 'propB' does not exist on type 'A'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(70,7): error TS2339: Property 'propB' does not exist on type 'A'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(75,46): error TS2345: Argument of type '(p1: any) => boolean' is not assignable to parameter of type '(p1: any) => boolean'. Type predicate 'p1 is C' is not assignable to 'p1 is B'. Type 'C' is not assignable to type 'B'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(75,1): error TS2322: Type '(p1: any, p2: any) => boolean' is not assignable to type '(p1: any, p2: any) => boolean'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(79,1): error TS2322: Type '(p1: any, p2: any) => boolean' is not assignable to type '(p1: any, p2: any) => boolean'. Signature '(p1: any, p2: any): boolean' must have a type predicate. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(81,1): error TS2322: Type '(p1: any, p2: any) => boolean' is not assignable to type '(p1: any, p2: any) => boolean'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(85,1): error TS2322: Type '(p1: any, p2: any) => boolean' is not assignable to type '(p1: any, p2: any) => boolean'. Type predicate 'p2 is A' is not assignable to 'p1 is A'. Parameter 'p2' is not in the same position as parameter 'p1'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(87,1): error TS2322: Type '(p1: any, p2: any, p3: any) => boolean' is not assignable to type '(p1: any, p2: any) => boolean'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(92,9): error TS1228: A type predicate is only allowed in return type position for functions and methods. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(93,16): error TS1228: A type predicate is only allowed in return type position for functions and methods. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(94,20): error TS1228: A type predicate is only allowed in return type position for functions and methods. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(100,25): error TS1228: A type predicate is only allowed in return type position for functions and methods. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(101,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(103,20): error TS1228: A type predicate is only allowed in return type position for functions and methods. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(106,20): error TS1228: A type predicate is only allowed in return type position for functions and methods. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(107,16): error TS2408: Setters cannot return a value. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(112,18): error TS1228: A type predicate is only allowed in return type position for functions and methods. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(116,22): error TS1228: A type predicate is only allowed in return type position for functions and methods. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(120,20): error TS1229: A type predicate cannot reference a rest parameter. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(125,34): error TS1230: A type predicate cannot reference element 'p1' in a binding pattern. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(91,1): error TS2322: Type '(p1: any, p2: any, p3: any) => boolean' is not assignable to type '(p1: any, p2: any) => boolean'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(96,9): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,16): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,20): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(104,25): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(105,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(107,20): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(110,20): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(111,16): error TS2408: Setters cannot return a value. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(116,18): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(120,22): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(124,20): error TS1229: A type predicate cannot reference a rest parameter. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(129,34): error TS1230: A type predicate cannot reference element 'p1' in a binding pattern. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(133,39): error TS1230: A type predicate cannot reference element 'p1' in a binding pattern. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(133,34): error TS1230: A type predicate cannot reference element 'p1' in a binding pattern. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39): error TS1230: A type predicate cannot reference element 'p1' in a binding pattern. -==== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts (30 errors) ==== +==== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts (31 errors) ==== class A { propA: number; @@ -66,6 +67,12 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(133,39 return true; } + function hasMissingParameter(): x is A { + ~ +!!! error TS1225: Cannot find parameter 'x'. + return true; + } + function hasMissingTypeInTypeGuardType(x): x is { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2391: Function implementation is missing or not immediately following the declaration. @@ -237,4 +244,10 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(133,39 ~~ !!! error TS1230: A type predicate cannot reference element 'p1' in a binding pattern. return true; + } + + // Should not crash the compiler + var x: A; + if (hasMissingParameter()) { + x.propA; } \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardFunctionErrors.js b/tests/baselines/reference/typeGuardFunctionErrors.js index 5b0979ac576..4923f544345 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.js +++ b/tests/baselines/reference/typeGuardFunctionErrors.js @@ -24,6 +24,10 @@ function hasMissingIsKeyword(): x { return true; } +function hasMissingParameter(): x is A { + return true; +} + function hasMissingTypeInTypeGuardType(x): x is { return true; } @@ -133,6 +137,12 @@ function b6([a, b, p1], p2, p3): p1 is A { function b7({a, b, c: {p1}}, p2, p3): p1 is A { return true; +} + +// Should not crash the compiler +var x: A; +if (hasMissingParameter()) { + x.propA; } //// [typeGuardFunctionErrors.js] @@ -167,6 +177,9 @@ function hasTypeGuardTypeInsideTypeGuardType(x) { function hasMissingIsKeyword() { return true; } +function hasMissingParameter() { + return true; +} return true; function hasNonMatchingParameter(y) { return true; @@ -260,3 +273,8 @@ function b7(_a, p2, p3) { var a = _a.a, b = _a.b, p1 = _a.c.p1; return true; } +// Should not crash the compiler +var x; +if (hasMissingParameter()) { + x.propA; +} From 38a54bc0b90f7145abd45e186e74e4dc78ad705c Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 18 Jun 2015 14:16:00 -0700 Subject: [PATCH 15/18] Fix incremental parsing issue. We were moving a method-declaration called "constructor" into a class. This is incorrect as that same code should be parsed as a constructor-declaration now that it is in the class context. --- src/compiler/parser.ts | 10 +++++++++- tests/cases/unittests/incrementalParser.ts | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index a507125d4bb..a94341dd9c4 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1491,12 +1491,20 @@ namespace ts { switch (node.kind) { case SyntaxKind.Constructor: case SyntaxKind.IndexSignature: - case SyntaxKind.MethodDeclaration: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: case SyntaxKind.PropertyDeclaration: case SyntaxKind.SemicolonClassElement: return true; + case SyntaxKind.MethodDeclaration: + // Method declarations are not necessarily reusable. An object-literal + // may have a method calls "constructor(...)" and we must reparse that + // into an actual .ConstructorDeclaration. + let methodDeclaration = node; + let nameIsConstructor = methodDeclaration.name.kind === SyntaxKind.Identifier && + (methodDeclaration.name).originalKeywordKind === SyntaxKind.ConstructorKeyword; + + return !nameIsConstructor; } } diff --git a/tests/cases/unittests/incrementalParser.ts b/tests/cases/unittests/incrementalParser.ts index a0b361a87f4..1ef10eaa712 100644 --- a/tests/cases/unittests/incrementalParser.ts +++ b/tests/cases/unittests/incrementalParser.ts @@ -713,6 +713,24 @@ module m3 { }\ compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 4); }); + it('Do not move constructors from class to object-literal.', () => { + var source = "class C { public constructor() { } public constructor() { } public constructor() { } }" + + var oldText = ScriptSnapshot.fromString(source); + var newTextAndChange = withChange(oldText, 0, "class C".length, "var v ="); + + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); + }); + + it('Do not move methods called "constructor" from object literal to class', () => { + var source = "var v = { public constructor() { } public constructor() { } public constructor() { } }" + + var oldText = ScriptSnapshot.fromString(source); + var newTextAndChange = withChange(oldText, 0, "var v =".length, "class C"); + + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); + }); + it('Moving index signatures from class to interface',() => { var source = "class C { public [a: number]: string; public [a: number]: string; public [a: number]: string }" From 3db5bbf93ffc06afe707a0a9a5cb016b061404a7 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 5 Jun 2015 12:00:53 -0700 Subject: [PATCH 16/18] wrap host.getCanonicalFileName in arrow function --- src/compiler/program.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 5c40230484a..1cfe4d77b6f 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -152,7 +152,7 @@ module ts { let start = new Date().getTime(); host = host || createCompilerHost(options); - let filesByName = createFileMap(host.getCanonicalFileName); + let filesByName = createFileMap(fileName => host.getCanonicalFileName(fileName)); forEach(rootNames, name => processRootFile(name, false)); if (!seenNoDefaultLib) { From 9ab6f4189047485b13a2eee677a61b38a647fe61 Mon Sep 17 00:00:00 2001 From: Zhengbo Li Date: Fri, 19 Jun 2015 17:34:10 -0700 Subject: [PATCH 17/18] Fix the issue that the "out" path is not relative to the path of tsconfig.json --- src/compiler/commandLineParser.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 07bccf4a5ef..4e401c5c9b3 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -110,6 +110,7 @@ namespace ts { { name: "out", type: "string", + isFilePath: true, description: Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: Diagnostics.FILE, }, From c41918116db9655f10882518db602515eaed7cad Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 22 Jun 2015 07:42:40 -0700 Subject: [PATCH 18/18] Update LKG. --- bin/lib.core.d.ts | 2 +- bin/lib.core.es6.d.ts | 2 +- bin/lib.d.ts | 9 +- bin/lib.dom.d.ts | 7 +- bin/lib.es6.d.ts | 19 +- bin/lib.webworker.d.ts | 7 +- bin/tsc.js | 6127 ++++++++++++------------ bin/tsserver.js | 7914 ++++++++++++++++--------------- bin/typescript.d.ts | 349 +- bin/typescript.js | 8870 ++++++++++++++++++----------------- bin/typescriptServices.d.ts | 365 +- bin/typescriptServices.js | 8870 ++++++++++++++++++----------------- 12 files changed, 17176 insertions(+), 15365 deletions(-) diff --git a/bin/lib.core.d.ts b/bin/lib.core.d.ts index fd048630ca1..af876765ab4 100644 --- a/bin/lib.core.d.ts +++ b/bin/lib.core.d.ts @@ -1165,7 +1165,7 @@ interface ArrayConstructor { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; - isArray(arg: any): boolean; + isArray(arg: any): arg is Array; prototype: Array; } diff --git a/bin/lib.core.es6.d.ts b/bin/lib.core.es6.d.ts index 1213967b972..1ee111caa9b 100644 --- a/bin/lib.core.es6.d.ts +++ b/bin/lib.core.es6.d.ts @@ -1165,7 +1165,7 @@ interface ArrayConstructor { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; - isArray(arg: any): boolean; + isArray(arg: any): arg is Array; prototype: Array; } diff --git a/bin/lib.d.ts b/bin/lib.d.ts index 0e1176377b5..63a8adbeda4 100644 --- a/bin/lib.d.ts +++ b/bin/lib.d.ts @@ -1165,7 +1165,7 @@ interface ArrayConstructor { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; - isArray(arg: any): boolean; + isArray(arg: any): arg is Array; prototype: Array; } @@ -3531,6 +3531,11 @@ declare module Intl { currency?: string; currencyDisplay?: string; useGrouping?: boolean; + minimumintegerDigits?: number; + minimumFractionDigits?: number; + maximumFractionDigits?: number; + minimumSignificantDigits?: number; + maximumSignificantDigits?: number; } interface ResolvedNumberFormatOptions { @@ -3593,7 +3598,7 @@ declare module Intl { } interface DateTimeFormat { - format(date: number): string; + format(date?: Date | number): string; resolvedOptions(): ResolvedDateTimeFormatOptions; } var DateTimeFormat: { diff --git a/bin/lib.dom.d.ts b/bin/lib.dom.d.ts index 7638f0fba4c..b05be6cbee8 100644 --- a/bin/lib.dom.d.ts +++ b/bin/lib.dom.d.ts @@ -2361,6 +2361,11 @@ declare module Intl { currency?: string; currencyDisplay?: string; useGrouping?: boolean; + minimumintegerDigits?: number; + minimumFractionDigits?: number; + maximumFractionDigits?: number; + minimumSignificantDigits?: number; + maximumSignificantDigits?: number; } interface ResolvedNumberFormatOptions { @@ -2423,7 +2428,7 @@ declare module Intl { } interface DateTimeFormat { - format(date: number): string; + format(date?: Date | number): string; resolvedOptions(): ResolvedDateTimeFormatOptions; } var DateTimeFormat: { diff --git a/bin/lib.es6.d.ts b/bin/lib.es6.d.ts index 2326b43207d..e17cb3f35cf 100644 --- a/bin/lib.es6.d.ts +++ b/bin/lib.es6.d.ts @@ -1165,7 +1165,7 @@ interface ArrayConstructor { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; - isArray(arg: any): boolean; + isArray(arg: any): arg is Array; prototype: Array; } @@ -4909,6 +4909,11 @@ declare module Intl { currency?: string; currencyDisplay?: string; useGrouping?: boolean; + minimumintegerDigits?: number; + minimumFractionDigits?: number; + maximumFractionDigits?: number; + minimumSignificantDigits?: number; + maximumSignificantDigits?: number; } interface ResolvedNumberFormatOptions { @@ -4971,7 +4976,7 @@ declare module Intl { } interface DateTimeFormat { - format(date: number): string; + format(date?: Date | number): string; resolvedOptions(): ResolvedDateTimeFormatOptions; } var DateTimeFormat: { @@ -18015,7 +18020,17 @@ declare function addEventListener(type: "volumechange", listener: (ev: Event) => declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +interface DOMTokenList { + [Symbol.iterator](): IterableIterator; +} +interface NodeList { + [Symbol.iterator](): IterableIterator +} + +interface NodeListOf { + [Symbol.iterator](): IterableIterator +} ///////////////////////////// /// WorkerGlobalScope APIs ///////////////////////////// diff --git a/bin/lib.webworker.d.ts b/bin/lib.webworker.d.ts index 79eac80a8fd..d0caeccff92 100644 --- a/bin/lib.webworker.d.ts +++ b/bin/lib.webworker.d.ts @@ -2361,6 +2361,11 @@ declare module Intl { currency?: string; currencyDisplay?: string; useGrouping?: boolean; + minimumintegerDigits?: number; + minimumFractionDigits?: number; + maximumFractionDigits?: number; + minimumSignificantDigits?: number; + maximumSignificantDigits?: number; } interface ResolvedNumberFormatOptions { @@ -2423,7 +2428,7 @@ declare module Intl { } interface DateTimeFormat { - format(date: number): string; + format(date?: Date | number): string; resolvedOptions(): ResolvedDateTimeFormatOptions; } var DateTimeFormat: { diff --git a/bin/tsc.js b/bin/tsc.js index 16408e9c208..e5f449c4101 100644 --- a/bin/tsc.js +++ b/bin/tsc.js @@ -31,6 +31,36 @@ var ts; /// var ts; (function (ts) { + function createFileMap(getCanonicalFileName) { + var files = {}; + return { + get: get, + set: set, + contains: contains, + remove: remove, + forEachValue: forEachValueInMap + }; + function set(fileName, value) { + files[normalizeKey(fileName)] = value; + } + function get(fileName) { + return files[normalizeKey(fileName)]; + } + function contains(fileName) { + return hasProperty(files, normalizeKey(fileName)); + } + function remove(fileName) { + var key = normalizeKey(fileName); + delete files[key]; + } + function forEachValueInMap(f) { + forEachValue(files, f); + } + function normalizeKey(key) { + return getCanonicalFileName(normalizeSlashes(key)); + } + } + ts.createFileMap = createFileMap; function forEach(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -498,7 +528,7 @@ var ts; function getNormalizedPathComponents(path, currentDirectory) { path = normalizeSlashes(path); var rootLength = getRootLength(path); - if (rootLength == 0) { + if (rootLength === 0) { path = combinePaths(normalizeSlashes(currentDirectory), path); rootLength = getRootLength(path); } @@ -1116,14 +1146,26 @@ var ts; A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, - Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" }, - Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, + Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Modules are automatically in strict mode." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators are only available when targeting ECMAScript 6 or higher." }, Generators_are_not_allowed_in_an_ambient_context: { code: 1221, category: ts.DiagnosticCategory.Error, key: "Generators are not allowed in an ambient context." }, An_overload_signature_cannot_be_declared_as_a_generator: { code: 1222, category: ts.DiagnosticCategory.Error, key: "An overload signature cannot be declared as a generator." }, _0_tag_already_specified: { code: 1223, category: ts.DiagnosticCategory.Error, key: "'{0}' tag already specified." }, + Signature_0_must_have_a_type_predicate: { code: 1224, category: ts.DiagnosticCategory.Error, key: "Signature '{0}' must have a type predicate." }, + Cannot_find_parameter_0: { code: 1225, category: ts.DiagnosticCategory.Error, key: "Cannot find parameter '{0}'." }, + Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: ts.DiagnosticCategory.Error, key: "Type predicate '{0}' is not assignable to '{1}'." }, + Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' is not in the same position as parameter '{1}'." }, + A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: ts.DiagnosticCategory.Error, key: "A type predicate is only allowed in return type position for functions and methods." }, + A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: ts.DiagnosticCategory.Error, key: "A type predicate cannot reference a rest parameter." }, + A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: ts.DiagnosticCategory.Error, key: "A type predicate cannot reference element '{0}' in a binding pattern." }, + An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: ts.DiagnosticCategory.Error, key: "An export assignment can only be used in a module." }, + An_import_declaration_can_only_be_used_in_a_namespace_or_module: { code: 1232, category: ts.DiagnosticCategory.Error, key: "An import declaration can only be used in a namespace or module." }, + An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: ts.DiagnosticCategory.Error, key: "An export declaration can only be used in a module." }, + An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: ts.DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." }, + A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: ts.DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -1317,6 +1359,11 @@ var ts; Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, No_best_common_type_exists_among_yield_expressions: { code: 2504, category: ts.DiagnosticCategory.Error, key: "No best common type exists among yield expressions." }, A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: ts.DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." }, + _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: ts.DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own base expression." }, + Type_0_is_not_a_constructor_function_type: { code: 2507, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not a constructor function type." }, + No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: ts.DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." }, + Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: ts.DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." }, + Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: ts.DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -1526,7 +1573,7 @@ var ts; "false": 80, "finally": 81, "for": 82, - "from": 125, + "from": 126, "function": 83, "get": 116, "if": 84, @@ -1535,36 +1582,37 @@ var ts; "in": 86, "instanceof": 87, "interface": 103, + "is": 117, "let": 104, - "module": 117, - "namespace": 118, + "module": 118, + "namespace": 119, "new": 88, "null": 89, - "number": 120, + "number": 121, "package": 105, "private": 106, "protected": 107, "public": 108, - "require": 119, + "require": 120, "return": 90, - "set": 121, + "set": 122, "static": 109, - "string": 122, + "string": 123, "super": 91, "switch": 92, - "symbol": 123, + "symbol": 124, "this": 93, "throw": 94, "true": 95, "try": 96, - "type": 124, + "type": 125, "typeof": 97, "var": 98, "void": 99, "while": 100, "with": 101, "yield": 110, - "of": 126, + "of": 127, "{": 14, "}": 15, "(": 16, @@ -1767,6 +1815,25 @@ var ts; return ch >= 48 && ch <= 55; } ts.isOctalDigit = isOctalDigit; + function couldStartTrivia(text, pos) { + var ch = text.charCodeAt(pos); + switch (ch) { + case 13: + case 10: + case 9: + case 11: + case 12: + case 32: + case 47: + case 60: + case 61: + case 62: + return true; + default: + return ch > 127; + } + } + ts.couldStartTrivia = couldStartTrivia; function skipTrivia(text, pos, stopAfterLineBreak) { while (true) { var ch = text.charCodeAt(pos); @@ -2229,7 +2296,7 @@ var ts; error(ts.Diagnostics.Unexpected_end_of_text); isInvalidExtendedEscape = true; } - else if (text.charCodeAt(pos) == 125) { + else if (text.charCodeAt(pos) === 125) { pos++; } else { @@ -2750,16 +2817,16 @@ var ts; (function (ts) { ts.bindTime = 0; function getModuleInstanceState(node) { - if (node.kind === 203 || node.kind === 204) { + if (node.kind === 205 || node.kind === 206) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 210 || node.kind === 209) && !(node.flags & 1)) { + else if ((node.kind === 212 || node.kind === 211) && !(node.flags & 1)) { return 0; } - else if (node.kind === 207) { + else if (node.kind === 209) { var state = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -2775,7 +2842,7 @@ var ts; }); return state; } - else if (node.kind === 206) { + else if (node.kind === 208) { return getModuleInstanceState(node.body); } else { @@ -2794,11 +2861,14 @@ var ts; var container; var blockScopeContainer; var lastContainer; + var inStrictMode = !!file.externalModuleIndicator; var symbolCount = 0; var Symbol = ts.objectAllocator.getSymbolConstructor(); + var classifiableNames = {}; if (!file.locals) { bind(file); file.symbolCount = symbolCount; + file.classifiableNames = classifiableNames; } return; function createSymbol(flags, name) { @@ -2824,10 +2894,10 @@ var ts; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 206 && node.name.kind === 8) { + if (node.kind === 208 && node.name.kind === 8) { return '"' + node.name.text + '"'; } - if (node.name.kind === 128) { + if (node.name.kind === 129) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -2835,22 +2905,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 136: + case 137: return "__constructor"; - case 143: - case 139: - return "__call"; - case 144: + case 145: case 140: - return "__new"; + return "__call"; + case 146: case 141: + return "__new"; + case 142: return "__index"; - case 216: + case 218: return "__export"; - case 215: + case 217: return node.isExportEquals ? "export=" : "default"; - case 201: - case 202: + case 203: + case 204: return node.flags & 256 ? "default" : undefined; } } @@ -2865,6 +2935,9 @@ var ts; symbol = ts.hasProperty(symbolTable, name) ? symbolTable[name] : (symbolTable[name] = createSymbol(0, name)); + if (name && (includes & 788448)) { + classifiableNames[name] = name; + } if (symbol.flags & excludes) { if (node.name) { node.name.parent = node; @@ -2889,7 +2962,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 218 || (node.kind === 209 && hasExportModifier)) { + if (node.kind === 220 || (node.kind === 211 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -2935,36 +3008,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 175: - case 202: - case 203: + case 177: + case 204: case 205: - case 146: - case 155: + case 207: + case 148: + case 157: return 1; - case 139: case 140: case 141: - case 135: - case 134: - case 201: + case 142: case 136: + case 135: + case 203: case 137: case 138: - case 143: - case 144: - case 163: - case 164: - case 206: - case 228: - return 5; - case 224: - case 187: - case 188: - case 189: + case 139: + case 145: + case 146: + case 165: + case 166: case 208: + case 230: + case 206: + return 5; + case 226: + case 189: + case 190: + case 191: + case 210: return 2; - case 180: + case 182: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -2980,32 +3054,33 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 206: + case 208: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 228: + case 230: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 175: - case 202: + case 177: + case 204: return declareClassMember(node, symbolFlags, symbolExcludes); - case 205: + case 207: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 146: - case 155: - case 203: + case 148: + case 157: + case 205: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 143: - case 144: - case 139: + case 145: + case 146: case 140: case 141: - case 135: - case 134: + case 142: case 136: + case 135: case 137: case 138: - case 201: - case 163: - case 164: + case 139: + case 203: + case 165: + case 166: + case 206: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -3029,11 +3104,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 228 ? node : node.body; - if (body.kind === 228 || body.kind === 207) { + var body = node.kind === 230 ? node : node.body; + if (body.kind === 230 || body.kind === 209) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 216 || stat.kind === 215) { + if (stat.kind === 218 || stat.kind === 217) { return true; } } @@ -3078,16 +3153,41 @@ var ts; typeLiteralSymbol.members = (_a = {}, _a[symbol.name] = symbol, _a); var _a; } + function bindObjectLiteralExpression(node) { + if (inStrictMode) { + var seen = {}; + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var prop = _a[_i]; + if (prop.name.kind !== 65) { + continue; + } + var identifier = prop.name; + var currentKind = prop.kind === 227 || prop.kind === 228 || prop.kind === 136 + ? 1 + : 2; + var existingKind = seen[identifier.text]; + if (!existingKind) { + seen[identifier.text] = currentKind; + continue; + } + if (currentKind === 1 && existingKind === 1) { + var span = ts.getErrorSpanForNode(file, identifier); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode)); + } + } + } + return bindAnonymousDeclaration(node, 4096, "__object"); + } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); addDeclarationToSymbol(symbol, node, symbolFlags); } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 206: + case 208: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 228: + case 230: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -3103,79 +3203,223 @@ var ts; function bindBlockScopedVariableDeclaration(node) { bindBlockScopedDeclaration(node, 2, 107455); } + function checkStrictModeIdentifier(node) { + if (inStrictMode && + node.originalKeywordKind >= 102 && + node.originalKeywordKind <= 110 && + !ts.isIdentifierName(node)) { + if (!file.parseDiagnostics.length) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); + } + } + } + function getStrictModeIdentifierMessage(node) { + if (ts.getAncestor(node, 204) || ts.getAncestor(node, 177)) { + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode; + } + if (file.externalModuleIndicator) { + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode; + } + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode; + } + function checkStrictModeBinaryExpression(node) { + if (inStrictMode && ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) { + checkStrictModeEvalOrArguments(node, node.left); + } + } + function checkStrictModeCatchClause(node) { + if (inStrictMode && node.variableDeclaration) { + checkStrictModeEvalOrArguments(node, node.variableDeclaration.name); + } + } + function checkStrictModeDeleteExpression(node) { + if (inStrictMode && node.expression.kind === 65) { + var span = ts.getErrorSpanForNode(file, node.expression); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); + } + } + function isEvalOrArgumentsIdentifier(node) { + return node.kind === 65 && + (node.text === "eval" || node.text === "arguments"); + } + function checkStrictModeEvalOrArguments(contextNode, name) { + if (name && name.kind === 65) { + var identifier = name; + if (isEvalOrArgumentsIdentifier(identifier)) { + var span = ts.getErrorSpanForNode(file, name); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, getStrictModeEvalOrArgumentsMessage(contextNode), identifier.text)); + } + } + } + function getStrictModeEvalOrArgumentsMessage(node) { + if (ts.getAncestor(node, 204) || ts.getAncestor(node, 177)) { + return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode; + } + if (file.externalModuleIndicator) { + return ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode; + } + return ts.Diagnostics.Invalid_use_of_0_in_strict_mode; + } + function checkStrictModeFunctionName(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.name); + } + } + function checkStrictModeNumericLiteral(node) { + if (inStrictMode && node.flags & 16384) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); + } + } + function checkStrictModePostfixUnaryExpression(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.operand); + } + } + function checkStrictModePrefixUnaryExpression(node) { + if (inStrictMode) { + if (node.operator === 38 || node.operator === 39) { + checkStrictModeEvalOrArguments(node, node.operand); + } + } + } + function checkStrictModeWithStatement(node) { + if (inStrictMode) { + grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); + } + } + function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + var span = ts.getSpanOfTokenAtPosition(file, node.pos); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); + } function getDestructuringParameterName(node) { return "__" + ts.indexOf(node.parent.parameters, node); } function bind(node) { node.parent = parent; + var savedInStrictMode = inStrictMode; + if (!savedInStrictMode) { + updateStrictMode(node); + } bindWorker(node); bindChildren(node); + inStrictMode = savedInStrictMode; + } + function updateStrictMode(node) { + switch (node.kind) { + case 230: + case 209: + updateStrictModeStatementList(node.statements); + return; + case 182: + if (ts.isFunctionLike(node.parent)) { + updateStrictModeStatementList(node.statements); + } + return; + case 204: + case 177: + inStrictMode = true; + return; + } + } + function updateStrictModeStatementList(statements) { + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (!ts.isPrologueDirective(statement)) { + return; + } + if (isUseStrictPrologueDirective(statement)) { + inStrictMode = true; + return; + } + } + } + function isUseStrictPrologueDirective(node) { + var nodeText = ts.getTextOfNodeFromSourceText(file.text, node.expression); + return nodeText === '"use strict"' || nodeText === "'use strict'"; } function bindWorker(node) { switch (node.kind) { - case 129: - return declareSymbolAndAddToSymbolTable(node, 262144, 530912); - case 130: - return bindParameter(node); - case 199: - case 153: - return bindVariableDeclarationOrBindingElement(node); - case 133: - case 132: - return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); - case 225: + case 65: + return checkStrictModeIdentifier(node); + case 172: + return checkStrictModeBinaryExpression(node); case 226: - return bindPropertyOrMethodOrAccessor(node, 4, 107455); + return checkStrictModeCatchClause(node); + case 167: + return checkStrictModeDeleteExpression(node); + case 7: + return checkStrictModeNumericLiteral(node); + case 171: + return checkStrictModePostfixUnaryExpression(node); + case 170: + return checkStrictModePrefixUnaryExpression(node); + case 195: + return checkStrictModeWithStatement(node); + case 130: + return declareSymbolAndAddToSymbolTable(node, 262144, 530912); + case 131: + return bindParameter(node); + case 201: + case 155: + return bindVariableDeclarationOrBindingElement(node); + case 134: + case 133: + return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); case 227: + case 228: + return bindPropertyOrMethodOrAccessor(node, 4, 107455); + case 229: return bindPropertyOrMethodOrAccessor(node, 8, 107455); - case 139: case 140: case 141: + case 142: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 135: - case 134: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); - case 201: - return declareSymbolAndAddToSymbolTable(node, 16, 106927); case 136: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); - case 137: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); - case 138: - return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 143: - case 144: - return bindFunctionOrConstructorType(node); - case 146: - return bindAnonymousDeclaration(node, 2048, "__type"); - case 155: - return bindAnonymousDeclaration(node, 4096, "__object"); - case 163: - case 164: - return bindAnonymousDeclaration(node, 16, "__function"); - case 175: - case 202: - return bindClassLikeDeclaration(node); + case 135: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); case 203: - return bindBlockScopedDeclaration(node, 64, 792992); + checkStrictModeFunctionName(node); + return declareSymbolAndAddToSymbolTable(node, 16, 106927); + case 137: + return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 138: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 139: + return bindPropertyOrMethodOrAccessor(node, 65536, 74687); + case 145: + case 146: + return bindFunctionOrConstructorType(node); + case 148: + return bindAnonymousDeclaration(node, 2048, "__type"); + case 157: + return bindObjectLiteralExpression(node); + case 165: + case 166: + checkStrictModeFunctionName(node); + return bindAnonymousDeclaration(node, 16, "__function"); + case 177: case 204: - return bindBlockScopedDeclaration(node, 524288, 793056); + return bindClassLikeDeclaration(node); case 205: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 64, 792992); case 206: + return bindBlockScopedDeclaration(node, 524288, 793056); + case 207: + return bindEnumDeclaration(node); + case 208: return bindModuleDeclaration(node); - case 209: - case 212: - case 214: - case 218: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); case 211: - return bindImportClause(node); + case 214: case 216: + case 220: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 213: + return bindImportClause(node); + case 218: return bindExportDeclaration(node); - case 215: + case 217: return bindExportAssignment(node); - case 228: + case 230: return bindSourceFileIfExternalModule(); } } @@ -3186,7 +3430,10 @@ var ts; } } function bindExportAssignment(node) { - if (node.expression.kind === 65) { + if (!container.symbol || !container.symbol.exports) { + bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); + } + else if (node.expression.kind === 65) { declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); } else { @@ -3194,7 +3441,10 @@ var ts; } } function bindExportDeclaration(node) { - if (!node.exportClause) { + if (!container.symbol || !container.symbol.exports) { + bindAnonymousDeclaration(node, 1073741824, getDeclarationName(node)); + } + else if (!node.exportClause) { declareSymbol(container.symbol.exports, container.symbol, node, 1073741824, 0); } } @@ -3204,7 +3454,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 202) { + if (node.kind === 204) { bindBlockScopedDeclaration(node, 32, 899583); } else { @@ -3227,6 +3477,9 @@ var ts; : bindBlockScopedDeclaration(node, 256, 899327); } function bindVariableDeclarationOrBindingElement(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.name); + } if (!ts.isBindingPattern(node.name)) { if (ts.isBlockOrCatchScoped(node)) { bindBlockScopedVariableDeclaration(node); @@ -3240,6 +3493,9 @@ var ts; } } function bindParameter(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.name); + } if (ts.isBindingPattern(node.name)) { bindAnonymousDeclaration(node, 1, getDestructuringParameterName(node)); } @@ -3247,8 +3503,8 @@ var ts; declareSymbolAndAddToSymbolTable(node, 1, 107455); } if (node.flags & 112 && - node.parent.kind === 136 && - (node.parent.parent.kind === 202 || node.parent.parent.kind === 175)) { + node.parent.kind === 137 && + (node.parent.parent.kind === 204 || node.parent.parent.kind === 177)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); } @@ -3276,7 +3532,7 @@ var ts; ts.getDeclarationOfKind = getDeclarationOfKind; var stringWriters = []; function getSingleLineStringWriter() { - if (stringWriters.length == 0) { + if (stringWriters.length === 0) { var str = ""; var writeText = function (text) { return str += text; }; return { @@ -3323,7 +3579,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 228) { + while (node && node.kind !== 230) { node = node.parent; } return node; @@ -3412,15 +3668,15 @@ var ts; return current; } switch (current.kind) { - case 228: + case 230: + case 210: + case 226: case 208: - case 224: - case 206: - case 187: - case 188: case 189: + case 190: + case 191: return current; - case 180: + case 182: if (!isFunctionLike(current.parent)) { return current; } @@ -3431,9 +3687,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 199 && + declaration.kind === 201 && declaration.parent && - declaration.parent.kind === 224; + declaration.parent.kind === 226; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3469,22 +3725,22 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 228: + case 230: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 199: - case 153: - case 202: - case 175: - case 203: - case 206: - case 205: - case 227: case 201: - case 163: + case 155: + case 204: + case 177: + case 205: + case 208: + case 207: + case 229: + case 203: + case 165: errorNode = node.name; break; } @@ -3506,11 +3762,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 205 && isConst(node); + return node.kind === 207 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 153 || isBindingPattern(node))) { + while (node && (node.kind === 155 || isBindingPattern(node))) { node = node.parent; } return node; @@ -3518,14 +3774,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 199) { + if (node.kind === 201) { node = node.parent; } - if (node && node.kind === 200) { + if (node && node.kind === 202) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 181) { + if (node && node.kind === 183) { flags |= node.flags; } return flags; @@ -3540,11 +3796,11 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 183 && node.expression.kind === 8; + return node.kind === 185 && node.expression.kind === 8; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - if (node.kind === 130 || node.kind === 129) { + if (node.kind === 131 || node.kind === 130) { return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); } else { @@ -3563,68 +3819,68 @@ var ts; ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (142 <= node.kind && node.kind <= 150) { + if (144 <= node.kind && node.kind <= 152) { return true; } switch (node.kind) { case 112: - case 120: - case 122: - case 113: + case 121: case 123: + case 113: + case 124: return true; case 99: - return node.parent.kind !== 167; + return node.parent.kind !== 169; case 8: - return node.parent.kind === 130; - case 177: - return true; + return node.parent.kind === 131; + case 179: + return !isExpressionWithTypeArgumentsInClassExtendsClause(node); case 65: - if (node.parent.kind === 127 && node.parent.right === node) { + if (node.parent.kind === 128 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 156 && node.parent.name === node) { + else if (node.parent.kind === 158 && node.parent.name === node) { node = node.parent; } - case 127: - case 156: - ts.Debug.assert(node.kind === 65 || node.kind === 127 || node.kind === 156, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 128: + case 158: + ts.Debug.assert(node.kind === 65 || node.kind === 128 || node.kind === 158, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_1 = node.parent; - if (parent_1.kind === 145) { + if (parent_1.kind === 147) { return false; } - if (142 <= parent_1.kind && parent_1.kind <= 150) { + if (144 <= parent_1.kind && parent_1.kind <= 152) { return true; } switch (parent_1.kind) { - case 177: - return true; - case 129: - return node === parent_1.constraint; - case 133: - case 132: + case 179: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); case 130: - case 199: - return node === parent_1.type; + return node === parent_1.constraint; + case 134: + case 133: + case 131: case 201: - case 163: - case 164: + return node === parent_1.type; + case 203: + case 165: + case 166: + case 137: case 136: case 135: - case 134: - case 137: case 138: - return node === parent_1.type; case 139: + return node === parent_1.type; case 140: case 141: + case 142: return node === parent_1.type; - case 161: + case 163: return node === parent_1.type; - case 158: - case 159: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 160: + case 161: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 162: return false; } } @@ -3635,23 +3891,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 192: + case 194: return visitor(node); - case 208: - case 180: - case 184: - case 185: + case 210: + case 182: case 186: case 187: case 188: case 189: - case 193: - case 194: - case 221: - case 222: + case 190: + case 191: case 195: - case 197: + case 196: + case 223: case 224: + case 197: + case 199: + case 226: return ts.forEachChild(node, traverse); } } @@ -3661,22 +3917,22 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 173: + case 175: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } + case 207: case 205: - case 203: + case 208: case 206: case 204: - case 202: return; default: if (isFunctionLike(node)) { var name_4 = node.name; - if (name_4 && name_4.kind === 128) { + if (name_4 && name_4.kind === 129) { traverse(name_4.expression); return; } @@ -3691,14 +3947,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 153: + case 155: + case 229: + case 131: case 227: - case 130: - case 225: + case 134: case 133: - case 132: - case 226: - case 199: + case 228: + case 201: return true; } } @@ -3708,8 +3964,8 @@ var ts; function isAccessor(node) { if (node) { switch (node.kind) { - case 137: case 138: + case 139: return true; } } @@ -3718,26 +3974,26 @@ var ts; ts.isAccessor = isAccessor; function isClassLike(node) { if (node) { - return node.kind === 202 || node.kind === 175; + return node.kind === 204 || node.kind === 177; } } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 136: - case 163: - case 201: - case 164: - case 135: - case 134: case 137: + case 165: + case 203: + case 166: + case 136: + case 135: case 138: case 139: case 140: case 141: - case 143: - case 144: + case 142: + case 145: + case 146: return true; } } @@ -3745,11 +4001,11 @@ var ts; } ts.isFunctionLike = isFunctionLike; function isFunctionBlock(node) { - return node && node.kind === 180 && isFunctionLike(node.parent); + return node && node.kind === 182 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 135 && node.parent.kind === 155; + return node && node.kind === 136 && node.parent.kind === 157; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -3768,36 +4024,36 @@ var ts; return undefined; } switch (node.kind) { - case 128: - if (node.parent.parent.kind === 202) { + case 129: + if (node.parent.parent.kind === 204) { return node; } node = node.parent; break; - case 131: - if (node.parent.kind === 130 && isClassElement(node.parent.parent)) { + case 132: + if (node.parent.kind === 131 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 164: + case 166: if (!includeArrowFunctions) { continue; } - case 201: - case 163: - case 206: - case 133: - case 132: - case 135: + case 203: + case 165: + case 208: case 134: + case 133: case 136: + case 135: case 137: case 138: - case 205: - case 228: + case 139: + case 207: + case 230: return node; } } @@ -3809,40 +4065,40 @@ var ts; if (!node) return node; switch (node.kind) { - case 128: - if (node.parent.parent.kind === 202) { + case 129: + if (node.parent.parent.kind === 204) { return node; } node = node.parent; break; - case 131: - if (node.parent.kind === 130 && isClassElement(node.parent.parent)) { + case 132: + if (node.parent.kind === 131 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 201: - case 163: - case 164: + case 203: + case 165: + case 166: if (!includeFunctions) { continue; } - case 133: - case 132: - case 135: case 134: + case 133: case 136: + case 135: case 137: case 138: + case 139: return node; } } } ts.getSuperContainer = getSuperContainer; function getInvokedExpression(node) { - if (node.kind === 160) { + if (node.kind === 162) { return node.tag; } return node.expression; @@ -3850,40 +4106,40 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 202: + case 204: return true; - case 133: - return node.parent.kind === 202; - case 130: - return node.parent.body && node.parent.parent.kind === 202; - case 137: + case 134: + return node.parent.kind === 204; + case 131: + return node.parent.body && node.parent.parent.kind === 204; case 138: - case 135: - return node.body && node.parent.kind === 202; + case 139: + case 136: + return node.body && node.parent.kind === 204; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 202: + case 204: if (node.decorators) { return true; } return false; - case 133: - case 130: + case 134: + case 131: if (node.decorators) { return true; } return false; - case 137: + case 138: if (node.body && node.decorators) { return true; } return false; - case 135: - case 138: + case 136: + case 139: if (node.body && node.decorators) { return true; } @@ -3894,10 +4150,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 202: + case 204: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 135: - case 138: + case 136: + case 139: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -3915,8 +4171,6 @@ var ts; case 95: case 80: case 9: - case 154: - case 155: case 156: case 157: case 158: @@ -3925,71 +4179,75 @@ var ts; case 161: case 162: case 163: - case 175: case 164: - case 167: case 165: + case 177: case 166: - case 168: case 169: + case 167: + case 168: case 170: case 171: - case 174: case 172: - case 10: - case 176: case 173: + case 176: + case 174: + case 10: + case 178: + case 175: return true; - case 127: - while (node.parent.kind === 127) { + case 128: + while (node.parent.kind === 128) { node = node.parent; } - return node.parent.kind === 145; + return node.parent.kind === 147; case 65: - if (node.parent.kind === 145) { + if (node.parent.kind === 147) { return true; } case 7: case 8: var parent_2 = node.parent; switch (parent_2.kind) { - case 199: - case 130: + case 201: + case 131: + case 134: case 133: - case 132: + case 229: case 227: - case 225: - case 153: + case 155: return parent_2.initializer === node; - case 183: - case 184: case 185: case 186: - case 192: - case 193: - case 194: - case 221: - case 196: - case 194: - return parent_2.expression === node; case 187: + case 188: + case 194: + case 195: + case 196: + case 223: + case 198: + case 196: + return parent_2.expression === node; + case 189: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 200) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 202) || forStatement.condition === node || forStatement.incrementor === node; - case 188: - case 189: + case 190: + case 191: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 200) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 202) || forInStatement.expression === node; - case 161: + case 163: return node === parent_2.expression; - case 178: + case 180: return node === parent_2.expression; - case 128: + case 129: return node === parent_2.expression; - case 131: + case 132: return true; + case 179: + return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { return true; @@ -4006,7 +4264,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 209 && node.moduleReference.kind === 220; + return node.kind === 211 && node.moduleReference.kind === 222; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -4015,20 +4273,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 209 && node.moduleReference.kind !== 220; + return node.kind === 211 && node.moduleReference.kind !== 222; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 210) { + if (node.kind === 212) { return node.moduleSpecifier; } - if (node.kind === 209) { + if (node.kind === 211) { var reference = node.moduleReference; - if (reference.kind === 220) { + if (reference.kind === 222) { return reference.expression; } } - if (node.kind === 216) { + if (node.kind === 218) { return node.moduleSpecifier; } } @@ -4036,15 +4294,15 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 130: + case 131: return node.questionToken !== undefined; + case 136: case 135: - case 134: return node.questionToken !== undefined; - case 226: - case 225: + case 228: + case 227: + case 134: case 133: - case 132: return node.questionToken !== undefined; } } @@ -4052,9 +4310,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 241 && + return node.kind === 243 && node.parameters.length > 0 && - node.parameters[0].type.kind === 243; + node.parameters[0].type.kind === 245; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -4068,15 +4326,15 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 249); + return getJSDocTag(node, 251); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 248); + return getJSDocTag(node, 250); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 250); + return getJSDocTag(node, 252); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { @@ -4085,7 +4343,7 @@ var ts; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 247) { + if (t.kind === 249) { var parameterTag = t; var name_5 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_5.text === parameterName) { @@ -4104,12 +4362,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 64) { - if (node.type && node.type.kind === 242) { + if (node.type && node.type.kind === 244) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 242; + return paramTag.typeExpression.type.kind === 244; } } return node.dotDotDotToken !== undefined; @@ -4130,7 +4388,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 152 || node.kind === 151); + return !!node && (node.kind === 154 || node.kind === 153); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -4145,33 +4403,33 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 164: - case 153: - case 202: - case 136: - case 205: - case 227: - case 218: - case 201: - case 163: - case 137: - case 211: - case 209: - case 214: - case 203: - case 135: - case 134: - case 206: - case 212: - case 130: - case 225: - case 133: - case 132: - case 138: - case 226: + case 166: + case 155: case 204: - case 129: - case 199: + case 137: + case 207: + case 229: + case 220: + case 203: + case 165: + case 138: + case 213: + case 211: + case 216: + case 205: + case 136: + case 135: + case 208: + case 214: + case 131: + case 227: + case 134: + case 133: + case 139: + case 228: + case 206: + case 130: + case 201: return true; } return false; @@ -4179,25 +4437,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 191: - case 190: - case 198: - case 185: - case 183: - case 182: - case 188: - case 189: - case 187: - case 184: - case 195: - case 192: - case 194: - case 94: - case 197: - case 181: - case 186: case 193: - case 215: + case 192: + case 200: + case 187: + case 185: + case 184: + case 190: + case 191: + case 189: + case 186: + case 197: + case 194: + case 196: + case 94: + case 199: + case 183: + case 188: + case 195: + case 217: return true; default: return false; @@ -4206,13 +4464,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 136: - case 133: - case 135: case 137: - case 138: case 134: - case 141: + case 136: + case 138: + case 139: + case 135: + case 142: return true; default: return false; @@ -4224,7 +4482,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 214 || parent.kind === 218) { + if (parent.kind === 216 || parent.kind === 220) { if (parent.propertyName) { return true; } @@ -4235,13 +4493,43 @@ var ts; return false; } ts.isDeclarationName = isDeclarationName; + function isIdentifierName(node) { + var parent = node.parent; + switch (parent.kind) { + case 134: + case 133: + case 136: + case 135: + case 138: + case 139: + case 229: + case 227: + case 158: + return parent.name === node; + case 128: + if (parent.right === node) { + while (parent.kind === 128) { + parent = parent.parent; + } + return parent.kind === 147; + } + return false; + case 155: + case 216: + return parent.propertyName === node; + case 220: + return true; + } + return false; + } + ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 209 || - node.kind === 211 && !!node.name || - node.kind === 212 || + return node.kind === 211 || + node.kind === 213 && !!node.name || node.kind === 214 || - node.kind === 218 || - node.kind === 215 && node.expression.kind === 65; + node.kind === 216 || + node.kind === 220 || + node.kind === 217 && node.expression.kind === 65; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { @@ -4324,7 +4612,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 66 <= token && token <= 126; + return 66 <= token && token <= 127; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -4333,19 +4621,19 @@ var ts; ts.isTrivia = isTrivia; function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 128 && + declaration.name.kind === 129 && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; function isWellKnownSymbolSyntactically(node) { - return node.kind === 156 && isESSymbolIdentifier(node.expression); + return node.kind === 158 && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { if (name.kind === 65 || name.kind === 8 || name.kind === 7) { return name.text; } - if (name.kind === 128) { + if (name.kind === 129) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -4380,18 +4668,18 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 130; + return root.kind === 131; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 153) { + while (node.kind === 155) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 206 || n.kind === 228; + return isFunctionLike(n) || n.kind === 208 || n.kind === 230; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -4615,7 +4903,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 136 && nodeIsPresent(member.body)) { + if (member.kind === 137 && nodeIsPresent(member.body)) { return member; } }); @@ -4638,10 +4926,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 137) { + if (accessor.kind === 138) { getAccessor = accessor; } - else if (accessor.kind === 138) { + else if (accessor.kind === 139) { setAccessor = accessor; } else { @@ -4650,7 +4938,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 137 || member.kind === 138) + if ((member.kind === 138 || member.kind === 139) && (member.flags & 128) === (accessor.flags & 128)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -4661,10 +4949,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 137 && !getAccessor) { + if (member.kind === 138 && !getAccessor) { getAccessor = member; } - if (member.kind === 138 && !setAccessor) { + if (member.kind === 139 && !setAccessor) { setAccessor = member; } } @@ -4785,22 +5073,22 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 156: - case 157: - case 159: case 158: + case 159: + case 161: case 160: - case 154: case 162: - case 155: - case 175: - case 163: + case 156: + case 164: + case 157: + case 177: + case 165: case 65: case 9: case 7: case 8: case 10: - case 172: + case 174: case 80: case 89: case 93: @@ -4816,6 +5104,12 @@ var ts; return token >= 53 && token <= 64; } ts.isAssignmentOperator = isAssignmentOperator; + function isExpressionWithTypeArgumentsInClassExtendsClause(node) { + return node.kind === 179 && + node.parent.token === 79 && + node.parent.parent.kind === 204; + } + ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isSupportedExpressionWithTypeArguments(node) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } @@ -4824,7 +5118,7 @@ var ts; if (node.kind === 65) { return true; } - else if (node.kind === 156) { + else if (node.kind === 158) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -4832,8 +5126,8 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 127 && node.parent.right === node) || - (node.parent.kind === 156 && node.parent.name === node); + return (node.parent.kind === 128 && node.parent.right === node) || + (node.parent.kind === 158 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function getLocalSymbolForExportDefault(symbol) { @@ -4960,6 +5254,12 @@ var ts; return start <= textSpanEnd(span) && end >= span.start; } ts.textSpanIntersectsWith = textSpanIntersectsWith; + function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { + var end1 = start1 + length1; + var end2 = start2 + length2; + return start2 <= end1 && end2 >= start1; + } + ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; function textSpanIntersectsWithPosition(span, position) { return position <= textSpanEnd(span) && position >= span.start; } @@ -5030,9 +5330,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 129) { + if (d && d.kind === 130) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 203) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 205) { return current; } } @@ -5044,7 +5344,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(252); + var nodeConstructors = new Array(254); ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -5082,20 +5382,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 127: + case 128: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 129: + case 130: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 130: + case 131: + case 134: case 133: - case 132: - case 225: - case 226: - case 199: - case 153: + case 227: + case 228: + case 201: + case 155: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -5104,24 +5404,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 143: - case 144: - case 139: + case 145: + case 146: case 140: case 141: + case 142: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 135: - case 134: case 136: + case 135: case 137: case 138: - case 163: - case 201: - case 164: + case 139: + case 165: + case 203: + case 166: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -5132,263 +5432,267 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 142: + case 144: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 145: - return visitNode(cbNode, node.exprName); - case 146: - return visitNodes(cbNodes, node.members); + case 143: + return visitNode(cbNode, node.parameterName) || + visitNode(cbNode, node.type); case 147: - return visitNode(cbNode, node.elementType); + return visitNode(cbNode, node.exprName); case 148: - return visitNodes(cbNodes, node.elementTypes); + return visitNodes(cbNodes, node.members); case 149: - return visitNodes(cbNodes, node.types); + return visitNode(cbNode, node.elementType); case 150: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.elementTypes); case 151: + return visitNodes(cbNodes, node.types); case 152: - return visitNodes(cbNodes, node.elements); + return visitNode(cbNode, node.type); + case 153: case 154: return visitNodes(cbNodes, node.elements); - case 155: - return visitNodes(cbNodes, node.properties); case 156: + return visitNodes(cbNodes, node.elements); + case 157: + return visitNodes(cbNodes, node.properties); + case 158: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 157: + case 159: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 158: - case 159: + case 160: + case 161: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 160: + case 162: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 161: + case 163: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 162: - return visitNode(cbNode, node.expression); - case 165: - return visitNode(cbNode, node.expression); - case 166: + case 164: return visitNode(cbNode, node.expression); case 167: return visitNode(cbNode, node.expression); case 168: + return visitNode(cbNode, node.expression); + case 169: + return visitNode(cbNode, node.expression); + case 170: return visitNode(cbNode, node.operand); - case 173: + case 175: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 169: + case 171: return visitNode(cbNode, node.operand); - case 170: + case 172: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 171: + case 173: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 174: + case 176: return visitNode(cbNode, node.expression); - case 180: - case 207: + case 182: + case 209: return visitNodes(cbNodes, node.statements); - case 228: + case 230: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 181: + case 183: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 200: + case 202: return visitNodes(cbNodes, node.declarations); - case 183: + case 185: return visitNode(cbNode, node.expression); - case 184: + case 186: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 185: + case 187: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 186: + case 188: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 187: + case 189: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 188: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 189: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 190: - case 191: - return visitNode(cbNode, node.label); - case 192: - return visitNode(cbNode, node.expression); - case 193: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 191: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 192: + case 193: + return visitNode(cbNode, node.label); case 194: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.caseBlock); - case 208: - return visitNodes(cbNodes, node.clauses); - case 221: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.statements); - case 222: - return visitNodes(cbNodes, node.statements); + return visitNode(cbNode, node.expression); case 195: - return visitNode(cbNode, node.label) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 196: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.caseBlock); + case 210: + return visitNodes(cbNodes, node.clauses); + case 223: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.statements); + case 224: + return visitNodes(cbNodes, node.statements); case 197: + return visitNode(cbNode, node.label) || + visitNode(cbNode, node.statement); + case 198: + return visitNode(cbNode, node.expression); + case 199: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 224: + case 226: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 131: + case 132: return visitNode(cbNode, node.expression); - case 202: - case 175: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); - case 203: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); case 204: + case 177: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 205: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 227: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); case 206: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); + case 207: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 229: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 208: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 209: + case 211: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 210: + case 212: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 211: + case 213: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 212: + case 214: return visitNode(cbNode, node.name); - case 213: - case 217: + case 215: + case 219: return visitNodes(cbNodes, node.elements); - case 216: + case 218: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 214: - case 218: + case 216: + case 220: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 215: + case 217: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 172: + case 174: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 178: + case 180: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 128: + case 129: return visitNode(cbNode, node.expression); - case 223: + case 225: return visitNodes(cbNodes, node.types); - case 177: + case 179: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 220: + case 222: return visitNode(cbNode, node.expression); - case 219: + case 221: return visitNodes(cbNodes, node.decorators); - case 229: - return visitNode(cbNode, node.type); - case 233: - return visitNodes(cbNodes, node.types); - case 234: - return visitNodes(cbNodes, node.types); - case 232: - return visitNode(cbNode, node.elementType); - case 236: + case 231: return visitNode(cbNode, node.type); case 235: + return visitNodes(cbNodes, node.types); + case 236: + return visitNodes(cbNodes, node.types); + case 234: + return visitNode(cbNode, node.elementType); + case 238: return visitNode(cbNode, node.type); case 237: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.type); case 239: + return visitNodes(cbNodes, node.members); + case 241: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 240: - return visitNode(cbNode, node.type); - case 241: - return visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); case 242: return visitNode(cbNode, node.type); case 243: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); case 244: return visitNode(cbNode, node.type); - case 238: + case 245: + return visitNode(cbNode, node.type); + case 246: + return visitNode(cbNode, node.type); + case 240: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 245: - return visitNodes(cbNodes, node.tags); case 247: + return visitNodes(cbNodes, node.tags); + case 249: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 248: - return visitNode(cbNode, node.typeExpression); - case 249: - return visitNode(cbNode, node.typeExpression); case 250: + return visitNode(cbNode, node.typeExpression); + case 251: + return visitNode(cbNode, node.typeExpression); + case 252: return visitNodes(cbNodes, node.typeParameters); } } @@ -5462,7 +5766,7 @@ var ts; sourceFile = createSourceFile(fileName, languageVersion); token = nextToken(); processReferenceComments(sourceFile); - sourceFile.statements = parseList(0, true, parseSourceElement); + sourceFile.statements = parseList(0, parseStatement); ts.Debug.assert(token === 1); sourceFile.endOfFileToken = parseTokenNode(); setExternalModuleIndicator(sourceFile); @@ -5483,9 +5787,9 @@ var ts; return; function visit(node) { switch (node.kind) { - case 181: - case 201: - case 130: + case 183: + case 203: + case 131: addJSDocComment(node); } forEachChild(node, visit); @@ -5523,7 +5827,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(228, 0); + var sourceFile = createNode(230, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -5541,9 +5845,6 @@ var ts; contextFlags &= ~flag; } } - function setStrictModeContext(val) { - setContextFlag(val, 1); - } function setDisallowInContext(val) { setContextFlag(val, 2); } @@ -5614,9 +5915,6 @@ var ts; function inYieldContext() { return (contextFlags & 4) !== 0; } - function inStrictModeContext() { - return (contextFlags & 1) !== 0; - } function inGeneratorParameterContext() { return (contextFlags & 8) !== 0; } @@ -5825,7 +6123,7 @@ var ts; return token === 8 || token === 7 || isIdentifierOrKeyword(); } function parseComputedPropertyName() { - var node = createNode(128); + var node = createNode(129); parseExpected(18); var yieldContext = inYieldContext(); if (inGeneratorParameterContext()) { @@ -5879,23 +6177,21 @@ var ts; switch (parsingContext) { case 0: case 1: - return !(token === 22 && inErrorRecovery) && isStartOfModuleElement(); - case 2: - case 4: - return !(token === 22 && inErrorRecovery) && isStartOfStatement(); case 3: + return !(token === 22 && inErrorRecovery) && isStartOfStatement(); + case 2: return token === 67 || token === 73; - case 5: + case 4: return isStartOfTypeMember(); - case 6: + case 5: return lookAhead(isClassMemberStart) || (token === 22 && !inErrorRecovery); - case 7: + case 6: return token === 18 || isLiteralPropertyName(); - case 13: + case 12: return token === 18 || token === 35 || isLiteralPropertyName(); - case 10: + case 9: return isLiteralPropertyName(); - case 8: + case 7: if (token === 14) { return lookAhead(isValidHeritageClauseObjectLiteral); } @@ -5905,29 +6201,29 @@ var ts; else { return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); } - case 9: + case 8: return isIdentifierOrPattern(); - case 11: + case 10: return token === 23 || token === 21 || isIdentifierOrPattern(); - case 16: - return isIdentifier(); - case 12: - case 14: - return token === 23 || token === 21 || isStartOfExpression(); case 15: + return isIdentifier(); + case 11: + case 13: + return token === 23 || token === 21 || isStartOfExpression(); + case 14: return isStartOfParameter(); + case 16: case 17: - case 18: return token === 23 || isStartOfType(); - case 19: + case 18: return isHeritageClause(); - case 20: + case 19: return isIdentifierOrKeyword(); + case 20: case 21: - case 22: - case 24: - return JSDocParser.isJSDocType(); case 23: + return JSDocParser.isJSDocType(); + case 22: return isSimplePropertyName(); } ts.Debug.fail("Non-exhaustive case in 'isListElement'."); @@ -5962,41 +6258,40 @@ var ts; switch (kind) { case 1: case 2: - case 3: + case 4: case 5: case 6: - case 7: - case 13: - case 10: - case 20: - return token === 15; - case 4: - return token === 15 || token === 67 || token === 73; - case 8: - return token === 14 || token === 79 || token === 102; - case 9: - return isVariableDeclaratorListTerminator(); - case 16: - return token === 25 || token === 16 || token === 14 || token === 79 || token === 102; case 12: - return token === 17 || token === 22; - case 14: - case 18: - case 11: - return token === 19; - case 15: - return token === 17 || token === 19; - case 17: - return token === 25 || token === 16; + case 9: case 19: + return token === 15; + case 3: + return token === 15 || token === 67 || token === 73; + case 7: + return token === 14 || token === 79 || token === 102; + case 8: + return isVariableDeclaratorListTerminator(); + case 15: + return token === 25 || token === 16 || token === 14 || token === 79 || token === 102; + case 11: + return token === 17 || token === 22; + case 13: + case 17: + case 10: + return token === 19; + case 14: + return token === 17 || token === 19; + case 16: + return token === 25 || token === 16; + case 18: return token === 14 || token === 15; - case 21: + case 20: return token === 17 || token === 51 || token === 15; - case 22: + case 21: return token === 25 || token === 15; - case 24: - return token === 19 || token === 15; case 23: + return token === 19 || token === 15; + case 22: return token === 15; } } @@ -6013,7 +6308,7 @@ var ts; return false; } function isInSomeParsingContext() { - for (var kind = 0; kind < 25; kind++) { + for (var kind = 0; kind < 24; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, true) || isListTerminator(kind)) { return true; @@ -6022,43 +6317,25 @@ var ts; } return false; } - function parseList(kind, checkForStrictMode, parseElement) { + function parseList(kind, parseElement) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; var result = []; result.pos = getNodePos(); - var savedStrictModeContext = inStrictModeContext(); while (!isListTerminator(kind)) { if (isListElement(kind, false)) { var element = parseListElement(kind, parseElement); result.push(element); - if (checkForStrictMode && !inStrictModeContext()) { - if (ts.isPrologueDirective(element)) { - if (isUseStrictPrologueDirective(element)) { - setStrictModeContext(true); - checkForStrictMode = false; - } - } - else { - checkForStrictMode = false; - } - } continue; } if (abortParsingListOrMoveToNextToken(kind)) { break; } } - setStrictModeContext(savedStrictModeContext); result.end = getNodeEnd(); parsingContext = saveParsingContext; return result; } - function isUseStrictPrologueDirective(node) { - ts.Debug.assert(ts.isPrologueDirective(node)); - var nodeText = ts.getTextOfNodeFromSourceText(sourceText, node.expression); - return nodeText === '"use strict"' || nodeText === "'use strict'"; - } function parseListElement(parsingContext, parseElement) { var node = currentNode(parsingContext); if (node) { @@ -6083,7 +6360,7 @@ var ts; if (ts.containsParseError(node)) { return undefined; } - var nodeContextFlags = node.parserContextFlags & 63; + var nodeContextFlags = node.parserContextFlags & 62; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -6099,61 +6376,47 @@ var ts; } function canReuseNode(node, parsingContext) { switch (parsingContext) { - case 1: - return isReusableModuleElement(node); - case 6: - return isReusableClassMember(node); - case 3: - return isReusableSwitchClause(node); - case 2: - case 4: - return isReusableStatement(node); - case 7: - return isReusableEnumMember(node); case 5: + return isReusableClassMember(node); + case 2: + return isReusableSwitchClause(node); + case 0: + case 1: + case 3: + return isReusableStatement(node); + case 6: + return isReusableEnumMember(node); + case 4: return isReusableTypeMember(node); - case 9: - return isReusableVariableDeclaration(node); - case 15: - return isReusableParameter(node); - case 19: - case 16: - case 18: - case 17: - case 12: - case 13: case 8: - } - return false; - } - function isReusableModuleElement(node) { - if (node) { - switch (node.kind) { - case 210: - case 209: - case 216: - case 215: - case 202: - case 203: - case 206: - case 205: - return true; - } - return isReusableStatement(node); + return isReusableVariableDeclaration(node); + case 14: + return isReusableParameter(node); + case 18: + case 15: + case 17: + case 16: + case 11: + case 12: + case 7: } return false; } function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 136: - case 141: - case 135: case 137: + case 142: case 138: - case 133: - case 179: + case 139: + case 134: + case 181: return true; + case 136: + var methodDeclaration = node; + var nameIsConstructor = methodDeclaration.name.kind === 65 && + methodDeclaration.name.originalKeywordKind === 114; + return !nameIsConstructor; } } return false; @@ -6161,8 +6424,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 221: - case 222: + case 223: + case 224: return true; } } @@ -6171,56 +6434,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 201: - case 181: - case 180: - case 184: + case 203: case 183: - case 196: - case 192: - case 194: - case 191: - case 190: - case 188: - case 189: - case 187: - case 186: - case 193: case 182: - case 197: - case 195: + case 186: case 185: case 198: + case 194: + case 196: + case 193: + case 192: + case 190: + case 191: + case 189: + case 188: + case 195: + case 184: + case 199: + case 197: + case 187: + case 200: + case 212: + case 211: + case 218: + case 217: + case 208: + case 204: + case 205: + case 207: + case 206: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 227; + return node.kind === 229; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 140: - case 134: case 141: - case 132: - case 139: + case 135: + case 142: + case 133: + case 140: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 199) { + if (node.kind !== 201) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 130) { + if (node.kind !== 131) { return false; } var parameter = node; @@ -6238,29 +6510,28 @@ var ts; switch (context) { case 0: return ts.Diagnostics.Declaration_or_statement_expected; case 1: return ts.Diagnostics.Declaration_or_statement_expected; - case 2: return ts.Diagnostics.Statement_expected; - case 3: return ts.Diagnostics.case_or_default_expected; - case 4: return ts.Diagnostics.Statement_expected; - case 5: return ts.Diagnostics.Property_or_signature_expected; - case 6: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; - case 7: return ts.Diagnostics.Enum_member_expected; - case 8: return ts.Diagnostics.Expression_expected; - case 9: return ts.Diagnostics.Variable_declaration_expected; - case 10: return ts.Diagnostics.Property_destructuring_pattern_expected; - case 11: return ts.Diagnostics.Array_element_destructuring_pattern_expected; - case 12: return ts.Diagnostics.Argument_expression_expected; - case 13: return ts.Diagnostics.Property_assignment_expected; - case 14: return ts.Diagnostics.Expression_or_comma_expected; - case 15: return ts.Diagnostics.Parameter_declaration_expected; - case 16: return ts.Diagnostics.Type_parameter_declaration_expected; - case 17: return ts.Diagnostics.Type_argument_expected; - case 18: return ts.Diagnostics.Type_expected; - case 19: return ts.Diagnostics.Unexpected_token_expected; - case 20: return ts.Diagnostics.Identifier_expected; - case 21: return ts.Diagnostics.Parameter_declaration_expected; - case 22: return ts.Diagnostics.Type_argument_expected; - case 24: return ts.Diagnostics.Type_expected; - case 23: return ts.Diagnostics.Property_assignment_expected; + case 2: return ts.Diagnostics.case_or_default_expected; + case 3: return ts.Diagnostics.Statement_expected; + case 4: return ts.Diagnostics.Property_or_signature_expected; + case 5: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; + case 6: return ts.Diagnostics.Enum_member_expected; + case 7: return ts.Diagnostics.Expression_expected; + case 8: return ts.Diagnostics.Variable_declaration_expected; + case 9: return ts.Diagnostics.Property_destructuring_pattern_expected; + case 10: return ts.Diagnostics.Array_element_destructuring_pattern_expected; + case 11: return ts.Diagnostics.Argument_expression_expected; + case 12: return ts.Diagnostics.Property_assignment_expected; + case 13: return ts.Diagnostics.Expression_or_comma_expected; + case 14: return ts.Diagnostics.Parameter_declaration_expected; + case 15: return ts.Diagnostics.Type_parameter_declaration_expected; + case 16: return ts.Diagnostics.Type_argument_expected; + case 17: return ts.Diagnostics.Type_expected; + case 18: return ts.Diagnostics.Unexpected_token_expected; + case 19: return ts.Diagnostics.Identifier_expected; + case 20: return ts.Diagnostics.Parameter_declaration_expected; + case 21: return ts.Diagnostics.Type_argument_expected; + case 23: return ts.Diagnostics.Type_expected; + case 22: return ts.Diagnostics.Property_assignment_expected; } } ; @@ -6319,7 +6590,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(20)) { - var node = createNode(127, entity.pos); + var node = createNode(128, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -6327,7 +6598,7 @@ var ts; return entity; } function parseRightSideOfDot(allowIdentifierNames) { - if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord()) { + if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { return createMissingNode(65, true, ts.Diagnostics.Identifier_expected); @@ -6336,7 +6607,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(172); + var template = createNode(174); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 11, "Template head has wrong token kind"); var templateSpans = []; @@ -6349,7 +6620,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(178); + var span = createNode(180); span.expression = allowInAnd(parseExpression); var literal; if (token === 15) { @@ -6382,22 +6653,30 @@ var ts; } return node; } - function parseTypeReference() { - var node = createNode(142); - node.typeName = parseEntityName(false, ts.Diagnostics.Type_expected); + function parseTypeReferenceOrTypePredicate() { + var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); + if (typeName.kind === 65 && token === 117 && !scanner.hasPrecedingLineBreak()) { + nextToken(); + var node_1 = createNode(143, typeName.pos); + node_1.parameterName = typeName; + node_1.type = parseType(); + return finishNode(node_1); + } + var node = createNode(144, typeName.pos); + node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 24) { - node.typeArguments = parseBracketedList(17, parseType, 24, 25); + node.typeArguments = parseBracketedList(16, parseType, 24, 25); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(145); + var node = createNode(147); parseExpected(97); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(129); + var node = createNode(130); node.name = parseIdentifier(); if (parseOptional(79)) { if (isStartOfType() || !isStartOfExpression()) { @@ -6411,7 +6690,7 @@ var ts; } function parseTypeParameters() { if (token === 24) { - return parseBracketedList(16, parseTypeParameter, 24, 25); + return parseBracketedList(15, parseTypeParameter, 24, 25); } } function parseParameterType() { @@ -6432,7 +6711,7 @@ var ts; } } function parseParameter() { - var node = createNode(130); + var node = createNode(131); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(21); @@ -6466,7 +6745,7 @@ var ts; var savedGeneratorParameterContext = inGeneratorParameterContext(); setYieldContext(yieldAndGeneratorParameterContext); setGeneratorParameterContext(yieldAndGeneratorParameterContext); - var result = parseDelimitedList(15, parseParameter); + var result = parseDelimitedList(14, parseParameter); setYieldContext(savedYieldContext); setGeneratorParameterContext(savedGeneratorParameterContext); if (!parseExpected(17) && requireCompleteParameterList) { @@ -6484,7 +6763,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 140) { + if (kind === 141) { parseExpected(88); } fillSignature(51, false, false, node); @@ -6524,10 +6803,10 @@ var ts; return token === 51 || token === 23 || token === 19; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(141, fullStart); + var node = createNode(142, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.parameters = parseBracketedList(15, parseParameter, 18, 19); + node.parameters = parseBracketedList(14, parseParameter, 18, 19); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); @@ -6537,7 +6816,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(50); if (token === 16 || token === 24) { - var method = createNode(134, fullStart); + var method = createNode(135, fullStart); method.name = name; method.questionToken = questionToken; fillSignature(51, false, false, method); @@ -6545,7 +6824,7 @@ var ts; return finishNode(method); } else { - var property = createNode(132, fullStart); + var property = createNode(133, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -6587,14 +6866,14 @@ var ts; switch (token) { case 16: case 24: - return parseSignatureMember(139); + return parseSignatureMember(140); case 18: return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); case 88: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(140); + return parseSignatureMember(141); } case 8: case 7: @@ -6624,14 +6903,14 @@ var ts; return token === 16 || token === 24; } function parseTypeLiteral() { - var node = createNode(146); + var node = createNode(148); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; if (parseExpected(14)) { - members = parseList(5, false, parseTypeMember); + members = parseList(4, parseTypeMember); parseExpected(15); } else { @@ -6640,12 +6919,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(148); - node.elementTypes = parseBracketedList(18, parseType, 18, 19); + var node = createNode(150); + node.elementTypes = parseBracketedList(17, parseType, 18, 19); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(150); + var node = createNode(152); parseExpected(16); node.type = parseType(); parseExpected(17); @@ -6653,7 +6932,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 144) { + if (kind === 146) { parseExpected(88); } fillSignature(32, false, false, node); @@ -6666,12 +6945,12 @@ var ts; function parseNonArrayType() { switch (token) { case 112: - case 122: - case 120: - case 113: case 123: + case 121: + case 113: + case 124: var node = tryParse(parseKeywordAndNoDot); - return node || parseTypeReference(); + return node || parseTypeReferenceOrTypePredicate(); case 99: return parseTokenNode(); case 97: @@ -6683,16 +6962,16 @@ var ts; case 16: return parseParenthesizedType(); default: - return parseTypeReference(); + return parseTypeReferenceOrTypePredicate(); } } function isStartOfType() { switch (token) { case 112: - case 122: - case 120: - case 113: case 123: + case 121: + case 113: + case 124: case 99: case 97: case 14: @@ -6714,7 +6993,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(18)) { parseExpected(19); - var node = createNode(147, type.pos); + var node = createNode(149, type.pos); node.elementType = type; type = finishNode(node); } @@ -6729,7 +7008,7 @@ var ts; types.push(parseArrayTypeOrHigher()); } types.end = getNodeEnd(); - var node = createNode(149, type.pos); + var node = createNode(151, type.pos); node.types = types; type = finishNode(node); } @@ -6774,10 +7053,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(143); + return parseFunctionOrConstructorType(145); } if (token === 88) { - return parseFunctionOrConstructorType(144); + return parseFunctionOrConstructorType(146); } return parseUnionTypeOrHigher(); } @@ -6898,10 +7177,7 @@ var ts; if (inYieldContext()) { return true; } - if (inStrictModeContext()) { - return true; - } - return lookAhead(nextTokenIsIdentifierOnSameLine); + return lookAhead(nextTokenIsIdentifierOrKeywordOrNumberOnSameLine); } return false; } @@ -6910,7 +7186,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(173); + var node = createNode(175); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token === 35 || isStartOfExpression())) { @@ -6924,8 +7200,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 32, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(164, identifier.pos); - var parameter = createNode(130, identifier.pos); + var node = createNode(166, identifier.pos); + var parameter = createNode(131, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -7003,7 +7279,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(164); + var node = createNode(166); fillSignature(51, false, !allowAmbiguity, node); if (!node.parameters) { return undefined; @@ -7031,7 +7307,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(171, leftOperand.pos); + var node = createNode(173, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -7044,7 +7320,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 86 || t === 126; + return t === 86 || t === 127; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -7105,33 +7381,33 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(170, left.pos); + var node = createNode(172, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(168); + var node = createNode(170); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(165); + var node = createNode(167); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(166); + var node = createNode(168); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(167); + var node = createNode(169); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -7161,7 +7437,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token === 38 || token === 39) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(169, expression.pos); + var node = createNode(171, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -7184,14 +7460,14 @@ var ts; if (token === 16 || token === 20) { return expression; } - var node = createNode(156, expression.pos); + var node = createNode(158, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(20, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } function parseTypeAssertion() { - var node = createNode(161); + var node = createNode(163); parseExpected(24); node.type = parseType(); parseExpected(25); @@ -7202,7 +7478,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(20); if (dotToken) { - var propertyAccess = createNode(156, expression.pos); + var propertyAccess = createNode(158, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); @@ -7210,7 +7486,7 @@ var ts; continue; } if (!inDecoratorContext() && parseOptional(18)) { - var indexedAccess = createNode(157, expression.pos); + var indexedAccess = createNode(159, expression.pos); indexedAccess.expression = expression; if (token !== 19) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -7224,7 +7500,7 @@ var ts; continue; } if (token === 10 || token === 11) { - var tagExpression = createNode(160, expression.pos); + var tagExpression = createNode(162, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 10 ? parseLiteralNode() @@ -7243,7 +7519,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(158, expression.pos); + var callExpr = createNode(160, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -7251,7 +7527,7 @@ var ts; continue; } else if (token === 16) { - var callExpr = createNode(158, expression.pos); + var callExpr = createNode(160, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -7262,7 +7538,7 @@ var ts; } function parseArgumentList() { parseExpected(16); - var result = parseDelimitedList(12, parseArgumentExpression); + var result = parseDelimitedList(11, parseArgumentExpression); parseExpected(17); return result; } @@ -7270,7 +7546,7 @@ var ts; if (!parseOptional(24)) { return undefined; } - var typeArguments = parseDelimitedList(17, parseType); + var typeArguments = parseDelimitedList(16, parseType); if (!parseExpected(25)) { return undefined; } @@ -7341,42 +7617,42 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(162); + var node = createNode(164); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); return finishNode(node); } function parseSpreadElement() { - var node = createNode(174); + var node = createNode(176); parseExpected(21); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 21 ? parseSpreadElement() : - token === 23 ? createNode(176) : + token === 23 ? createNode(178) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(154); + var node = createNode(156); parseExpected(18); if (scanner.hasPrecedingLineBreak()) node.flags |= 512; - node.elements = parseDelimitedList(14, parseArgumentOrArrayLiteralElement); + node.elements = parseDelimitedList(13, parseArgumentOrArrayLiteralElement); parseExpected(19); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(116)) { - return parseAccessorDeclaration(137, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(121)) { return parseAccessorDeclaration(138, fullStart, decorators, modifiers); } + else if (parseContextualModifier(122)) { + return parseAccessorDeclaration(139, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { @@ -7396,13 +7672,13 @@ var ts; return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } if ((token === 23 || token === 15) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(226, fullStart); + var shorthandDeclaration = createNode(228, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(225, fullStart); + var propertyAssignment = createNode(227, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; parseExpected(51); @@ -7411,12 +7687,12 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(155); + var node = createNode(157); parseExpected(14); if (scanner.hasPrecedingLineBreak()) { node.flags |= 512; } - node.properties = parseDelimitedList(13, parseObjectLiteralElement, true); + node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); parseExpected(15); return finishNode(node); } @@ -7425,7 +7701,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(163); + var node = createNode(165); parseExpected(83); node.asteriskToken = parseOptionalToken(35); node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); @@ -7440,7 +7716,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(159); + var node = createNode(161); parseExpected(88); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -7449,10 +7725,10 @@ var ts; } return finishNode(node); } - function parseBlock(ignoreMissingOpenBrace, checkForStrictMode, diagnosticMessage) { - var node = createNode(180); + function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { + var node = createNode(182); if (parseExpected(14, diagnosticMessage) || ignoreMissingOpenBrace) { - node.statements = parseList(2, checkForStrictMode, parseStatement); + node.statements = parseList(1, parseStatement); parseExpected(15); } else { @@ -7467,7 +7743,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var block = parseBlock(ignoreMissingOpenBrace, true, diagnosticMessage); + var block = parseBlock(ignoreMissingOpenBrace, diagnosticMessage); if (saveDecoratorContext) { setDecoratorContext(true); } @@ -7475,12 +7751,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(182); + var node = createNode(184); parseExpected(22); return finishNode(node); } function parseIfStatement() { - var node = createNode(184); + var node = createNode(186); parseExpected(84); parseExpected(16); node.expression = allowInAnd(parseExpression); @@ -7490,7 +7766,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(185); + var node = createNode(187); parseExpected(75); node.statement = parseStatement(); parseExpected(100); @@ -7501,7 +7777,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(186); + var node = createNode(188); parseExpected(100); parseExpected(16); node.expression = allowInAnd(parseExpression); @@ -7524,21 +7800,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(86)) { - var forInStatement = createNode(188, pos); + var forInStatement = createNode(190, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(17); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(126)) { - var forOfStatement = createNode(189, pos); + else if (parseOptional(127)) { + var forOfStatement = createNode(191, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(17); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(187, pos); + var forStatement = createNode(189, pos); forStatement.initializer = initializer; parseExpected(22); if (token !== 22 && token !== 17) { @@ -7556,7 +7832,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 191 ? 66 : 71); + parseExpected(kind === 193 ? 66 : 71); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -7564,7 +7840,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(192); + var node = createNode(194); parseExpected(90); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -7573,7 +7849,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(193); + var node = createNode(195); parseExpected(101); parseExpected(16); node.expression = allowInAnd(parseExpression); @@ -7582,32 +7858,32 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(221); + var node = createNode(223); parseExpected(67); node.expression = allowInAnd(parseExpression); parseExpected(51); - node.statements = parseList(4, false, parseStatement); + node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(222); + var node = createNode(224); parseExpected(73); parseExpected(51); - node.statements = parseList(4, false, parseStatement); + node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { return token === 67 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(194); + var node = createNode(196); parseExpected(92); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); - var caseBlock = createNode(208, scanner.getStartPos()); + var caseBlock = createNode(210, scanner.getStartPos()); parseExpected(14); - caseBlock.clauses = parseList(3, false, parseCaseOrDefaultClause); + caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(15); node.caseBlock = finishNode(caseBlock); return finishNode(node); @@ -7615,35 +7891,35 @@ var ts; function parseThrowStatement() { // ThrowStatement[Yield] : // throw [no LineTerminator here]Expression[In, ?Yield]; - var node = createNode(196); + var node = createNode(198); parseExpected(94); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(197); + var node = createNode(199); parseExpected(96); - node.tryBlock = parseBlock(false, false); + node.tryBlock = parseBlock(false); node.catchClause = token === 68 ? parseCatchClause() : undefined; if (!node.catchClause || token === 81) { parseExpected(81); - node.finallyBlock = parseBlock(false, false); + node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(224); + var result = createNode(226); parseExpected(68); if (parseExpected(16)) { result.variableDeclaration = parseVariableDeclaration(); } parseExpected(17); - result.block = parseBlock(false, false); + result.block = parseBlock(false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(198); + var node = createNode(200); parseExpected(72); parseSemicolon(); return finishNode(node); @@ -7652,13 +7928,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 65 && parseOptional(51)) { - var labeledStatement = createNode(195, fullStart); + var labeledStatement = createNode(197, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(183, fullStart); + var expressionStatement = createNode(185, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -7671,7 +7947,11 @@ var ts; nextToken(); return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); } - function parseDeclarationFlags() { + function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { + nextToken(); + return (isIdentifierOrKeyword() || token === 7) && !scanner.hasPrecedingLineBreak(); + } + function isDeclaration() { while (true) { switch (token) { case 98: @@ -7680,28 +7960,30 @@ var ts; case 83: case 69: case 77: - return 1; + return true; case 103: - case 124: - nextToken(); - return isIdentifierOrKeyword() ? 1 : 0; - case 117: + case 125: + return nextTokenIsIdentifierOnSameLine(); case 118: + case 119: + return nextTokenIsIdentifierOrStringLiteralOnSameLine(); + case 115: nextToken(); - return isIdentifierOrKeyword() || token === 8 ? 2 : 0; + if (scanner.hasPrecedingLineBreak()) { + return false; + } + continue; case 85: nextToken(); return token === 8 || token === 35 || - token === 14 || isIdentifierOrKeyword() ? - 2 : 0; + token === 14 || isIdentifierOrKeyword(); case 78: nextToken(); if (token === 53 || token === 35 || token === 14 || token === 73) { - return 2; + return true; } continue; - case 115: case 108: case 106: case 107: @@ -7709,14 +7991,14 @@ var ts; nextToken(); continue; default: - return 0; + return false; } } } - function getDeclarationFlags() { - return lookAhead(parseDeclarationFlags); + function isStartOfDeclaration() { + return lookAhead(isDeclaration); } - function getStatementFlags() { + function isStartOfStatement() { switch (token) { case 52: case 22: @@ -7740,56 +8022,39 @@ var ts; case 72: case 68: case 81: - return 1; + return true; case 70: case 78: case 85: - return getDeclarationFlags(); + return isStartOfDeclaration(); case 115: case 103: - case 117: case 118: - case 124: - return getDeclarationFlags() || 1; + case 119: + case 125: + return true; case 108: case 106: case 107: case 109: - return getDeclarationFlags() || - (lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? 0 : 1); + return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: - return isStartOfExpression() ? 1 : 0; + return isStartOfExpression(); } } - function isStartOfStatement() { - return (getStatementFlags() & 1) !== 0; - } - function isStartOfModuleElement() { - return (getStatementFlags() & 3) !== 0; - } - function nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine() { + function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return !scanner.hasPrecedingLineBreak() && - (isIdentifier() || token === 14 || token === 18); + return isIdentifier() || token === 14 || token === 18; } function isLetDeclaration() { - return inStrictModeContext() || lookAhead(nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine); + return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } function parseStatement() { - return parseModuleElementOfKind(1); - } - function parseModuleElement() { - return parseModuleElementOfKind(3); - } - function parseSourceElement() { - return parseModuleElementOfKind(3); - } - function parseModuleElementOfKind(flags) { switch (token) { case 22: return parseEmptyStatement(); case 14: - return parseBlock(false, false); + return parseBlock(false); case 98: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); case 104: @@ -7810,9 +8075,9 @@ var ts; case 82: return parseForOrForInOrForOfStatement(); case 71: - return parseBreakOrContinueStatement(190); + return parseBreakOrContinueStatement(192); case 66: - return parseBreakOrContinueStatement(191); + return parseBreakOrContinueStatement(193); case 90: return parseReturnStatement(); case 101: @@ -7829,20 +8094,20 @@ var ts; return parseDebuggerStatement(); case 52: return parseDeclaration(); - case 70: + case 103: + case 125: + case 118: + case 119: case 115: + case 70: case 77: case 78: case 85: - case 103: - case 117: - case 118: case 106: case 107: case 108: case 109: - case 124: - if (getDeclarationFlags() & flags) { + if (isStartOfDeclaration()) { return parseDeclaration(); } break; @@ -7864,12 +8129,12 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 103: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 124: + case 125: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 77: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 117: case 118: + case 119: return parseModuleDeclaration(fullStart, decorators, modifiers); case 85: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); @@ -7879,8 +8144,8 @@ var ts; parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: - if (decorators) { - var node = createMissingNode(219, true, ts.Diagnostics.Declaration_expected); + if (decorators || modifiers) { + var node = createMissingNode(221, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -7888,6 +8153,10 @@ var ts; } } } + function nextTokenIsIdentifierOrStringLiteralOnSameLine() { + nextToken(); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 8); + } function parseFunctionBlockOrSemicolon(isGenerator, diagnosticMessage) { if (token !== 14 && canParseSemicolon()) { parseSemicolon(); @@ -7897,16 +8166,16 @@ var ts; } function parseArrayBindingElement() { if (token === 23) { - return createNode(176); + return createNode(178); } - var node = createNode(153); + var node = createNode(155); node.dotDotDotToken = parseOptionalToken(21); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(153); + var node = createNode(155); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); if (tokenIsIdentifier && token !== 51) { @@ -7921,16 +8190,16 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(151); + var node = createNode(153); parseExpected(14); - node.elements = parseDelimitedList(10, parseObjectBindingElement); + node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(15); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(152); + var node = createNode(154); parseExpected(18); - node.elements = parseDelimitedList(11, parseArrayBindingElement); + node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(19); return finishNode(node); } @@ -7947,7 +8216,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(199); + var node = createNode(201); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -7956,7 +8225,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(200); + var node = createNode(202); switch (token) { case 98: break; @@ -7970,13 +8239,13 @@ var ts; ts.Debug.fail(); } nextToken(); - if (token === 126 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 127 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { var savedDisallowIn = inDisallowInContext(); setDisallowInContext(inForStatementInitializer); - node.declarations = parseDelimitedList(9, parseVariableDeclaration); + node.declarations = parseDelimitedList(8, parseVariableDeclaration); setDisallowInContext(savedDisallowIn); } return finishNode(node); @@ -7985,7 +8254,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 17; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(181, fullStart); + var node = createNode(183, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -7993,7 +8262,7 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(201, fullStart); + var node = createNode(203, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(83); @@ -8004,7 +8273,7 @@ var ts; return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(136, pos); + var node = createNode(137, pos); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(114); @@ -8013,7 +8282,7 @@ var ts; return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(135, fullStart); + var method = createNode(136, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -8024,7 +8293,7 @@ var ts; return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(133, fullStart); + var property = createNode(134, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -8093,7 +8362,7 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 121 || idToken === 116) { + if (!ts.isKeyword(idToken) || idToken === 122 || idToken === 116) { return true; } switch (token) { @@ -8120,7 +8389,7 @@ var ts; decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(131, decoratorStart); + var decorator = createNode(132, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -8153,7 +8422,7 @@ var ts; } function parseClassElement() { if (token === 22) { - var result = createNode(179); + var result = createNode(181); nextToken(); return finishNode(result); } @@ -8177,21 +8446,19 @@ var ts; token === 18) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } - if (decorators) { + if (decorators || modifiers) { var name_6 = createMissingNode(65, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_6, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 175); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 177); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 202); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 204); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { - var savedStrictModeContext = inStrictModeContext(); - setStrictModeContext(true); var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); @@ -8208,9 +8475,7 @@ var ts; else { node.members = createMissingList(); } - var finishedNode = finishNode(node); - setStrictModeContext(savedStrictModeContext); - return finishedNode; + return finishNode(node); } function parseHeritageClauses(isClassHeritageClause) { // ClassTail[Yield,GeneratorParameter] : See 14.5 @@ -8224,23 +8489,23 @@ var ts; return undefined; } function parseHeritageClausesWorker() { - return parseList(19, false, parseHeritageClause); + return parseList(18, parseHeritageClause); } function parseHeritageClause() { if (token === 79 || token === 102) { - var node = createNode(223); + var node = createNode(225); node.token = token; nextToken(); - node.types = parseDelimitedList(8, parseExpressionWithTypeArguments); + node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); return finishNode(node); } return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(177); + var node = createNode(179); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 24) { - node.typeArguments = parseBracketedList(17, parseType, 24, 25); + node.typeArguments = parseBracketedList(16, parseType, 24, 25); } return finishNode(node); } @@ -8248,10 +8513,10 @@ var ts; return token === 79 || token === 102; } function parseClassMembers() { - return parseList(6, false, parseClassElement); + return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(203, fullStart); + var node = createNode(205, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(103); @@ -8262,30 +8527,31 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(204, fullStart); + var node = createNode(206, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(124); + parseExpected(125); node.name = parseIdentifier(); + node.typeParameters = parseTypeParameters(); parseExpected(53); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNode(227, scanner.getStartPos()); + var node = createNode(229, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(205, fullStart); + var node = createNode(207, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(77); node.name = parseIdentifier(); if (parseExpected(14)) { - node.members = parseDelimitedList(7, parseEnumMember); + node.members = parseDelimitedList(6, parseEnumMember); parseExpected(15); } else { @@ -8294,9 +8560,9 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(207, scanner.getStartPos()); + var node = createNode(209, scanner.getStartPos()); if (parseExpected(14)) { - node.statements = parseList(1, false, parseModuleElement); + node.statements = parseList(1, parseStatement); parseExpected(15); } else { @@ -8305,7 +8571,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(206, fullStart); + var node = createNode(208, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; @@ -8316,7 +8582,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(206, fullStart); + var node = createNode(208, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -8325,11 +8591,11 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(118)) { + if (parseOptional(119)) { flags |= 32768; } else { - parseExpected(117); + parseExpected(118); if (token === 8) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -8337,7 +8603,7 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 119 && + return token === 120 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -8346,7 +8612,7 @@ var ts; function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 23 || - token === 125; + token === 126; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { parseExpected(85); @@ -8354,8 +8620,8 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 && token !== 125) { - var importEqualsDeclaration = createNode(209, fullStart); + if (token !== 23 && token !== 126) { + var importEqualsDeclaration = createNode(211, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; @@ -8365,14 +8631,14 @@ var ts; return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(210, fullStart); + var importDeclaration = createNode(212, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || token === 35 || token === 14) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(125); + parseExpected(126); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -8385,13 +8651,13 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(211, fullStart); + var importClause = createNode(213, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(23)) { - importClause.namedBindings = token === 35 ? parseNamespaceImport() : parseNamedImportsOrExports(213); + importClause.namedBindings = token === 35 ? parseNamespaceImport() : parseNamedImportsOrExports(215); } return finishNode(importClause); } @@ -8401,8 +8667,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(220); - parseExpected(119); + var node = createNode(222); + parseExpected(120); parseExpected(16); node.expression = parseModuleSpecifier(); parseExpected(17); @@ -8416,7 +8682,7 @@ var ts; return result; } function parseNamespaceImport() { - var namespaceImport = createNode(212); + var namespaceImport = createNode(214); parseExpected(35); parseExpected(111); namespaceImport.name = parseIdentifier(); @@ -8424,14 +8690,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(20, kind === 213 ? parseImportSpecifier : parseExportSpecifier, 14, 15); + node.elements = parseBracketedList(19, kind === 215 ? parseImportSpecifier : parseExportSpecifier, 14, 15); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(218); + return parseImportOrExportSpecifier(220); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(214); + return parseImportOrExportSpecifier(216); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -8450,22 +8716,22 @@ var ts; else { node.name = identifierName; } - if (kind === 214 && checkIdentifierIsKeyword) { + if (kind === 216 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216, fullStart); + var node = createNode(218, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(35)) { - parseExpected(125); + parseExpected(126); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(217); - if (parseOptional(125)) { + node.exportClause = parseNamedImportsOrExports(219); + if (parseOptional(126)) { node.moduleSpecifier = parseModuleSpecifier(); } } @@ -8473,7 +8739,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(215, fullStart); + var node = createNode(217, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(53)) { @@ -8538,15 +8804,15 @@ var ts; } sourceFile.referencedFiles = referencedFiles; sourceFile.amdDependencies = amdDependencies; - sourceFile.amdModuleName = amdModuleName; + sourceFile.moduleName = amdModuleName; } function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 - || node.kind === 209 && node.moduleReference.kind === 220 - || node.kind === 210 - || node.kind === 215 - || node.kind === 216 + || node.kind === 211 && node.moduleReference.kind === 222 + || node.kind === 212 + || node.kind === 217 + || node.kind === 218 ? node : undefined; }); @@ -8581,7 +8847,7 @@ var ts; function parseJSDocTypeExpression(start, length) { scanner.setText(sourceText, start, length); token = nextToken(); - var result = createNode(229); + var result = createNode(231); parseExpected(14); result.type = parseJSDocTopLevelType(); parseExpected(15); @@ -8592,12 +8858,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token === 44) { - var unionType = createNode(233, type.pos); + var unionType = createNode(235, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token === 53) { - var optionalType = createNode(240, type.pos); + var optionalType = createNode(242, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -8608,20 +8874,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 18) { - var arrayType = createNode(232, type.pos); + var arrayType = createNode(234, type.pos); arrayType.elementType = type; nextToken(); parseExpected(19); type = finishNode(arrayType); } else if (token === 50) { - var nullableType = createNode(235, type.pos); + var nullableType = createNode(237, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token === 46) { - var nonNullableType = createNode(236, type.pos); + var nonNullableType = createNode(238, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -8655,40 +8921,40 @@ var ts; case 93: return parseJSDocThisType(); case 112: - case 122: - case 120: - case 113: case 123: + case 121: + case 113: + case 124: case 99: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(244); + var result = createNode(246); nextToken(); parseExpected(51); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(243); + var result = createNode(245); nextToken(); parseExpected(51); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(242); + var result = createNode(244); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(241); + var result = createNode(243); nextToken(); parseExpected(16); - result.parameters = parseDelimitedList(21, parseJSDocParameter); + result.parameters = parseDelimitedList(20, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(17); if (token === 51) { @@ -8698,18 +8964,18 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(130); + var parameter = createNode(131); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(240, type.pos); + var result = createNode(242, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(239); + var result = createNode(241); result.name = parseSimplePropertyName(); while (parseOptional(20)) { if (token === 24) { @@ -8724,7 +8990,7 @@ var ts; } function parseTypeArguments() { nextToken(); - var typeArguments = parseDelimitedList(22, parseJSDocType); + var typeArguments = parseDelimitedList(21, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); parseExpected(25); @@ -8738,21 +9004,21 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(127, left.pos); + var result = createNode(128, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(237); + var result = createNode(239); nextToken(); - result.members = parseDelimitedList(23, parseJSDocRecordMember); + result.members = parseDelimitedList(22, parseJSDocRecordMember); checkForTrailingComma(result.members); parseExpected(15); return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(238); + var result = createNode(240); result.name = parseSimplePropertyName(); if (token === 51) { nextToken(); @@ -8761,15 +9027,15 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(236); + var result = createNode(238); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(234); + var result = createNode(236); nextToken(); - result.types = parseDelimitedList(24, parseJSDocType); + result.types = parseDelimitedList(23, parseJSDocType); checkForTrailingComma(result.types); parseExpected(19); return finishNode(result); @@ -8781,7 +9047,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(233); + var result = createNode(235); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(17); @@ -8799,7 +9065,7 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(230); + var result = createNode(232); nextToken(); return finishNode(result); } @@ -8812,11 +9078,11 @@ var ts; token === 25 || token === 53 || token === 44) { - var result = createNode(231, pos); + var result = createNode(233, pos); return finishNode(result); } else { - var result = createNode(235, pos); + var result = createNode(237, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -8887,7 +9153,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(245, start); + var result = createNode(247, start); result.tags = tags; return finishNode(result, end); } @@ -8925,7 +9191,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(246, atToken.pos); + var result = createNode(248, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -8977,7 +9243,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(247, atToken.pos); + var result = createNode(249, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -8987,27 +9253,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 248; })) { + if (ts.forEach(tags, function (t) { return t.kind === 250; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(248, atToken.pos); + var result = createNode(250, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 249; })) { + if (ts.forEach(tags, function (t) { return t.kind === 251; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(249, atToken.pos); + var result = createNode(251, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 250; })) { + if (ts.forEach(tags, function (t) { return t.kind === 252; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -9020,7 +9286,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(129, name_7.pos); + var typeParameter = createNode(130, name_7.pos); typeParameter.name = name_7; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -9031,7 +9297,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(250, atToken.pos); + var result = createNode(252, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -9426,8 +9692,8 @@ var ts; emptyGenericType.instantiations = {}; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var anySignature = createSignature(undefined, undefined, emptyArray, anyType, 0, false, false); - var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, false, false); + var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); + var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); var globals = {}; var globalESSymbolConstructorSymbol; var globalObjectType; @@ -9478,6 +9744,11 @@ var ts; flags: 2097152 } }; + var subtypeRelation = {}; + var assignableRelation = {}; + var identityRelation = {}; + initializeTypeChecker(); + return checker; function getEmitResolver(sourceFile) { getDiagnostics(sourceFile); return emitResolver; @@ -9617,10 +9888,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 228); + return ts.getAncestor(node, 230); } function isGlobalSourceFile(node) { - return node.kind === 228 && !ts.isExternalModule(node); + return node.kind === 230 && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -9668,34 +9939,37 @@ var ts; } } switch (location.kind) { - case 228: + case 230: if (!ts.isExternalModule(location)) break; - case 206: - if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8914931)) { - if (result.flags & meaning || !(result.flags & 8388608 && getDeclarationOfAliasSymbol(result).kind === 218)) { - break loop; + case 208: + var moduleExports = getSymbolOfNode(location).exports; + if (location.kind === 230 || + (location.kind === 208 && location.name.kind === 8)) { + if (ts.hasProperty(moduleExports, name) && + moduleExports[name].flags === 8388608 && + ts.getDeclarationOfKind(moduleExports[name], 220)) { + break; } - result = undefined; - } - else if (location.kind === 228 || - (location.kind === 206 && location.name.kind === 8)) { - result = getSymbolOfNode(location).exports["default"]; + result = moduleExports["default"]; var localSymbol = ts.getLocalSymbolForExportDefault(result); if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; } result = undefined; } + if (result = getSymbol(moduleExports, name, meaning & 8914931)) { + break loop; + } break; - case 205: + case 207: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 134: case 133: - case 132: - if (location.parent.kind === 202 && !(location.flags & 128)) { + if (location.parent.kind === 204 && !(location.flags & 128)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455)) { @@ -9704,8 +9978,8 @@ var ts; } } break; - case 202: - case 203: + case 204: + case 205: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { if (lastLocation && lastLocation.flags & 128) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -9714,28 +9988,28 @@ var ts; break loop; } break; - case 128: + case 129: grandparent = location.parent.parent; - if (grandparent.kind === 202 || grandparent.kind === 203) { + if (grandparent.kind === 204 || grandparent.kind === 205) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 135: - case 134: case 136: + case 135: case 137: case 138: - case 201: - case 164: + case 139: + case 203: + case 166: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 163: + case 165: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -9748,7 +10022,7 @@ var ts; } } break; - case 175: + case 177: if (meaning & 32) { var className = location.name; if (className && name === className.text) { @@ -9757,8 +10031,8 @@ var ts; } } break; - case 131: - if (location.parent && location.parent.kind === 130) { + case 132: + if (location.parent && location.parent.kind === 131) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -9796,14 +10070,14 @@ var ts; ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); if (!isUsedBeforeDeclaration) { - var variableDeclaration = ts.getAncestor(declaration, 199); + var variableDeclaration = ts.getAncestor(declaration, 201); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 181 || - variableDeclaration.parent.parent.kind === 187) { + if (variableDeclaration.parent.parent.kind === 183 || + variableDeclaration.parent.parent.kind === 189) { isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 189 || - variableDeclaration.parent.parent.kind === 188) { + else if (variableDeclaration.parent.parent.kind === 191 || + variableDeclaration.parent.parent.kind === 190) { var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); } @@ -9825,10 +10099,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 209) { + if (node.kind === 211) { return node; } - while (node && node.kind !== 210) { + while (node && node.kind !== 212) { node = node.parent; } return node; @@ -9838,7 +10112,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 220) { + if (node.moduleReference.kind === 222) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -9927,17 +10201,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 209: - return getTargetOfImportEqualsDeclaration(node); case 211: + return getTargetOfImportEqualsDeclaration(node); + case 213: return getTargetOfImportClause(node); - case 212: - return getTargetOfNamespaceImport(node); case 214: + return getTargetOfNamespaceImport(node); + case 216: return getTargetOfImportSpecifier(node); - case 218: + case 220: return getTargetOfExportSpecifier(node); - case 215: + case 217: return getTargetOfExportAssignment(node); } } @@ -9979,10 +10253,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 215) { + if (node.kind === 217) { checkExpressionCached(node.expression); } - else if (node.kind === 218) { + else if (node.kind === 220) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -9992,17 +10266,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 209); + importDeclaration = ts.getAncestor(entityName, 211); ts.Debug.assert(importDeclaration !== undefined); } if (entityName.kind === 65 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 65 || entityName.parent.kind === 127) { + if (entityName.kind === 65 || entityName.parent.kind === 128) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 209); + ts.Debug.assert(entityName.parent.kind === 211); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -10021,9 +10295,9 @@ var ts; return undefined; } } - else if (name.kind === 127 || name.kind === 156) { - var left = name.kind === 127 ? name.left : name.expression; - var right = name.kind === 127 ? name.right : name.name; + else if (name.kind === 128 || name.kind === 158) { + var left = name.kind === 128 ? name.left : name.expression; + var right = name.kind === 128 ? name.right : name.name; var namespace = resolveEntityName(left, 1536); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -10168,7 +10442,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 136 && ts.nodeIsPresent(member.body)) { + if (member.kind === 137 && ts.nodeIsPresent(member.body)) { return member; } } @@ -10233,17 +10507,17 @@ var ts; } } switch (location_1.kind) { - case 228: + case 230: if (!ts.isExternalModule(location_1)) { break; } - case 206: + case 208: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 202: - case 203: + case 204: + case 205: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -10358,8 +10632,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 206 && declaration.name.kind === 8) || - (declaration.kind === 228 && ts.isExternalModule(declaration)); + return (declaration.kind === 208 && declaration.name.kind === 8) || + (declaration.kind === 230 && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -10391,11 +10665,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 145) { + if (entityName.parent.kind === 147) { meaning = 107455 | 1048576; } - else if (entityName.kind === 127 || entityName.kind === 156 || - entityName.parent.kind === 209) { + else if (entityName.kind === 128 || entityName.kind === 158 || + entityName.parent.kind === 211) { meaning = 1536; } else { @@ -10425,6 +10699,13 @@ var ts; ts.releaseStringWriter(writer); return result; } + function signatureToString(signature, enclosingDeclaration, flags) { + var writer = ts.getSingleLineStringWriter(); + getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); + var result = writer.string(); + ts.releaseStringWriter(writer); + return result; + } function typeToString(type, enclosingDeclaration, flags) { var writer = ts.getSingleLineStringWriter(); getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); @@ -10439,10 +10720,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 150) { + while (node.kind === 152) { node = node.parent; } - if (node.kind === 204) { + if (node.kind === 206) { return getSymbolOfNode(node); } } @@ -10649,7 +10930,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 228 || declaration.parent.kind === 207; + return declaration.parent.kind === 230 || declaration.parent.kind === 209; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -10723,7 +11004,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); writePunctuation(writer, 51); writeSpace(writer); - writeKeyword(writer, 122); + writeKeyword(writer, 123); writePunctuation(writer, 19); writePunctuation(writer, 51); writeSpace(writer); @@ -10736,7 +11017,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); writePunctuation(writer, 51); writeSpace(writer); - writeKeyword(writer, 120); + writeKeyword(writer, 121); writePunctuation(writer, 19); writePunctuation(writer, 51); writeSpace(writer); @@ -10779,7 +11060,7 @@ var ts; function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { var targetSymbol = getTargetSymbol(symbol); if (targetSymbol.flags & 32 || targetSymbol.flags & 64) { - buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterface(symbol), writer, enclosingDeclaraiton, flags); + buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); } } function buildTypeParameterDisplay(tp, writer, enclosingDeclaration, flags, symbolStack) { @@ -10881,12 +11162,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 206) { + if (node.kind === 208) { if (node.name.kind === 8) { return node; } } - else if (node.kind === 228) { + else if (node.kind === 230) { return ts.isExternalModule(node) ? node : undefined; } } @@ -10929,58 +11210,58 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 153: + case 155: return isDeclarationVisible(node.parent.parent); - case 199: + case 201: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 206: - case 202: - case 203: + case 208: case 204: - case 201: case 205: - case 209: + case 206: + case 203: + case 207: + case 211: var parent_4 = getDeclarationContainer(node); if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 209 && parent_4.kind !== 228 && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 211 && parent_4.kind !== 230 && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } return isDeclarationVisible(parent_4); - case 133: - case 132: - case 137: - case 138: - case 135: case 134: + case 133: + case 138: + case 139: + case 136: + case 135: if (node.flags & (32 | 64)) { return false; } - case 136: - case 140: - case 139: + case 137: case 141: - case 130: - case 207: - case 143: - case 144: - case 146: + case 140: case 142: - case 147: + case 131: + case 209: + case 145: + case 146: case 148: + case 144: case 149: case 150: + case 151: + case 152: return isDeclarationVisible(node.parent); - case 211: - case 212: + case 213: case 214: + case 216: return false; - case 129: - case 228: + case 130: + case 230: return true; - case 215: + case 217: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -10996,10 +11277,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 215) { + if (node.parent && node.parent.kind === 217) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 218) { + else if (node.parent.kind === 220) { exportSymbol = getTargetOfExportSpecifier(node.parent); } var result = []; @@ -11045,7 +11326,7 @@ var ts; } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); - return node.kind === 199 ? node.parent.parent.parent : node.parent; + return node.kind === 201 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); @@ -11071,7 +11352,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 151) { + if (pattern.kind === 153) { var name_9 = declaration.propertyName || declaration.name; type = getTypeOfPropertyOfType(parentType, name_9.text) || isNumericLiteralName(name_9.text) && getIndexTypeOfType(parentType, 1) || @@ -11108,10 +11389,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 188) { + if (declaration.parent.parent.kind === 190) { return anyType; } - if (declaration.parent.parent.kind === 189) { + if (declaration.parent.parent.kind === 191) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -11120,10 +11401,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 130) { + if (declaration.kind === 131) { var func = declaration.parent; - if (func.kind === 138 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 137); + if (func.kind === 139 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 138); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -11136,7 +11417,7 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 226) { + if (declaration.kind === 228) { return checkIdentifier(declaration.name); } return undefined; @@ -11165,7 +11446,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 176 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 178 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -11180,7 +11461,7 @@ var ts; return createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern) { - return pattern.kind === 151 + return pattern.kind === 153 ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -11190,7 +11471,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - return declaration.kind !== 225 ? getWidenedType(type) : type; + return declaration.kind !== 227 ? getWidenedType(type) : type; } if (ts.isBindingPattern(declaration.name)) { return getTypeFromBindingPattern(declaration.name); @@ -11198,7 +11479,7 @@ var ts; type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 130 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 131 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -11211,10 +11492,10 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 224) { + if (declaration.parent.kind === 226) { return links.type = anyType; } - if (declaration.kind === 215) { + if (declaration.kind === 217) { return links.type = checkExpression(declaration.expression); } if (!pushTypeResolution(symbol)) { @@ -11242,7 +11523,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 137) { + if (accessor.kind === 138) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -11258,8 +11539,8 @@ var ts; if (!pushTypeResolution(symbol)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 137); - var setter = ts.getDeclarationOfKind(symbol, 138); + var getter = ts.getDeclarationOfKind(symbol, 138); + var setter = ts.getDeclarationOfKind(symbol, 139); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -11285,7 +11566,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 137); + var getter_1 = ts.getDeclarationOfKind(symbol, 138); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -11374,9 +11655,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 202 || node.kind === 201 || - node.kind === 163 || node.kind === 135 || - node.kind === 164) { + if (node.kind === 204 || node.kind === 203 || + node.kind === 165 || node.kind === 136 || + node.kind === 166) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -11385,14 +11666,14 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var kind = symbol.flags & 32 ? 202 : 203; + var kind = symbol.flags & 32 ? 204 : 205; return appendOuterTypeParameters(undefined, ts.getDeclarationOfKind(symbol, kind)); } - function getLocalTypeParametersOfClassOrInterface(symbol) { + function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 203 || node.kind === 202) { + if (node.kind === 205 || node.kind === 204 || node.kind === 206) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -11402,56 +11683,109 @@ var ts; return result; } function getTypeParametersOfClassOrInterface(symbol) { - return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterface(symbol)); + return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); + } + function isConstructorType(type) { + return type.flags & 48128 && getSignaturesOfType(type, 1).length > 0; + } + function getBaseTypeNodeOfClass(type) { + return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); + } + function getConstructorsForTypeArguments(type, typeArgumentNodes) { + var typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; + return ts.filter(getSignaturesOfType(type, 1), function (sig) { return (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount; }); + } + function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { + var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); + if (typeArgumentNodes) { + var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); + signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments); }); + } + return signatures; + } + function getBaseConstructorTypeOfClass(type) { + if (!type.resolvedBaseConstructorType) { + var baseTypeNode = getBaseTypeNodeOfClass(type); + if (!baseTypeNode) { + return type.resolvedBaseConstructorType = undefinedType; + } + if (!pushTypeResolution(type)) { + return unknownType; + } + var baseConstructorType = checkExpression(baseTypeNode.expression); + if (baseConstructorType.flags & 48128) { + resolveObjectOrUnionTypeMembers(baseConstructorType); + } + if (!popTypeResolution()) { + error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); + return type.resolvedBaseConstructorType = unknownType; + } + if (baseConstructorType !== unknownType && baseConstructorType !== nullType && !isConstructorType(baseConstructorType)) { + error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); + return type.resolvedBaseConstructorType = unknownType; + } + type.resolvedBaseConstructorType = baseConstructorType; + } + return type.resolvedBaseConstructorType; } function getBaseTypes(type) { - var typeWithBaseTypes = type; - if (!typeWithBaseTypes.baseTypes) { + if (!type.resolvedBaseTypes) { if (type.symbol.flags & 32) { - resolveBaseTypesOfClass(typeWithBaseTypes); + resolveBaseTypesOfClass(type); } else if (type.symbol.flags & 64) { - resolveBaseTypesOfInterface(typeWithBaseTypes); + resolveBaseTypesOfInterface(type); } else { ts.Debug.fail("type must be class or interface"); } } - return typeWithBaseTypes.baseTypes; + return type.resolvedBaseTypes; } function resolveBaseTypesOfClass(type) { - type.baseTypes = []; - var declaration = ts.getDeclarationOfKind(type.symbol, 202); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(declaration); - if (baseTypeNode) { - var baseType = getTypeFromTypeNode(baseTypeNode); - if (baseType !== unknownType) { - if (getTargetType(baseType).flags & 1024) { - if (type !== baseType && !hasBaseType(baseType, type)) { - type.baseTypes.push(baseType); - } - else { - error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1)); - } - } - else { - error(baseTypeNode, ts.Diagnostics.A_class_may_only_extend_another_class); - } - } + type.resolvedBaseTypes = emptyArray; + var baseContructorType = getBaseConstructorTypeOfClass(type); + if (!(baseContructorType.flags & 48128)) { + return; } + var baseTypeNode = getBaseTypeNodeOfClass(type); + var baseType; + if (baseContructorType.symbol && baseContructorType.symbol.flags & 32) { + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseContructorType.symbol); + } + else { + var constructors = getInstantiatedConstructorsForTypeArguments(baseContructorType, baseTypeNode.typeArguments); + if (!constructors.length) { + error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); + return; + } + baseType = getReturnTypeOfSignature(constructors[0]); + } + if (baseType === unknownType) { + return; + } + if (!(getTargetType(baseType).flags & (1024 | 2048))) { + error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); + return; + } + if (type === baseType || hasBaseType(baseType, type)) { + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1)); + return; + } + type.resolvedBaseTypes = [baseType]; } function resolveBaseTypesOfInterface(type) { - type.baseTypes = []; + type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 203 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 205 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { if (getTargetType(baseType).flags & (1024 | 2048)) { if (type !== baseType && !hasBaseType(baseType, type)) { - type.baseTypes.push(baseType); + type.resolvedBaseTypes.push(baseType); } else { error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1)); @@ -11471,7 +11805,7 @@ var ts; var kind = symbol.flags & 32 ? 1024 : 2048; var type = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); - var localTypeParameters = getLocalTypeParametersOfClassOrInterface(symbol); + var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (outerTypeParameters || localTypeParameters) { type.flags |= 4096; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); @@ -11491,9 +11825,16 @@ var ts; if (!pushTypeResolution(links)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 204); + var declaration = ts.getDeclarationOfKind(symbol, 206); var type = getTypeFromTypeNode(declaration.type); - if (!popTypeResolution()) { + if (popTypeResolution()) { + links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + if (links.typeParameters) { + links.instantiations = {}; + links.instantiations[getTypeListId(links.typeParameters)] = type; + } + } + else { type = unknownType; error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } @@ -11515,7 +11856,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 129).constraint) { + if (!ts.getDeclarationOfKind(symbol, 130).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -11630,34 +11971,42 @@ var ts; }); setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } - function createSignature(declaration, typeParameters, parameters, resolvedReturnType, minArgumentCount, hasRestParameter, hasStringLiterals) { + function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); sig.declaration = declaration; sig.typeParameters = typeParameters; sig.parameters = parameters; sig.resolvedReturnType = resolvedReturnType; + sig.typePredicate = typePredicate; sig.minArgumentCount = minArgumentCount; sig.hasRestParameter = hasRestParameter; sig.hasStringLiterals = hasStringLiterals; return sig; } function cloneSignature(sig) { - return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); + return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); } function getDefaultConstructSignatures(classType) { - var baseTypes = getBaseTypes(classType); - if (baseTypes.length) { - var baseType = baseTypes[0]; - var baseSignatures = getSignaturesOfType(getTypeOfSymbol(baseType.symbol), 1); - return ts.map(baseSignatures, function (baseSignature) { - var signature = baseType.flags & 4096 ? - getSignatureInstantiation(baseSignature, baseType.typeArguments) : cloneSignature(baseSignature); - signature.typeParameters = classType.localTypeParameters; - signature.resolvedReturnType = classType; - return signature; - }); + if (!getBaseTypes(classType).length) { + return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)]; } - return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, 0, false, false)]; + var baseConstructorType = getBaseConstructorTypeOfClass(classType); + var baseSignatures = getSignaturesOfType(baseConstructorType, 1); + var baseTypeNode = getBaseTypeNodeOfClass(classType); + var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); + var typeArgCount = typeArguments ? typeArguments.length : 0; + var result = []; + for (var _i = 0; _i < baseSignatures.length; _i++) { + var baseSig = baseSignatures[_i]; + var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; + if (typeParamCount === typeArgCount) { + var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + sig.typeParameters = classType.localTypeParameters; + sig.resolvedReturnType = classType; + result.push(sig); + } + } + return result; } function createTupleTypeMemberSymbols(memberTypes) { var members = {}; @@ -11756,10 +12105,10 @@ var ts; if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); } - var baseTypes = getBaseTypes(classType); - if (baseTypes.length) { + var baseConstructorType = getBaseConstructorTypeOfClass(classType); + if (baseConstructorType.flags & 48128) { members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(getTypeOfSymbol(baseTypes[0].symbol))); + addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); } } stringIndexType = undefined; @@ -11965,7 +12314,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 136 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 137 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -11987,22 +12336,31 @@ var ts; minArgumentCount = declaration.parameters.length; } var returnType; + var typePredicate; if (classType) { returnType = classType; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); + if (declaration.type.kind === 143) { + var typePredicateNode = declaration.type; + typePredicate = { + parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, + parameterIndex: typePredicateNode.parameterName ? getTypePredicateParameterIndex(declaration.parameters, typePredicateNode.parameterName) : undefined, + type: getTypeFromTypeNode(typePredicateNode.type) + }; + } } else { - if (declaration.kind === 137 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 138); + if (declaration.kind === 138 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 139); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { returnType = anyType; } } - links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); + links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); } return links.resolvedSignature; } @@ -12013,19 +12371,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 143: - case 144: - case 201: - case 135: - case 134: + case 145: + case 146: + case 203: case 136: - case 139: + case 135: + case 137: case 140: case 141: - case 137: + case 142: case 138: - case 163: - case 164: + case 139: + case 165: + case 166: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -12095,7 +12453,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 136 || signature.declaration.kind === 140; + var isConstructor = signature.declaration.kind === 137 || signature.declaration.kind === 141; var type = createObjectType(32768 | 131072); type.members = emptySymbols; type.properties = emptyArray; @@ -12109,7 +12467,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 120 : 122; + var syntaxKind = kind === 1 ? 121 : 123; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { var len = indexSymbol.declarations.length; @@ -12139,13 +12497,13 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 129).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 130).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 129).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 130).parent); } function getTypeListId(types) { switch (types.length) { @@ -12192,18 +12550,18 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 129; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 130; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 142 && n.typeName.kind === 65) { + if (n.kind === 144 && n.typeName.kind === 65) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); if (symbol && (symbol.flags & 262144)) { - links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent == typeParameter.parent; }); + links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent === typeParameter.parent; }); } } if (links.isIllegalTypeReferenceInConstraint) { @@ -12217,55 +12575,71 @@ var ts; check(typeParameter.constraint); } } - function getTypeFromTypeReferenceOrExpressionWithTypeArguments(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - var type; - if (node.kind !== 177 || ts.isSupportedExpressionWithTypeArguments(node)) { - var typeNameOrExpression = node.kind === 142 - ? node.typeName - : node.expression; - var symbol = resolveEntityName(typeNameOrExpression, 793056); - if (symbol) { - if ((symbol.flags & 262144) && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { - type = unknownType; - } - else { - type = createTypeReferenceIfGeneric(getDeclaredTypeOfSymbol(symbol), node, node.typeArguments); - } - } + function getTypeFromClassOrInterfaceReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var typeParameters = type.localTypeParameters; + if (typeParameters) { + if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1), typeParameters.length); + return unknownType; } - links.resolvedType = type || unknownType; + return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); } - return links.resolvedType; - } - function createTypeReferenceIfGeneric(type, node, typeArguments) { - if (type.flags & (1024 | 2048) && type.flags & 4096) { - var localTypeParameters = type.localTypeParameters; - var expectedTypeArgCount = localTypeParameters ? localTypeParameters.length : 0; - var typeArgCount = typeArguments ? typeArguments.length : 0; - if (typeArgCount === expectedTypeArgCount) { - if (typeArgCount) { - return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(typeArguments, getTypeFromTypeNode))); - } - } - else { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1), expectedTypeArgCount); - return undefined; - } - } - else { - if (typeArguments) { - error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); - return undefined; - } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); + return unknownType; } return type; } + function getTypeFromTypeAliasReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var links = getSymbolLinks(symbol); + var typeParameters = links.typeParameters; + if (typeParameters) { + if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); + return unknownType; + } + var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); + var id = getTypeListId(typeArguments); + return links.instantiations[id] || (links.instantiations[id] = instantiateType(type, createTypeMapper(typeParameters, typeArguments))); + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); + return unknownType; + } + return type; + } + function getTypeFromNonGenericTypeReference(node, symbol) { + if (symbol.flags & 262144 && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { + return unknownType; + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); + return unknownType; + } + return getDeclaredTypeOfSymbol(symbol); + } + function getTypeFromTypeReference(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + var typeNameOrExpression = node.kind === 144 ? node.typeName : + ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : + undefined; + var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; + var type = symbol === unknownSymbol ? unknownType : + symbol.flags & (32 | 64) ? getTypeFromClassOrInterfaceReference(node, symbol) : + symbol.flags & 524288 ? getTypeFromTypeAliasReference(node, symbol) : + getTypeFromNonGenericTypeReference(node, symbol); + links.resolvedSymbol = symbol; + links.resolvedType = type; + } + return links.resolvedType; + } function getTypeFromTypeQueryNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getWidenedType(checkExpressionOrQualifiedName(node.exprName)); + links.resolvedType = getWidenedType(checkExpression(node.exprName)); } return links.resolvedType; } @@ -12275,9 +12649,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 202: - case 203: + case 204: case 205: + case 207: return declaration; } } @@ -12478,38 +12852,40 @@ var ts; switch (node.kind) { case 112: return anyType; - case 122: + case 123: return stringType; - case 120: + case 121: return numberType; case 113: return booleanType; - case 123: + case 124: return esSymbolType; case 99: return voidType; case 8: return getTypeFromStringLiteral(node); - case 142: - return getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); - case 177: - return getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); - case 145: - return getTypeFromTypeQueryNode(node); - case 147: - return getTypeFromArrayTypeNode(node); - case 148: - return getTypeFromTupleTypeNode(node); - case 149: - return getTypeFromUnionTypeNode(node); - case 150: - return getTypeFromTypeNode(node.type); - case 143: case 144: + return getTypeFromTypeReference(node); + case 143: + return booleanType; + case 179: + return getTypeFromTypeReference(node); + case 147: + return getTypeFromTypeQueryNode(node); + case 149: + return getTypeFromArrayTypeNode(node); + case 150: + return getTypeFromTupleTypeNode(node); + case 151: + return getTypeFromUnionTypeNode(node); + case 152: + return getTypeFromTypeNode(node.type); + case 145: case 146: + case 148: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 65: - case 127: + case 128: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -12599,11 +12975,19 @@ var ts; } function instantiateSignature(signature, mapper, eraseTypeParameters) { var freshTypeParameters; + var freshTypePredicate; if (signature.typeParameters && !eraseTypeParameters) { freshTypeParameters = instantiateList(signature.typeParameters, mapper, instantiateTypeParameter); mapper = combineTypeMappers(createTypeMapper(signature.typeParameters, freshTypeParameters), mapper); } - var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + if (signature.typePredicate) { + freshTypePredicate = { + parameterName: signature.typePredicate.parameterName, + parameterIndex: signature.typePredicate.parameterIndex, + type: instantiateType(signature.typePredicate.type, mapper) + }; + } + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -12660,27 +13044,27 @@ var ts; return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 135 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 163: - case 164: + case 165: + case 166: return isContextSensitiveFunctionLikeDeclaration(node); - case 155: + case 157: return ts.forEach(node.properties, isContextSensitive); - case 154: + case 156: return ts.forEach(node.elements, isContextSensitive); - case 171: + case 173: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 170: + case 172: return node.operatorToken.kind === 49 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 225: + case 227: return isContextSensitive(node.initializer); + case 136: case 135: - case 134: return isContextSensitiveFunctionLikeDeclaration(node); - case 162: + case 164: return isContextSensitive(node.expression); } return false; @@ -12688,23 +13072,20 @@ var ts; function isContextSensitiveFunctionLikeDeclaration(node) { return !node.typeParameters && node.parameters.length && !ts.forEach(node.parameters, function (p) { return p.type; }); } - function getTypeWithoutConstructors(type) { + function getTypeWithoutSignatures(type) { if (type.flags & 48128) { var resolved = resolveObjectOrUnionTypeMembers(type); if (resolved.constructSignatures.length) { var result = createObjectType(32768, type.symbol); result.members = resolved.members; result.properties = resolved.properties; - result.callSignatures = resolved.callSignatures; + result.callSignatures = emptyArray; result.constructSignatures = emptyArray; type = result; } } return type; } - var subtypeRelation = {}; - var assignableRelation = {}; - var identityRelation = {}; function isTypeIdenticalTo(source, target) { return checkTypeRelatedTo(source, target, identityRelation, undefined); } @@ -12955,9 +13336,9 @@ var ts; maybeStack[depth][id] = 1; depth++; var saveExpandingFlags = expandingFlags; - if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack)) + if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) expandingFlags |= 1; - if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack)) + if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth)) expandingFlags |= 2; var result; if (expandingFlags === 3) { @@ -12990,21 +13371,6 @@ var ts; } return result; } - function isDeeplyNestedGeneric(type, stack) { - if (type.flags & (4096 | 65536) && depth >= 10) { - var symbol = type.symbol; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (t.flags & (4096 | 65536) && t.symbol === symbol) { - count++; - if (count >= 10) - return true; - } - } - } - return false; - } function propertiesRelatedTo(source, target, reportErrors) { if (relation === identityRelation) { return propertiesIdenticalTo(source, target); @@ -13175,6 +13541,33 @@ var ts; } result &= related; } + if (source.typePredicate && target.typePredicate) { + var hasDifferentParameterIndex = source.typePredicate.parameterIndex !== target.typePredicate.parameterIndex; + var hasDifferentTypes; + if (hasDifferentParameterIndex || + (hasDifferentTypes = !isTypeIdenticalTo(source.typePredicate.type, target.typePredicate.type))) { + if (reportErrors) { + var sourceParamText = source.typePredicate.parameterName; + var targetParamText = target.typePredicate.parameterName; + var sourceTypeText = typeToString(source.typePredicate.type); + var targetTypeText = typeToString(target.typePredicate.type); + if (hasDifferentParameterIndex) { + reportError(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceParamText, targetParamText); + } + else if (hasDifferentTypes) { + reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceTypeText, targetTypeText); + } + reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, sourceParamText + " is " + sourceTypeText, targetParamText + " is " + targetTypeText); + } + return 0; + } + } + else if (!source.typePredicate && target.typePredicate) { + if (reportErrors) { + reportError(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); + } + return 0; + } var t = getReturnTypeOfSignature(target); if (t === voidType) return result; @@ -13264,6 +13657,21 @@ var ts; return 0; } } + function isDeeplyNestedGeneric(type, stack, depth) { + if (type.flags & (4096 | 65536) && depth >= 5) { + var symbol = type.symbol; + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (t.flags & (4096 | 65536) && t.symbol === symbol) { + count++; + if (count >= 5) + return true; + } + } + } + return false; + } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypes) !== 0; } @@ -13454,22 +13862,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 134: case 133: - case 132: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 130: + case 131: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 201: + case 203: + case 136: case 135: - case 134: - case 137: case 138: - case 163: - case 164: + case 139: + case 165: + case 166: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -13541,20 +13949,6 @@ var ts; } return false; } - function isWithinDepthLimit(type, stack) { - if (depth >= 5) { - var target_1 = type.target; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (t.flags & 4096 && t.target === target_1) { - count++; - } - } - return count < 5; - } - return true; - } function inferFromTypes(source, target) { if (source === anyFunctionType) { return; @@ -13612,22 +14006,26 @@ var ts; } else if (source.flags & 48128 && (target.flags & (4096 | 8192) || (target.flags & 32768) && target.symbol && target.symbol.flags & (8192 | 2048))) { - if (!isInProcess(source, target) && isWithinDepthLimit(source, sourceStack) && isWithinDepthLimit(target, targetStack)) { - if (depth === 0) { - sourceStack = []; - targetStack = []; - } - sourceStack[depth] = source; - targetStack[depth] = target; - depth++; - inferFromProperties(source, target); - inferFromSignatures(source, target, 0); - inferFromSignatures(source, target, 1); - inferFromIndexTypes(source, target, 0, 0); - inferFromIndexTypes(source, target, 1, 1); - inferFromIndexTypes(source, target, 0, 1); - depth--; + if (isInProcess(source, target)) { + return; } + if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { + return; + } + if (depth === 0) { + sourceStack = []; + targetStack = []; + } + sourceStack[depth] = source; + targetStack[depth] = target; + depth++; + inferFromProperties(source, target); + inferFromSignatures(source, target, 0); + inferFromSignatures(source, target, 1); + inferFromIndexTypes(source, target, 0, 0); + inferFromIndexTypes(source, target, 1, 1); + inferFromIndexTypes(source, target, 0, 1); + depth--; } } function inferFromProperties(source, target) { @@ -13652,7 +14050,14 @@ var ts; } function inferFromSignature(source, target) { forEachMatchingParameterType(source, target, inferFromTypes); - inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + if (source.typePredicate && target.typePredicate) { + if (target.typePredicate.parameterIndex === source.typePredicate.parameterIndex) { + inferFromTypes(source.typePredicate.type, target.typePredicate.type); + } + } + else { + inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + } } function inferFromIndexTypes(source, target, sourceKind, targetKind) { var targetIndexType = getIndexTypeOfType(target, targetKind); @@ -13712,10 +14117,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 145: + case 147: return true; case 65: - case 127: + case 128: node = node.parent; continue; default: @@ -13757,7 +14162,7 @@ var ts; function isAssignedInBinaryExpression(node) { if (node.operatorToken.kind >= 53 && node.operatorToken.kind <= 64) { var n = node.left; - while (n.kind === 162) { + while (n.kind === 164) { n = n.expression; } if (n.kind === 65 && getResolvedSymbol(n) === symbol) { @@ -13774,46 +14179,46 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 170: + case 172: return isAssignedInBinaryExpression(node); - case 199: - case 153: - return isAssignedInVariableDeclaration(node); - case 151: - case 152: - case 154: + case 201: case 155: + return isAssignedInVariableDeclaration(node); + case 153: + case 154: case 156: case 157: case 158: case 159: + case 160: case 161: - case 162: - case 168: - case 165: - case 166: + case 163: + case 164: + case 170: case 167: + case 168: case 169: case 171: - case 174: - case 180: - case 181: + case 173: + case 176: + case 182: case 183: - case 184: case 185: case 186: case 187: case 188: case 189: - case 192: - case 193: + case 190: + case 191: case 194: - case 221: - case 222: case 195: case 196: - case 197: + case 223: case 224: + case 197: + case 198: + case 199: + case 226: return ts.forEachChild(node, isAssignedIn); } return false; @@ -13850,17 +14255,17 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 184: + case 186: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 171: + case 173: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 170: + case 172: if (child === node.right) { if (node.operatorToken.kind === 48) { narrowedType = narrowType(type, node.left, true); @@ -13870,14 +14275,14 @@ var ts; } } break; - case 228: - case 206: - case 201: - case 135: - case 134: - case 137: - case 138: + case 230: + case 208: + case 203: case 136: + case 135: + case 138: + case 139: + case 137: break loop; } if (narrowedType !== type) { @@ -13891,7 +14296,7 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 166 || expr.right.kind !== 8) { + if (expr.left.kind !== 168 || expr.right.kind !== 8) { return type; } var left = expr.left; @@ -13970,20 +14375,44 @@ var ts; } } if (targetType) { - if (isTypeSubtypeOf(targetType, type)) { - return targetType; - } - if (type.flags & 16384) { - return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); })); + return getNarrowedType(type, targetType); + } + return type; + } + function getNarrowedType(originalType, narrowedTypeCandidate) { + if (isTypeSubtypeOf(narrowedTypeCandidate, originalType)) { + return narrowedTypeCandidate; + } + if (originalType.flags & 16384) { + return getUnionType(ts.filter(originalType.types, function (t) { return isTypeSubtypeOf(t, narrowedTypeCandidate); })); + } + return originalType; + } + function narrowTypeByTypePredicate(type, expr, assumeTrue) { + if (type.flags & 1) { + return type; + } + var signature = getResolvedSignature(expr); + if (signature.typePredicate && + expr.arguments[signature.typePredicate.parameterIndex] && + getSymbolAtLocation(expr.arguments[signature.typePredicate.parameterIndex]) === symbol) { + if (!assumeTrue) { + if (type.flags & 16384) { + return getUnionType(ts.filter(type.types, function (t) { return !isTypeSubtypeOf(t, signature.typePredicate.type); })); + } + return type; } + return getNarrowedType(type, signature.typePredicate.type); } return type; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 162: + case 160: + return narrowTypeByTypePredicate(type, expr, assumeTrue); + case 164: return narrowType(type, expr.expression, assumeTrue); - case 170: + case 172: var operator = expr.operatorToken.kind; if (operator === 30 || operator === 31) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -13998,7 +14427,7 @@ var ts; return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 168: + case 170: if (expr.operator === 46) { return narrowType(type, expr.operand, !assumeTrue); } @@ -14009,7 +14438,7 @@ var ts; } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); - if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 164 && languageVersion < 2) { + if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 166 && languageVersion < 2) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } if (symbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { @@ -14033,15 +14462,15 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 224) { + symbol.valueDeclaration.parent.kind === 226) { return; } var container = symbol.valueDeclaration; - while (container.kind !== 200) { + while (container.kind !== 202) { container = container.parent; } container = container.parent; - if (container.kind === 181) { + if (container.kind === 183) { container = container.parent; } var inFunction = isInsideFunction(node.parent, container); @@ -14058,9 +14487,9 @@ var ts; } } function captureLexicalThis(node, container) { - var classNode = container.parent && container.parent.kind === 202 ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 204 ? container.parent : undefined; getNodeLinks(node).flags |= 2; - if (container.kind === 133 || container.kind === 136) { + if (container.kind === 134 || container.kind === 137) { getNodeLinks(classNode).flags |= 4; } else { @@ -14070,36 +14499,36 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 164) { + if (container.kind === 166) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 206: + case 208: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 205: + case 207: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 136: + case 137: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 134: case 133: - case 132: if (container.flags & 128) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 128: + case 129: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } if (needToCaptureLexicalThis) { captureLexicalThis(node, container); } - var classNode = container.parent && container.parent.kind === 202 ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 204 ? container.parent : undefined; if (classNode) { var symbol = getSymbolOfNode(classNode); return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); @@ -14108,23 +14537,21 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 130) { + if (n.kind === 131) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 158 && node.parent.expression === node; - var enclosingClass = ts.getAncestor(node, 202); - var baseClass; - if (enclosingClass && ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); - var baseTypes = getBaseTypes(classType); - baseClass = baseTypes.length && baseTypes[0]; - } - if (!baseClass) { - error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); + var isCallExpression = node.parent.kind === 160 && node.parent.expression === node; + var classDeclaration = ts.getAncestor(node, 204); + var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); + var baseClassType = classType && getBaseTypes(classType)[0]; + if (!baseClassType) { + if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { + error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); + } return unknownType; } var container = ts.getSuperContainer(node, true); @@ -14132,31 +14559,31 @@ var ts; var canUseSuperExpression = false; var needToCaptureLexicalThis; if (isCallExpression) { - canUseSuperExpression = container.kind === 136; + canUseSuperExpression = container.kind === 137; } else { needToCaptureLexicalThis = false; - while (container && container.kind === 164) { + while (container && container.kind === 166) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } - if (container && container.parent && container.parent.kind === 202) { + if (container && container.parent && container.parent.kind === 204) { if (container.flags & 128) { canUseSuperExpression = - container.kind === 135 || - container.kind === 134 || - container.kind === 137 || - container.kind === 138; + container.kind === 136 || + container.kind === 135 || + container.kind === 138 || + container.kind === 139; } else { canUseSuperExpression = - container.kind === 135 || - container.kind === 134 || - container.kind === 137 || + container.kind === 136 || + container.kind === 135 || container.kind === 138 || + container.kind === 139 || + container.kind === 134 || container.kind === 133 || - container.kind === 132 || - container.kind === 136; + container.kind === 137; } } } @@ -14164,13 +14591,13 @@ var ts; var returnType; if ((container.flags & 128) || isCallExpression) { getNodeLinks(node).flags |= 32; - returnType = getTypeOfSymbol(baseClass.symbol); + returnType = getBaseConstructorTypeOfClass(classType); } else { getNodeLinks(node).flags |= 16; - returnType = baseClass; + returnType = baseClassType; } - if (container.kind === 136 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 137 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); returnType = unknownType; } @@ -14180,7 +14607,7 @@ var ts; return returnType; } } - if (container && container.kind === 128) { + if (container && container.kind === 129) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -14218,7 +14645,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 130) { + if (declaration.kind === 131) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -14251,8 +14678,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 136 || - functionDecl.kind === 137 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 138))) { + functionDecl.kind === 137 || + functionDecl.kind === 138 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 139))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -14271,7 +14698,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 160) { + if (template.parent.kind === 162) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -14379,34 +14806,34 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 199: - case 130: + case 201: + case 131: + case 134: case 133: - case 132: - case 153: + case 155: return getContextualTypeForInitializerExpression(node); - case 164: - case 192: + case 166: + case 194: return getContextualTypeForReturnExpression(node); - case 173: + case 175: return getContextualTypeForYieldOperand(parent); - case 158: - case 159: - return getContextualTypeForArgument(parent, node); + case 160: case 161: + return getContextualTypeForArgument(parent, node); + case 163: return getTypeFromTypeNode(parent.type); - case 170: + case 172: return getContextualTypeForBinaryOperand(node); - case 225: + case 227: return getContextualTypeForObjectLiteralElement(parent); - case 154: + case 156: return getContextualTypeForElementExpression(node); - case 171: + case 173: return getContextualTypeForConditionalOperand(node); - case 178: - ts.Debug.assert(parent.parent.kind === 172); + case 180: + ts.Debug.assert(parent.parent.kind === 174); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 162: + case 164: return getContextualType(parent); } return undefined; @@ -14421,7 +14848,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 163 || node.kind === 164; + return node.kind === 165 || node.kind === 166; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -14429,7 +14856,7 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 135 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -14473,13 +14900,13 @@ var ts; } function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 170 && parent.operatorToken.kind === 53 && parent.left === node) { + if (parent.kind === 172 && parent.operatorToken.kind === 53 && parent.left === node) { return true; } - if (parent.kind === 225) { + if (parent.kind === 227) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 154) { + if (parent.kind === 156) { return isAssignmentTarget(parent); } return false; @@ -14498,7 +14925,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 174) { + if (inDestructuringPattern && e.kind === 176) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -14510,7 +14937,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 174; + hasSpreadElement = hasSpreadElement || e.kind === 176; } if (!hasSpreadElement) { var contextualType = getContextualType(node); @@ -14521,7 +14948,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 128 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 129 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); @@ -14554,18 +14981,18 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 225 || - memberDecl.kind === 226 || + if (memberDecl.kind === 227 || + memberDecl.kind === 228 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 225) { + if (memberDecl.kind === 227) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 135) { + else if (memberDecl.kind === 136) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 226); + ts.Debug.assert(memberDecl.kind === 228); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -14580,7 +15007,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 137 || memberDecl.kind === 138); + ts.Debug.assert(memberDecl.kind === 138 || memberDecl.kind === 139); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -14613,7 +15040,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 133; + return s.valueDeclaration ? s.valueDeclaration.kind : 134; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; @@ -14623,7 +15050,7 @@ var ts; if (!(flags & (32 | 64))) { return; } - var enclosingClassDeclaration = ts.getAncestor(node, 202); + var enclosingClassDeclaration = ts.getAncestor(node, 204); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; var declaringClass = getDeclaredTypeOfSymbol(prop.parent); if (flags & 32) { @@ -14653,7 +15080,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { - var type = checkExpressionOrQualifiedName(left); + var type = checkExpression(left); if (isTypeAny(type)) { return type; } @@ -14670,7 +15097,7 @@ var ts; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32) { - if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 135) { + if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 136) { error(right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); } else { @@ -14680,14 +15107,14 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 156 + var left = node.kind === 158 ? node.expression : node.left; - var type = checkExpressionOrQualifiedName(left); + var type = checkExpression(left); if (type !== unknownType && !isTypeAny(type)) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32) { - if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 135) { + if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 136) { return false; } else { @@ -14702,7 +15129,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 159 && node.parent.expression === node) { + if (node.parent.kind === 161 && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -14798,7 +15225,7 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 160) { + if (node.kind === 162) { checkExpression(node.template); } else { @@ -14851,7 +15278,7 @@ var ts; } function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { - if (args[i].kind === 174) { + if (args[i].kind === 176) { return i; } } @@ -14861,11 +15288,11 @@ var ts; var adjustedArgCount; var typeArguments; var callIsIncomplete; - if (node.kind === 160) { + if (node.kind === 162) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 172) { + if (tagExpression.template.kind === 174) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -14880,7 +15307,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 159); + ts.Debug.assert(callExpression.kind === 161); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -14932,10 +15359,10 @@ var ts; } for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg.kind !== 176) { + if (arg.kind !== 178) { var paramType = getTypeAtPosition(signature, i); var argType = void 0; - if (i === 0 && args[i].parent.kind === 160) { + if (i === 0 && args[i].parent.kind === 162) { argType = globalTemplateStringsArrayType; } else { @@ -14975,9 +15402,9 @@ var ts; function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg.kind !== 176) { + if (arg.kind !== 178) { var paramType = getTypeAtPosition(signature, i); - var argType = i === 0 && node.kind === 160 + var argType = i === 0 && node.kind === 162 ? globalTemplateStringsArrayType : arg.kind === 8 && !reportErrors ? getStringLiteralType(arg) @@ -14991,10 +15418,10 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 160) { + if (node.kind === 162) { var template = node.template; args = [template]; - if (template.kind === 172) { + if (template.kind === 174) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); @@ -15005,21 +15432,11 @@ var ts; } return args; } - function getEffectiveTypeArguments(callExpression) { - if (callExpression.expression.kind === 91) { - var containingClass = ts.getAncestor(callExpression, 202); - var baseClassTypeNode = containingClass && ts.getClassExtendsHeritageClauseElement(containingClass); - return baseClassTypeNode && baseClassTypeNode.typeArguments; - } - else { - return callExpression.typeArguments; - } - } function resolveCall(node, signatures, candidatesOutArray) { - var isTaggedTemplate = node.kind === 160; + var isTaggedTemplate = node.kind === 162; var typeArguments; if (!isTaggedTemplate) { - typeArguments = getEffectiveTypeArguments(node); + typeArguments = node.typeArguments; if (node.expression.kind !== 91) { ts.forEach(typeArguments, checkSourceElement); } @@ -15060,8 +15477,8 @@ var ts; checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); } else if (candidateForTypeArgumentError) { - if (!isTaggedTemplate && node.typeArguments) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], true); + if (!isTaggedTemplate && typeArguments) { + checkTypeArguments(candidateForTypeArgumentError, typeArguments, [], true); } else { ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); @@ -15145,7 +15562,9 @@ var ts; if (node.expression.kind === 91) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { - return resolveCall(node, getSignaturesOfType(superType, 1), candidatesOutArray); + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getAncestor(node, 204)); + var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + return resolveCall(node, baseConstructors, candidatesOutArray); } return resolveUntypedCall(node); } @@ -15226,13 +15645,13 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 158) { + if (node.kind === 160) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 159) { + else if (node.kind === 161) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 160) { + else if (node.kind === 162) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } else { @@ -15247,12 +15666,12 @@ var ts; if (node.expression.kind === 91) { return voidType; } - if (node.kind === 159) { + if (node.kind === 161) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 136 && - declaration.kind !== 140 && - declaration.kind !== 144) { + declaration.kind !== 137 && + declaration.kind !== 141 && + declaration.kind !== 146) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } @@ -15299,7 +15718,7 @@ var ts; return unknownType; } var type; - if (func.body.kind !== 180) { + if (func.body.kind !== 182) { type = checkExpressionCached(func.body, contextualMapper); } else { @@ -15376,7 +15795,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 196); + return (body.statements.length === 1) && (body.statements[0].kind === 198); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!produceDiagnostics) { @@ -15385,7 +15804,7 @@ var ts; if (returnType === voidType || isTypeAny(returnType)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 180) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 182) { return; } var bodyBlock = func.body; @@ -15398,10 +15817,10 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 135 || ts.isObjectLiteralMethod(node)); - var hasGrammarError = checkGrammarDeclarationNameInStrictMode(node) || checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 163) { - checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node); + ts.Debug.assert(node.kind !== 136 || ts.isObjectLiteralMethod(node)); + var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); + if (!hasGrammarError && node.kind === 165) { + checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { return anyFunctionType; @@ -15427,14 +15846,14 @@ var ts; checkSignatureDeclaration(node); } } - if (produceDiagnostics && node.kind !== 135 && node.kind !== 134) { + if (produceDiagnostics && node.kind !== 136 && node.kind !== 135) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 135 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 || ts.isObjectLiteralMethod(node)); if (node.type && !node.asteriskToken) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); } @@ -15442,7 +15861,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 180) { + if (node.body.kind === 182) { checkSourceElement(node.body); } else { @@ -15472,13 +15891,13 @@ var ts; var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 156: { + case 158: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; } - case 157: + case 159: return true; - case 162: + case 164: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -15487,11 +15906,11 @@ var ts; function isConstVariableReference(n) { switch (n.kind) { case 65: - case 156: { + case 158: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 8192) !== 0; } - case 157: { + case 159: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 8) { @@ -15501,7 +15920,7 @@ var ts; } return false; } - case 162: + case 164: return isConstVariableReference(n.expression); default: return false; @@ -15518,10 +15937,7 @@ var ts; return true; } function checkDeleteExpression(node) { - if (node.parserContextFlags & 1 && node.expression.kind === 65) { - grammarErrorOnNode(node.expression, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); - } - var operandType = checkExpression(node.expression); + checkExpression(node.expression); return booleanType; } function checkTypeOfExpression(node) { @@ -15533,9 +15949,6 @@ var ts; return undefinedType; } function checkPrefixUnaryExpression(node) { - if ((node.operator === 38 || node.operator === 39)) { - checkGrammarEvalOrArgumentsInStrictMode(node, node.operand); - } var operandType = checkExpression(node.operand); switch (node.operator) { case 33: @@ -15558,7 +15971,6 @@ var ts; return unknownType; } function checkPostfixUnaryExpression(node) { - checkGrammarEvalOrArgumentsInStrictMode(node, node.operand); var operandType = checkExpression(node.operand); var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { @@ -15626,7 +16038,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 225 || p.kind === 226) { + if (p.kind === 227 || p.kind === 228) { var name_12 = p.name; var type = isTypeAny(sourceType) ? sourceType @@ -15651,8 +16063,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 176) { - if (e.kind !== 174) { + if (e.kind !== 178) { + if (e.kind !== 176) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -15677,7 +16089,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 170 && restExpression.operatorToken.kind === 53) { + if (restExpression.kind === 172 && restExpression.operatorToken.kind === 53) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -15690,14 +16102,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 170 && target.operatorToken.kind === 53) { + if (target.kind === 172 && target.operatorToken.kind === 53) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 155) { + if (target.kind === 157) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 154) { + if (target.kind === 156) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -15710,11 +16122,8 @@ var ts; return sourceType; } function checkBinaryExpression(node, contextualMapper) { - if (ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) { - checkGrammarEvalOrArgumentsInStrictMode(node, node.left); - } var operator = node.operatorToken.kind; - if (operator === 53 && (node.left.kind === 155 || node.left.kind === 154)) { + if (operator === 53 && (node.left.kind === 157 || node.left.kind === 156)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); @@ -15860,7 +16269,7 @@ var ts; if (ts.isFunctionLike(parent) && current === parent.body) { return false; } - else if (current.kind === 202 || current.kind === 175) { + else if (current.kind === 204 || current.kind === 177) { return true; } current = parent; @@ -15921,14 +16330,14 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 128) { + if (node.name.kind === 129) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 128) { + if (node.name.kind === 129) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -15950,12 +16359,8 @@ var ts; return type; } function checkExpression(node, contextualMapper) { - checkGrammarIdentifierInStrictMode(node); - return checkExpressionOrQualifiedName(node, contextualMapper); - } - function checkExpressionOrQualifiedName(node, contextualMapper) { var type; - if (node.kind == 127) { + if (node.kind === 128) { type = checkQualifiedName(node); } else { @@ -15963,9 +16368,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 156 && node.parent.expression === node) || - (node.parent.kind === 157 && node.parent.expression === node) || - ((node.kind === 65 || node.kind === 127) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 158 && node.parent.expression === node) || + (node.parent.kind === 159 && node.parent.expression === node) || + ((node.kind === 65 || node.kind === 128) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -15991,60 +16396,59 @@ var ts; return booleanType; case 7: return checkNumericLiteral(node); - case 172: + case 174: return checkTemplateExpression(node); case 8: case 10: return stringType; case 9: return globalRegExpType; - case 154: - return checkArrayLiteral(node, contextualMapper); - case 155: - return checkObjectLiteral(node, contextualMapper); case 156: - return checkPropertyAccessExpression(node); + return checkArrayLiteral(node, contextualMapper); case 157: - return checkIndexedAccess(node); + return checkObjectLiteral(node, contextualMapper); case 158: + return checkPropertyAccessExpression(node); case 159: - return checkCallExpression(node); + return checkIndexedAccess(node); case 160: - return checkTaggedTemplateExpression(node); case 161: - return checkTypeAssertion(node); + return checkCallExpression(node); case 162: - return checkExpression(node.expression, contextualMapper); - case 175: - return checkClassExpression(node); + return checkTaggedTemplateExpression(node); case 163: + return checkTypeAssertion(node); case 164: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 166: - return checkTypeOfExpression(node); + return checkExpression(node.expression, contextualMapper); + case 177: + return checkClassExpression(node); case 165: - return checkDeleteExpression(node); - case 167: - return checkVoidExpression(node); + case 166: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case 168: - return checkPrefixUnaryExpression(node); + return checkTypeOfExpression(node); + case 167: + return checkDeleteExpression(node); case 169: - return checkPostfixUnaryExpression(node); + return checkVoidExpression(node); case 170: - return checkBinaryExpression(node, contextualMapper); + return checkPrefixUnaryExpression(node); case 171: - return checkConditionalExpression(node, contextualMapper); - case 174: - return checkSpreadElementExpression(node, contextualMapper); - case 176: - return undefinedType; + return checkPostfixUnaryExpression(node); + case 172: + return checkBinaryExpression(node, contextualMapper); case 173: + return checkConditionalExpression(node, contextualMapper); + case 176: + return checkSpreadElementExpression(node, contextualMapper); + case 178: + return undefinedType; + case 175: return checkYieldExpression(node); } return unknownType; } function checkTypeParameter(node) { - checkGrammarDeclarationNameInStrictMode(node); if (node.expression) { grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); } @@ -16059,14 +16463,12 @@ var ts; // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the // Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code // or if its FunctionBody is strict code(11.1.5). - // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a - // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEvalOrArgumentsInStrictMode(node, node.name); + checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (node.flags & 112) { func = ts.getContainingFunction(node); - if (!(func.kind === 136 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 137 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -16081,32 +16483,106 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 135 || - node.kind === 201 || - node.kind === 163; + return node.kind === 136 || + node.kind === 203 || + node.kind === 165; + } + function getTypePredicateParameterIndex(parameterList, parameter) { + if (parameterList) { + for (var i = 0; i < parameterList.length; i++) { + var param = parameterList[i]; + if (param.name.kind === 65 && + param.name.text === parameter.text) { + return i; + } + } + } + return -1; + } + function isInLegalTypePredicatePosition(node) { + switch (node.parent.kind) { + case 166: + case 140: + case 203: + case 165: + case 145: + case 136: + case 135: + return node === node.parent.type; + } + return false; } function checkSignatureDeclaration(node) { - if (node.kind === 141) { + if (node.kind === 142) { checkGrammarIndexSignature(node); } - else if (node.kind === 143 || node.kind === 201 || node.kind === 144 || - node.kind === 139 || node.kind === 136 || - node.kind === 140) { + else if (node.kind === 145 || node.kind === 203 || node.kind === 146 || + node.kind === 140 || node.kind === 137 || + node.kind === 141) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - checkSourceElement(node.type); + if (node.type.kind === 143) { + var typePredicate = getSignatureFromDeclaration(node).typePredicate; + var typePredicateNode = node.type; + if (isInLegalTypePredicatePosition(typePredicateNode)) { + if (typePredicate.parameterIndex >= 0) { + if (node.parameters[typePredicate.parameterIndex].dotDotDotToken) { + error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); + } + else { + checkTypeAssignableTo(typePredicate.type, getTypeAtLocation(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); + } + } + else if (typePredicateNode.parameterName) { + var hasReportedError = false; + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var param = _a[_i]; + if (hasReportedError) { + break; + } + if (param.name.kind === 153 || + param.name.kind === 154) { + (function checkBindingPattern(pattern) { + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.name.kind === 65 && + element.name.text === typePredicate.parameterName) { + error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); + hasReportedError = true; + break; + } + else if (element.name.kind === 154 || + element.name.kind === 153) { + checkBindingPattern(element.name); + } + } + })(param.name); + } + } + if (!hasReportedError) { + error(typePredicateNode.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName); + } + } + } + else { + error(typePredicateNode, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + } + } + else { + checkSourceElement(node.type); + } } if (produceDiagnostics) { checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 140: + case 141: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 139: + case 140: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -16128,7 +16604,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 203) { + if (node.kind === 205) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -16143,7 +16619,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 122: + case 123: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -16151,7 +16627,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 120: + case 121: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -16188,17 +16664,17 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 158 && n.expression.kind === 91; + return n.kind === 160 && n.expression.kind === 91; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 163: - case 201: - case 164: - case 155: return false; + case 165: + case 203: + case 166: + case 157: return false; default: return ts.forEachChild(n, containsSuperCall); } } @@ -16206,12 +16682,12 @@ var ts; if (n.kind === 93) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 163 && n.kind !== 201) { + else if (n.kind !== 165 && n.kind !== 203) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 133 && + return n.kind === 134 && !(n.flags & 128) && !!n.initializer; } @@ -16221,7 +16697,7 @@ var ts; ts.forEach(node.parameters, function (p) { return p.flags & (16 | 32 | 64); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 183 || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 185 || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -16237,13 +16713,13 @@ var ts; function checkAccessorDeclaration(node) { if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 137) { + if (node.kind === 138) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 137 ? 138 : 137; + var otherKind = node.kind === 138 ? 139 : 138; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112) !== (otherAccessor.flags & 112))) { @@ -16265,26 +16741,26 @@ var ts; function checkMissingDeclaration(node) { checkDecorators(node); } + function checkTypeArgumentConstraints(typeParameters, typeArguments) { + var result = true; + for (var i = 0; i < typeParameters.length; i++) { + var constraint = getConstraintOfTypeParameter(typeParameters[i]); + if (constraint) { + var typeArgument = typeArguments[i]; + result = result && checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, typeArgument, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + } + } + return result; + } function checkTypeReferenceNode(node) { - checkGrammarTypeReferenceInStrictMode(node.typeName); - return checkTypeReferenceOrExpressionWithTypeArguments(node); - } - function checkExpressionWithTypeArguments(node) { - checkGrammarExpressionWithTypeArgumentsInStrictMode(node.expression); - return checkTypeReferenceOrExpressionWithTypeArguments(node); - } - function checkTypeReferenceOrExpressionWithTypeArguments(node) { checkGrammarTypeArguments(node, node.typeArguments); - var type = getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); + var type = getTypeFromTypeReference(node); if (type !== unknownType && node.typeArguments) { - var len = node.typeArguments.length; - for (var i = 0; i < len; i++) { - checkSourceElement(node.typeArguments[i]); - var constraint = getConstraintOfTypeParameter(type.target.typeParameters[i]); - if (produceDiagnostics && constraint) { - var typeArgument = type.typeArguments[i]; - checkTypeAssignableTo(typeArgument, constraint, node, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); - } + ts.forEach(node.typeArguments, checkSourceElement); + if (produceDiagnostics) { + var symbol = getNodeLinks(node).resolvedSymbol; + var typeParameters = symbol.flags & 524288 ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; + checkTypeArgumentConstraints(typeParameters, node.typeArguments); } } } @@ -16328,9 +16804,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 203) { - ts.Debug.assert(signatureDeclarationNode.kind === 139 || signatureDeclarationNode.kind === 140); - var signatureKind = signatureDeclarationNode.kind === 139 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 205) { + ts.Debug.assert(signatureDeclarationNode.kind === 140 || signatureDeclarationNode.kind === 141); + var signatureKind = signatureDeclarationNode.kind === 140 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -16348,7 +16824,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 203 && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 205 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; } @@ -16421,7 +16897,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - ts.Debug.assert(node.kind === 135 || node.kind === 134); + ts.Debug.assert(node.kind === 136 || node.kind === 135); ts.Debug.assert((node.flags & 128) !== (subsequentNode.flags & 128)); var diagnostic = node.flags & 128 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -16448,11 +16924,11 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 203 || node.parent.kind === 146 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 205 || node.parent.kind === 148 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 201 || node.kind === 135 || node.kind === 134 || node.kind === 136) { + if (node.kind === 203 || node.kind === 136 || node.kind === 135 || node.kind === 137) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -16549,16 +17025,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 203: + case 205: return 2097152; - case 206: + case 208: return d.name.kind === 8 || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 202: - case 205: + case 204: + case 207: return 2097152 | 1048576; - case 209: + case 211: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -16572,54 +17048,54 @@ var ts; var expression = node.expression; var exprType = checkExpression(expression); switch (node.parent.kind) { - case 202: + case 204: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); var classDecoratorType = instantiateSingleCallFunctionType(getGlobalClassDecoratorType(), [classConstructorType]); checkTypeAssignableTo(exprType, classDecoratorType, node); break; - case 133: + case 134: checkTypeAssignableTo(exprType, getGlobalPropertyDecoratorType(), node); break; - case 135: - case 137: + case 136: case 138: + case 139: var methodType = getTypeOfNode(node.parent); var methodDecoratorType = instantiateSingleCallFunctionType(getGlobalMethodDecoratorType(), [methodType]); checkTypeAssignableTo(exprType, methodDecoratorType, node); break; - case 130: + case 131: checkTypeAssignableTo(exprType, getGlobalParameterDecoratorType(), node); break; } } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 142) { + if (node && node.kind === 144) { var type = getTypeFromTypeNode(node); var shouldCheckIfUnknownType = type === unknownType && compilerOptions.isolatedModules; if (!type || (!shouldCheckIfUnknownType && type.flags & (2097279 | 132 | 258))) { return; } if (shouldCheckIfUnknownType || type.symbol.valueDeclaration) { - checkExpressionOrQualifiedName(node.typeName); + checkExpression(node.typeName); } } } function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 133: + case 134: checkTypeNodeAsExpression(node.type); break; - case 130: + case 131: checkTypeNodeAsExpression(node.type); break; - case 135: - checkTypeNodeAsExpression(node.type); - break; - case 137: + case 136: checkTypeNodeAsExpression(node.type); break; case 138: + checkTypeNodeAsExpression(node.type); + break; + case 139: checkTypeNodeAsExpression(getSetAccessorTypeAnnotationNode(node)); break; } @@ -16642,43 +17118,40 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 202: + case 204: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 135: + case 136: checkParameterTypeAnnotationsAsExpressions(node); + case 139: case 138: - case 137: - case 133: - case 130: + case 134: + case 131: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 130) { + if (node.kind === 131) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); } function checkFunctionDeclaration(node) { if (produceDiagnostics) { - checkFunctionLikeDeclaration(node) || - checkGrammarFunctionName(node.name) || - checkGrammarForGenerator(node); + checkFunctionLikeDeclaration(node) || checkGrammarForGenerator(node); checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); } } function checkFunctionLikeDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSignatureDeclaration(node); - if (node.name && node.name.kind === 128) { + if (node.name && node.name.kind === 129) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -16708,11 +17181,11 @@ var ts; } } function checkBlock(node) { - if (node.kind === 180) { + if (node.kind === 182) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 207) { + if (ts.isFunctionBlock(node) || node.kind === 209) { checkFunctionExpressionBodies(node); } } @@ -16730,19 +17203,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 133 || - node.kind === 132 || + if (node.kind === 134 || + node.kind === 133 || + node.kind === 136 || node.kind === 135 || - node.kind === 134 || - node.kind === 137 || - node.kind === 138) { + node.kind === 138 || + node.kind === 139) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 130 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 131 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -16772,7 +17245,7 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; } - var enclosingClass = ts.getAncestor(node, 202); + var enclosingClass = ts.getAncestor(node, 204); if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { return; } @@ -16790,11 +17263,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 206 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 208 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 228 && ts.isExternalModule(parent)) { + if (parent.kind === 230 && ts.isExternalModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -16805,7 +17278,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 12288) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 199 && !node.initializer) { + if (node.kind === 201 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -16815,15 +17288,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 12288) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 200); - var container = varDeclList.parent.kind === 181 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 202); + var container = varDeclList.parent.kind === 183 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 180 && ts.isFunctionLike(container.parent) || - container.kind === 207 || - container.kind === 206 || - container.kind === 228); + (container.kind === 182 && ts.isFunctionLike(container.parent) || + container.kind === 209 || + container.kind === 208 || + container.kind === 230); if (!namesShareScope) { var name_13 = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_13, name_13); @@ -16833,7 +17306,7 @@ var ts; } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 130) { + if (ts.getRootDeclaration(node).kind !== 131) { return; } var func = ts.getContainingFunction(node); @@ -16842,7 +17315,7 @@ var ts; if (n.kind === 65) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 130) { + if (referencedSymbol.valueDeclaration.kind === 131) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -16860,10 +17333,9 @@ var ts; } } function checkVariableLikeDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 128) { + if (node.name.kind === 129) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -16872,7 +17344,7 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 130 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 131 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -16900,9 +17372,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 133 && node.kind !== 132) { + if (node.kind !== 134 && node.kind !== 133) { checkExportsOnMergedDeclarations(node); - if (node.kind === 199 || node.kind === 153) { + if (node.kind === 201 || node.kind === 155) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -16931,7 +17403,7 @@ var ts; } function inBlockOrObjectLiteralExpression(node) { while (node) { - if (node.kind === 180 || node.kind === 155) { + if (node.kind === 182 || node.kind === 157) { return true; } node = node.parent; @@ -16959,12 +17431,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind == 200) { + if (node.initializer && node.initializer.kind === 202) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 200) { + if (node.initializer.kind === 202) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -16979,13 +17451,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 200) { + if (node.initializer.kind === 202) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 154 || varExpr.kind === 155) { + if (varExpr.kind === 156 || varExpr.kind === 157) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -17000,7 +17472,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 200) { + if (node.initializer.kind === 202) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -17010,7 +17482,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 154 || varExpr.kind === 155) { + if (varExpr.kind === 156 || varExpr.kind === 157) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { @@ -17172,7 +17644,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 137 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 138))); + return !!(node.kind === 138 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 139))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -17184,31 +17656,28 @@ var ts; if (node.expression) { var func = ts.getContainingFunction(node); if (func) { - var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); + var signature = getSignatureFromDeclaration(func); + var returnType = getReturnTypeOfSignature(signature); var exprType = checkExpressionCached(node.expression); if (func.asteriskToken) { return; } - if (func.kind === 138) { + if (func.kind === 139) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 136) { + else if (func.kind === 137) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } - else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func)) { + else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { checkTypeAssignableTo(exprType, returnType, node.expression, undefined); } } } } function checkWithStatement(node) { - if (!checkGrammarStatementInAmbientContext(node)) { - if (node.parserContextFlags & 1) { - grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); - } - } + checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); } @@ -17218,7 +17687,7 @@ var ts; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 222 && !hasDuplicateDefaultClause) { + if (clause.kind === 224 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -17230,7 +17699,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 221) { + if (produceDiagnostics && clause.kind === 223) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { @@ -17247,7 +17716,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 195 && current.label.text === node.label.text) { + if (current.kind === 197 && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -17291,7 +17760,6 @@ var ts; grammarErrorOnNode(localSymbol.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); } } - checkGrammarEvalOrArgumentsInStrictMode(node, catchClause.variableDeclaration.name); } } checkBlock(catchClause.block); @@ -17311,7 +17779,7 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1); }); - if (type.flags & 1024 && type.symbol.valueDeclaration.kind === 202) { + if (type.flags & 1024 && type.symbol.valueDeclaration.kind === 204) { var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -17342,7 +17810,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 128 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 129 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -17392,7 +17860,6 @@ var ts; return unknownType; } function checkClassDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node); if (!node.name && !(node.flags & 256)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } @@ -17410,35 +17877,38 @@ var ts; var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - if (!ts.isSupportedExpressionWithTypeArguments(baseTypeNode)) { - error(baseTypeNode.expression, ts.Diagnostics.Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses); - } emitExtends = emitExtends || !ts.isInAmbientContext(node); - checkExpressionWithTypeArguments(baseTypeNode); - } - var baseTypes = getBaseTypes(type); - if (baseTypes.length) { - if (produceDiagnostics) { + var baseTypes = getBaseTypes(type); + if (baseTypes.length && produceDiagnostics) { var baseType = baseTypes[0]; + var staticBaseType = getBaseConstructorTypeOfClass(type); + if (baseTypeNode.typeArguments) { + ts.forEach(baseTypeNode.typeArguments, checkSourceElement); + for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { + var constructor = _a[_i]; + if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { + break; + } + } + } checkTypeAssignableTo(type, baseType, node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); - var staticBaseType = getTypeOfSymbol(baseType.symbol); - checkTypeAssignableTo(staticType, getTypeWithoutConstructors(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseType.symbol !== resolveEntityName(baseTypeNode.expression, 107455)) { - error(baseTypeNode, ts.Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType)); + checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32)) { + var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); + if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType; })) { + error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); + } } checkKindsOfPropertyMemberOverrides(type, baseType); } } - if (baseTypes.length || (baseTypeNode && compilerOptions.isolatedModules)) { - checkExpressionOrQualifiedName(baseTypeNode.expression); - } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { ts.forEach(implementedTypeNodes, function (typeRefNode) { if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } - checkExpressionWithTypeArguments(typeRefNode); + checkTypeReferenceNode(typeRefNode); if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { @@ -17520,7 +17990,7 @@ var ts; } } function isAccessor(kind) { - return kind === 137 || kind === 138; + return kind === 138 || kind === 139; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -17580,13 +18050,13 @@ var ts; return ok; } function checkInterfaceDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); checkTypeParameters(node.typeParameters); if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 203); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 205); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -17606,7 +18076,7 @@ var ts; if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) { error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments); } - checkExpressionWithTypeArguments(heritageElement); + checkTypeReferenceNode(heritageElement); }); ts.forEach(node.members, checkSourceElement); if (produceDiagnostics) { @@ -17627,7 +18097,7 @@ var ts; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 128 && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 129 && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; @@ -17663,7 +18133,7 @@ var ts; return evalConstant(initializer); function evalConstant(e) { switch (e.kind) { - case 168: + case 170: var value = evalConstant(e.operand); if (value === undefined) { return undefined; @@ -17674,7 +18144,7 @@ var ts; case 47: return ~value; } return undefined; - case 170: + case 172: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -17699,11 +18169,11 @@ var ts; return undefined; case 7: return +e.text; - case 162: + case 164: return evalConstant(e.expression); case 65: - case 157: - case 156: + case 159: + case 158: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType; @@ -17714,7 +18184,7 @@ var ts; } else { var expression; - if (e.kind === 157) { + if (e.kind === 159) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 8) { return undefined; @@ -17731,7 +18201,7 @@ var ts; if (current.kind === 65) { break; } - else if (current.kind === 156) { + else if (current.kind === 158) { current = current.expression; } else { @@ -17766,7 +18236,7 @@ var ts; if (!produceDiagnostics) { return; } - checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -17788,7 +18258,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 205) { + if (declaration.kind !== 207) { return false; } var enumDeclaration = declaration; @@ -17811,8 +18281,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 202 || - (declaration.kind === 201 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 204 || + (declaration.kind === 203 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -17834,7 +18304,14 @@ var ts; } function checkModuleDeclaration(node) { if (produceDiagnostics) { - if (!checkGrammarDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { + var isAmbientExternalModule = node.name.kind === 8; + var contextErrorMessage = isAmbientExternalModule + ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file + : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; + if (checkGrammarModuleElementContext(node, contextErrorMessage)) { + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { if (!ts.isInAmbientContext(node) && node.name.kind === 8) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } @@ -17856,13 +18333,13 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 202); + var mergedClass = ts.getDeclarationOfKind(symbol, 204); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 2048; } } - if (node.name.kind === 8) { + if (isAmbientExternalModule) { if (!isGlobalSourceFile(node.parent)) { error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules); } @@ -17875,10 +18352,10 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 127) { + if (node.kind === 128) { node = node.left; } - else if (node.kind === 156) { + else if (node.kind === 158) { node = node.expression; } else { @@ -17894,9 +18371,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 207 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 228 && !inAmbientExternalModule) { - error(moduleName, node.kind === 216 ? + var inAmbientExternalModule = node.parent.kind === 209 && node.parent.parent.name.kind === 8; + if (node.parent.kind !== 230 && !inAmbientExternalModule) { + error(moduleName, node.kind === 218 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -17915,7 +18392,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 218 ? + var message = node.kind === 220 ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -17928,7 +18405,10 @@ var ts; checkAliasSymbol(node); } function checkImportDeclaration(node) { - if (!checkGrammarImportDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -17938,7 +18418,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 212) { + if (importClause.namedBindings.kind === 214) { checkImportBinding(importClause.namedBindings); } else { @@ -17949,7 +18429,10 @@ var ts; } } function checkImportEqualsDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node); + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { + return; + } + checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); if (node.flags & 1) { @@ -17977,14 +18460,17 @@ var ts; } } function checkExportDeclaration(node) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { + return; + } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 207 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 228 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 209 && node.parent.parent.name.kind === 8; + if (node.parent.kind !== 230 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -17996,6 +18482,11 @@ var ts; } } } + function checkGrammarModuleElementContext(node, errorMessage) { + if (node.parent.kind !== 230 && node.parent.kind !== 209 && node.parent.kind !== 208) { + return grammarErrorOnFirstToken(node, errorMessage); + } + } function checkExportSpecifier(node) { checkAliasSymbol(node); if (!node.parent.parent.moduleSpecifier) { @@ -18003,8 +18494,11 @@ var ts; } } function checkExportAssignment(node) { - var container = node.parent.kind === 228 ? node.parent : node.parent.parent; - if (container.kind === 206 && container.name.kind === 65) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { + return; + } + var container = node.parent.kind === 230 ? node.parent : node.parent.parent; + if (container.kind === 208 && container.name.kind === 65) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -18028,10 +18522,10 @@ var ts; } } function getModuleStatements(node) { - if (node.kind === 228) { + if (node.kind === 230) { return node.statements; } - if (node.kind === 206 && node.body.kind === 207) { + if (node.kind === 208 && node.body.kind === 209) { return node.body.statements; } return emptyArray; @@ -18056,170 +18550,175 @@ var ts; links.exportsChecked = true; } } + function checkTypePredicate(node) { + if (!isInLegalTypePredicatePosition(node)) { + error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + } + } function checkSourceElement(node) { if (!node) return; switch (node.kind) { - case 129: - return checkTypeParameter(node); case 130: + return checkTypeParameter(node); + case 131: return checkParameter(node); + case 134: case 133: - case 132: return checkPropertyDeclaration(node); - case 143: - case 144: - case 139: + case 145: + case 146: case 140: - return checkSignatureDeclaration(node); case 141: return checkSignatureDeclaration(node); - case 135: - case 134: - return checkMethodDeclaration(node); - case 136: - return checkConstructorDeclaration(node); - case 137: - case 138: - return checkAccessorDeclaration(node); case 142: + return checkSignatureDeclaration(node); + case 136: + case 135: + return checkMethodDeclaration(node); + case 137: + return checkConstructorDeclaration(node); + case 138: + case 139: + return checkAccessorDeclaration(node); + case 144: return checkTypeReferenceNode(node); - case 145: - return checkTypeQuery(node); - case 146: - return checkTypeLiteral(node); + case 143: + return checkTypePredicate(node); case 147: - return checkArrayType(node); + return checkTypeQuery(node); case 148: - return checkTupleType(node); + return checkTypeLiteral(node); case 149: - return checkUnionType(node); + return checkArrayType(node); case 150: + return checkTupleType(node); + case 151: + return checkUnionType(node); + case 152: return checkSourceElement(node.type); - case 201: - return checkFunctionDeclaration(node); - case 180: - case 207: - return checkBlock(node); - case 181: - return checkVariableStatement(node); - case 183: - return checkExpressionStatement(node); - case 184: - return checkIfStatement(node); - case 185: - return checkDoStatement(node); - case 186: - return checkWhileStatement(node); - case 187: - return checkForStatement(node); - case 188: - return checkForInStatement(node); - case 189: - return checkForOfStatement(node); - case 190: - case 191: - return checkBreakOrContinueStatement(node); - case 192: - return checkReturnStatement(node); - case 193: - return checkWithStatement(node); - case 194: - return checkSwitchStatement(node); - case 195: - return checkLabeledStatement(node); - case 196: - return checkThrowStatement(node); - case 197: - return checkTryStatement(node); - case 199: - return checkVariableDeclaration(node); - case 153: - return checkBindingElement(node); - case 202: - return checkClassDeclaration(node); case 203: - return checkInterfaceDeclaration(node); - case 204: - return checkTypeAliasDeclaration(node); - case 205: - return checkEnumDeclaration(node); - case 206: - return checkModuleDeclaration(node); - case 210: - return checkImportDeclaration(node); - case 209: - return checkImportEqualsDeclaration(node); - case 216: - return checkExportDeclaration(node); - case 215: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); case 182: - checkGrammarStatementInAmbientContext(node); - return; + case 209: + return checkBlock(node); + case 183: + return checkVariableStatement(node); + case 185: + return checkExpressionStatement(node); + case 186: + return checkIfStatement(node); + case 187: + return checkDoStatement(node); + case 188: + return checkWhileStatement(node); + case 189: + return checkForStatement(node); + case 190: + return checkForInStatement(node); + case 191: + return checkForOfStatement(node); + case 192: + case 193: + return checkBreakOrContinueStatement(node); + case 194: + return checkReturnStatement(node); + case 195: + return checkWithStatement(node); + case 196: + return checkSwitchStatement(node); + case 197: + return checkLabeledStatement(node); case 198: + return checkThrowStatement(node); + case 199: + return checkTryStatement(node); + case 201: + return checkVariableDeclaration(node); + case 155: + return checkBindingElement(node); + case 204: + return checkClassDeclaration(node); + case 205: + return checkInterfaceDeclaration(node); + case 206: + return checkTypeAliasDeclaration(node); + case 207: + return checkEnumDeclaration(node); + case 208: + return checkModuleDeclaration(node); + case 212: + return checkImportDeclaration(node); + case 211: + return checkImportEqualsDeclaration(node); + case 218: + return checkExportDeclaration(node); + case 217: + return checkExportAssignment(node); + case 184: checkGrammarStatementInAmbientContext(node); return; - case 219: + case 200: + checkGrammarStatementInAmbientContext(node); + return; + case 221: return checkMissingDeclaration(node); } } function checkFunctionExpressionBodies(node) { switch (node.kind) { - case 163: - case 164: + case 165: + case 166: ts.forEach(node.parameters, checkFunctionExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; + case 136: case 135: - case 134: ts.forEach(node.decorators, checkFunctionExpressionBodies); ts.forEach(node.parameters, checkFunctionExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 136: case 137: case 138: - case 201: + case 139: + case 203: ts.forEach(node.parameters, checkFunctionExpressionBodies); break; - case 193: + case 195: checkFunctionExpressionBodies(node.expression); break; - case 131: - case 130: - case 133: case 132: - case 151: - case 152: + case 131: + case 134: + case 133: case 153: case 154: case 155: - case 225: case 156: case 157: + case 227: case 158: case 159: case 160: - case 172: - case 178: case 161: case 162: - case 166: - case 167: - case 165: - case 168: - case 169: - case 170: - case 171: case 174: case 180: - case 207: - case 181: + case 163: + case 164: + case 168: + case 169: + case 167: + case 170: + case 171: + case 172: + case 173: + case 176: + case 182: + case 209: case 183: - case 184: case 185: case 186: case 187: @@ -18228,21 +18727,23 @@ var ts; case 190: case 191: case 192: + case 193: case 194: - case 208: - case 221: - case 222: - case 195: case 196: - case 197: + case 210: + case 223: case 224: + case 197: + case 198: case 199: - case 200: + case 226: + case 201: case 202: - case 205: - case 227: - case 215: - case 228: + case 204: + case 207: + case 229: + case 217: + case 230: ts.forEachChild(node, checkFunctionExpressionBodies); break; } @@ -18255,6 +18756,9 @@ var ts; function checkSourceFileWorker(node) { var links = getNodeLinks(node); if (!(links.flags & 1)) { + if (node.isDefaultLib && compilerOptions.skipDefaultLibCheck) { + return; + } checkGrammarSourceFile(node); emitExtends = false; emitDecorate = false; @@ -18302,7 +18806,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 193 && node.parent.statement === node) { + if (node.parent.kind === 195 && node.parent.statement === node) { return true; } node = node.parent; @@ -18324,23 +18828,23 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 228: + case 230: if (!ts.isExternalModule(location)) { break; } - case 206: + case 208: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 205: + case 207: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 202: - case 203: + case 204: + case 205: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 163: + case 165: if (location.name) { copySymbol(location.symbol, meaning); } @@ -18376,22 +18880,22 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 228: + case 230: if (!ts.isExternalModule(location)) break; - case 206: + case 208: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 205: + case 207: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 202: - case 203: + case 204: + case 205: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 163: + case 165: if (location.name) { copySymbol(location.symbol, meaning); } @@ -18404,42 +18908,42 @@ var ts; return symbolsToArray(symbols); } function isTypeDeclarationName(name) { - return name.kind == 65 && + return name.kind === 65 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 129: - case 202: - case 203: + case 130: case 204: case 205: + case 206: + case 207: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 127) { + while (node.parent && node.parent.kind === 128) { node = node.parent; } - return node.parent && node.parent.kind === 142; + return node.parent && node.parent.kind === 144; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 156) { + while (node.parent && node.parent.kind === 158) { node = node.parent; } - return node.parent && node.parent.kind === 177; + return node.parent && node.parent.kind === 179; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 127) { + while (nodeOnRightSide.parent.kind === 128) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 209) { + if (nodeOnRightSide.parent.kind === 211) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 215) { + if (nodeOnRightSide.parent.kind === 217) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -18451,10 +18955,10 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 215) { + if (entityName.parent.kind === 217) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 156) { + if (entityName.kind !== 158) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -18463,7 +18967,7 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 177 ? 793056 : 1536; + var meaning = entityName.parent.kind === 179 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } @@ -18475,14 +18979,14 @@ var ts; var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 156) { + else if (entityName.kind === 158) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 127) { + else if (entityName.kind === 128) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -18491,7 +18995,7 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 142 ? 793056 : 1536; + var meaning = entityName.parent.kind === 144 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } @@ -18505,14 +19009,14 @@ var ts; return getSymbolOfNode(node.parent); } if (node.kind === 65 && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 215 + return node.parent.kind === 217 ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } switch (node.kind) { case 65: - case 156: - case 127: + case 158: + case 128: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 93: case 91: @@ -18520,7 +19024,7 @@ var ts; return type.symbol; case 114: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 136) { + if (constructorDeclaration && constructorDeclaration.kind === 137) { return constructorDeclaration.parent.symbol; } return undefined; @@ -18528,12 +19032,12 @@ var ts; var moduleName; if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 210 || node.parent.kind === 216) && + ((node.parent.kind === 212 || node.parent.kind === 218) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } case 7: - if (node.parent.kind == 157 && node.parent.argumentExpression === node) { + if (node.parent.kind === 159 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -18547,7 +19051,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 226) { + if (location && location.kind === 228) { return resolveEntityName(location.name, 107455); } return undefined; @@ -18562,6 +19066,9 @@ var ts; if (ts.isExpression(node)) { return getTypeOfExpression(node); } + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(node)) { + return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; + } if (isTypeDeclaration(node)) { var symbol = getSymbolOfNode(node); return getDeclaredTypeOfSymbol(symbol); @@ -18620,81 +19127,81 @@ var ts; } return [symbol]; } - function isExternalModuleSymbol(symbol) { - return symbol.flags & 512 && symbol.declarations.length === 1 && symbol.declarations[0].kind === 228; - } - function getAliasNameSubstitution(symbol, getGeneratedNameForNode) { - if (languageVersion >= 2) { - return undefined; - } - var node = getDeclarationOfAliasSymbol(symbol); - if (node) { - if (node.kind === 211) { - var defaultKeyword; - if (languageVersion === 0) { - defaultKeyword = "[\"default\"]"; - } - else { - defaultKeyword = ".default"; - } - return getGeneratedNameForNode(node.parent) + defaultKeyword; - } - if (node.kind === 214) { - var moduleName = getGeneratedNameForNode(node.parent.parent.parent); - var propertyName = node.propertyName || node.name; - return moduleName + "." + ts.unescapeIdentifier(propertyName.text); - } - } - } - function getExportNameSubstitution(symbol, location, getGeneratedNameForNode) { - if (isExternalModuleSymbol(symbol.parent)) { - if (languageVersion >= 2 || compilerOptions.module === 4) { - return undefined; - } - return "exports." + ts.unescapeIdentifier(symbol.name); - } - var node = location; - var containerSymbol = getParentOfSymbol(symbol); - while (node) { - if ((node.kind === 206 || node.kind === 205) && getSymbolOfNode(node) === containerSymbol) { - return getGeneratedNameForNode(node) + "." + ts.unescapeIdentifier(symbol.name); - } - node = node.parent; - } - } - function getExpressionNameSubstitution(node, getGeneratedNameForNode) { - var symbol = getNodeLinks(node).resolvedSymbol || (ts.isDeclarationName(node) ? getSymbolOfNode(node.parent) : undefined); + function getReferencedExportContainer(node) { + var symbol = getReferencedValueSymbol(node); if (symbol) { - if (symbol.parent) { - return getExportNameSubstitution(symbol, node.parent, getGeneratedNameForNode); + if (symbol.flags & 1048576) { + var exportSymbol = getMergedSymbol(symbol.exportSymbol); + if (exportSymbol.flags & 944) { + return undefined; + } + symbol = exportSymbol; } - var exportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); - if (symbol !== exportSymbol && !(exportSymbol.flags & 944)) { - return getExportNameSubstitution(exportSymbol, node.parent, getGeneratedNameForNode); - } - if (symbol.flags & 8388608) { - return getAliasNameSubstitution(symbol, getGeneratedNameForNode); + var parentSymbol = getParentOfSymbol(symbol); + if (parentSymbol) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 230) { + return parentSymbol.valueDeclaration; + } + for (var n = node.parent; n; n = n.parent) { + if ((n.kind === 208 || n.kind === 207) && getSymbolOfNode(n) === parentSymbol) { + return n; + } + } } } } + function getReferencedImportDeclaration(node) { + var symbol = getReferencedValueSymbol(node); + return symbol && symbol.flags & 8388608 ? getDeclarationOfAliasSymbol(symbol) : undefined; + } + function isStatementWithLocals(node) { + switch (node.kind) { + case 182: + case 210: + case 189: + case 190: + case 191: + return true; + } + return false; + } + function isNestedRedeclarationSymbol(symbol) { + if (symbol.flags & 418) { + var links = getSymbolLinks(symbol); + if (links.isNestedRedeclaration === undefined) { + var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); + links.isNestedRedeclaration = isStatementWithLocals(container) && + !!resolveName(container.parent, symbol.name, 107455, undefined, undefined); + } + return links.isNestedRedeclaration; + } + return false; + } + function getReferencedNestedRedeclaration(node) { + var symbol = getReferencedValueSymbol(node); + return symbol && isNestedRedeclarationSymbol(symbol) ? symbol.valueDeclaration : undefined; + } + function isNestedRedeclaration(node) { + return isNestedRedeclarationSymbol(getSymbolOfNode(node)); + } function isValueAliasDeclaration(node) { switch (node.kind) { - case 209: case 211: - case 212: + case 213: case 214: - case 218: - return isAliasResolvedToValue(getSymbolOfNode(node)); case 216: + case 220: + return isAliasResolvedToValue(getSymbolOfNode(node)); + case 218: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 215: + case 217: return node.expression && node.expression.kind === 65 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 228 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 230 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -18739,7 +19246,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 227) { + if (node.kind === 229) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -18750,10 +19257,9 @@ var ts; } return undefined; } - function serializeEntityName(node, getGeneratedNameForNode, fallbackPath) { + function serializeEntityName(node, fallbackPath) { if (node.kind === 65) { - var substitution = getExpressionNameSubstitution(node, getGeneratedNameForNode); - var text = substitution || node.text; + var text = node.text; if (fallbackPath) { fallbackPath.push(text); } @@ -18762,14 +19268,14 @@ var ts; } } else { - var left = serializeEntityName(node.left, getGeneratedNameForNode, fallbackPath); - var right = serializeEntityName(node.right, getGeneratedNameForNode, fallbackPath); + var left = serializeEntityName(node.left, fallbackPath); + var right = serializeEntityName(node.right, fallbackPath); if (!fallbackPath) { return left + "." + right; } } } - function serializeTypeReferenceNode(node, getGeneratedNameForNode) { + function serializeTypeReferenceNode(node) { var type = getTypeFromTypeNode(node); if (type.flags & 16) { return "void 0"; @@ -18791,42 +19297,42 @@ var ts; } else if (type === unknownType) { var fallbackPath = []; - serializeEntityName(node.typeName, getGeneratedNameForNode, fallbackPath); + serializeEntityName(node.typeName, fallbackPath); return fallbackPath; } else if (type.symbol && type.symbol.valueDeclaration) { - return serializeEntityName(node.typeName, getGeneratedNameForNode); + return serializeEntityName(node.typeName); } else if (typeHasCallOrConstructSignatures(type)) { return "Function"; } return "Object"; } - function serializeTypeNode(node, getGeneratedNameForNode) { + function serializeTypeNode(node) { if (node) { switch (node.kind) { case 99: return "void 0"; - case 150: - return serializeTypeNode(node.type, getGeneratedNameForNode); - case 143: - case 144: + case 152: + return serializeTypeNode(node.type); + case 145: + case 146: return "Function"; - case 147: - case 148: + case 149: + case 150: return "Array"; case 113: return "Boolean"; - case 122: + case 123: case 8: return "String"; - case 120: + case 121: return "Number"; - case 142: - return serializeTypeReferenceNode(node, getGeneratedNameForNode); - case 145: - case 146: - case 149: + case 144: + return serializeTypeReferenceNode(node); + case 147: + case 148: + case 151: case 112: break; default: @@ -18836,23 +19342,23 @@ var ts; } return "Object"; } - function serializeTypeOfNode(node, getGeneratedNameForNode) { + function serializeTypeOfNode(node) { switch (node.kind) { - case 202: return "Function"; - case 133: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 130: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 137: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 138: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node), getGeneratedNameForNode); + case 204: return "Function"; + case 134: return serializeTypeNode(node.type); + case 131: return serializeTypeNode(node.type); + case 138: return serializeTypeNode(node.type); + case 139: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node)); } if (ts.isFunctionLike(node)) { return "Function"; } return "void 0"; } - function serializeParameterTypesOfNode(node, getGeneratedNameForNode) { + function serializeParameterTypesOfNode(node) { if (node) { var valueDeclaration; - if (node.kind === 202) { + if (node.kind === 204) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -18867,19 +19373,19 @@ var ts; for (var i = 0; i < parameterCount; i++) { if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 147) { + if (parameterType.kind === 149) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 142 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 144 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { parameterType = undefined; } - result[i] = serializeTypeNode(parameterType, getGeneratedNameForNode); + result[i] = serializeTypeNode(parameterType); } else { - result[i] = serializeTypeOfNode(parameters[i], getGeneratedNameForNode); + result[i] = serializeTypeOfNode(parameters[i]); } } return result; @@ -18888,9 +19394,9 @@ var ts; } return emptyArray; } - function serializeReturnTypeOfNode(node, getGeneratedNameForNode) { + function serializeReturnTypeOfNode(node) { if (node && ts.isFunctionLike(node)) { - return serializeTypeNode(node.type, getGeneratedNameForNode); + return serializeTypeNode(node.type); } return "void 0"; } @@ -18912,25 +19418,24 @@ var ts; function hasGlobalName(name) { return ts.hasProperty(globals, name); } - function resolvesToSomeValue(location, name) { - ts.Debug.assert(!ts.nodeIsSynthesized(location), "resolvesToSomeValue called with a synthesized location"); - return !!resolveName(location, name, 107455, undefined, undefined); + function getReferencedValueSymbol(reference) { + return getNodeLinks(reference).resolvedSymbol || + resolveName(reference, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); } function getReferencedValueDeclaration(reference) { ts.Debug.assert(!ts.nodeIsSynthesized(reference)); - var symbol = getNodeLinks(reference).resolvedSymbol || - resolveName(reference, reference.text, 107455 | 8388608, undefined, undefined); + var symbol = getReferencedValueSymbol(reference); return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 153 || (n.parent.kind === 199 && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 155 || (n.parent.kind === 201 && n.parent.name === n); var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, 107455 | 8388608, undefined, undefined); var isLetOrConst = symbol && (symbol.flags & 2) && - symbol.valueDeclaration.parent.kind !== 224; + symbol.valueDeclaration.parent.kind !== 226; if (isLetOrConst) { getSymbolLinks(symbol); return symbol.id; @@ -18950,7 +19455,10 @@ var ts; } function createResolver() { return { - getExpressionNameSubstitution: getExpressionNameSubstitution, + getReferencedExportContainer: getReferencedExportContainer, + getReferencedImportDeclaration: getReferencedImportDeclaration, + getReferencedNestedRedeclaration: getReferencedNestedRedeclaration, + isNestedRedeclaration: isNestedRedeclaration, isValueAliasDeclaration: isValueAliasDeclaration, hasGlobalName: hasGlobalName, isReferencedAliasDeclaration: isReferencedAliasDeclaration, @@ -18964,7 +19472,6 @@ var ts; isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, getConstantValue: getConstantValue, - resolvesToSomeValue: resolvesToSomeValue, collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, @@ -19015,105 +19522,6 @@ var ts; } anyArrayType = createArrayType(anyType); } - function isReservedWordInStrictMode(node) { - return (node.parserContextFlags & 1) && - (102 <= node.originalKeywordKind && node.originalKeywordKind <= 110); - } - function reportStrictModeGrammarErrorInClassDeclaration(identifier, message, arg0, arg1, arg2) { - if (ts.getAncestor(identifier, 202) || ts.getAncestor(identifier, 175)) { - return grammarErrorOnNode(identifier, message, arg0); - } - return false; - } - function checkGrammarImportDeclarationNameInStrictMode(node) { - if (node.importClause) { - var impotClause = node.importClause; - if (impotClause.namedBindings) { - var nameBindings = impotClause.namedBindings; - if (nameBindings.kind === 212) { - var name_15 = nameBindings.name; - if (isReservedWordInStrictMode(name_15)) { - var nameText = ts.declarationNameToString(name_15); - return grammarErrorOnNode(name_15, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - } - } - else if (nameBindings.kind === 213) { - var reportError = false; - for (var _i = 0, _a = nameBindings.elements; _i < _a.length; _i++) { - var element = _a[_i]; - var name_16 = element.name; - if (isReservedWordInStrictMode(name_16)) { - var nameText = ts.declarationNameToString(name_16); - reportError = reportError || grammarErrorOnNode(name_16, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - } - } - return reportError; - } - } - } - return false; - } - function checkGrammarDeclarationNameInStrictMode(node) { - var name = node.name; - if (name && name.kind === 65 && isReservedWordInStrictMode(name)) { - var nameText = ts.declarationNameToString(name); - switch (node.kind) { - case 130: - case 199: - case 201: - case 129: - case 153: - case 203: - case 204: - case 205: - return checkGrammarIdentifierInStrictMode(name); - case 202: - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText); - case 206: - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - case 209: - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - } - } - return false; - } - function checkGrammarTypeReferenceInStrictMode(typeName) { - if (typeName.kind === 65) { - checkGrammarTypeNameInStrictMode(typeName); - } - else if (typeName.kind === 127) { - checkGrammarTypeNameInStrictMode(typeName.right); - checkGrammarTypeReferenceInStrictMode(typeName.left); - } - } - function checkGrammarExpressionWithTypeArgumentsInStrictMode(expression) { - if (expression && expression.kind === 65) { - return checkGrammarIdentifierInStrictMode(expression); - } - else if (expression && expression.kind === 156) { - checkGrammarExpressionWithTypeArgumentsInStrictMode(expression.expression); - } - } - function checkGrammarIdentifierInStrictMode(node, nameText) { - if (node && node.kind === 65 && isReservedWordInStrictMode(node)) { - if (!nameText) { - nameText = ts.declarationNameToString(node); - } - var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) || - grammarErrorOnNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - return errorReport; - } - return false; - } - function checkGrammarTypeNameInStrictMode(node) { - if (node && node.kind === 65 && isReservedWordInStrictMode(node)) { - var nameText = ts.declarationNameToString(node); - var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) || - grammarErrorOnNode(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode, nameText); - return errorReport; - } - return false; - } function checkGrammarDecorators(node) { if (!node.decorators) { return false; @@ -19124,7 +19532,7 @@ var ts; else if (languageVersion < 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); } - else if (node.kind === 137 || node.kind === 138) { + else if (node.kind === 138 || node.kind === 139) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -19134,33 +19542,33 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 137: case 138: - case 136: - case 133: - case 132: - case 135: + case 139: + case 137: case 134: - case 141: - case 206: - case 210: - case 209: - case 216: - case 215: - case 130: + case 133: + case 136: + case 135: + case 142: + case 208: + case 212: + case 211: + case 218: + case 217: + case 131: break; - case 202: - case 203: - case 181: - case 201: case 204: - if (node.modifiers && node.parent.kind !== 207 && node.parent.kind !== 228) { + case 205: + case 183: + case 203: + case 206: + if (node.modifiers && node.parent.kind !== 209 && node.parent.kind !== 230) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 205: + case 207: if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 70) && - node.parent.kind !== 207 && node.parent.kind !== 228) { + node.parent.kind !== 209 && node.parent.kind !== 230) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -19196,7 +19604,7 @@ var ts; else if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (node.parent.kind === 207 || node.parent.kind === 228) { + else if (node.parent.kind === 209 || node.parent.kind === 230) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } flags |= ts.modifierToFlag(modifier.kind); @@ -19205,10 +19613,10 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (node.parent.kind === 207 || node.parent.kind === 228) { + else if (node.parent.kind === 209 || node.parent.kind === 230) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 130) { + else if (node.kind === 131) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } flags |= 128; @@ -19221,10 +19629,10 @@ var ts; else if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (node.parent.kind === 202) { + else if (node.parent.kind === 204) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 130) { + else if (node.kind === 131) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; @@ -19233,13 +19641,13 @@ var ts; if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (node.parent.kind === 202) { + else if (node.parent.kind === 204) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 130) { + else if (node.kind === 131) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 207) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 209) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -19247,7 +19655,7 @@ var ts; break; } } - if (node.kind === 136) { + if (node.kind === 137) { if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -19258,10 +19666,10 @@ var ts; return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } } - else if ((node.kind === 210 || node.kind === 209) && flags & 2) { + else if ((node.kind === 212 || node.kind === 211) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 130 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 131 && (flags & 112) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } } @@ -19324,7 +19732,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 164) { + if (node.kind === 166) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -19359,7 +19767,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 122 && parameter.type.kind !== 120) { + if (parameter.type.kind !== 123 && parameter.type.kind !== 121) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -19391,7 +19799,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < arguments.length; _i++) { var arg = arguments[_i]; - if (arg.kind === 176) { + if (arg.kind === 178) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -19462,19 +19870,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 128) { + if (node.kind !== 129) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 170 && computedPropertyName.expression.operatorToken.kind === 23) { + if (computedPropertyName.expression.kind === 172 && computedPropertyName.expression.operatorToken.kind === 23) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 201 || - node.kind === 163 || - node.kind === 135); + ts.Debug.assert(node.kind === 203 || + node.kind === 165 || + node.kind === 136); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -19486,9 +19894,6 @@ var ts; } } } - function checkGrammarFunctionName(name) { - return checkGrammarEvalOrArgumentsInStrictMode(name, name); - } function checkGrammarForInvalidQuestionMark(node, questionToken, message) { if (questionToken) { return grammarErrorOnNode(questionToken, message); @@ -19500,55 +19905,52 @@ var ts; var GetAccessor = 2; var SetAccesor = 4; var GetOrSetAccessor = GetAccessor | SetAccesor; - var inStrictMode = (node.parserContextFlags & 1) !== 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_17 = prop.name; - if (prop.kind === 176 || - name_17.kind === 128) { - checkGrammarComputedPropertyName(name_17); + var name_15 = prop.name; + if (prop.kind === 178 || + name_15.kind === 129) { + checkGrammarComputedPropertyName(name_15); continue; } var currentKind = void 0; - if (prop.kind === 225 || prop.kind === 226) { + if (prop.kind === 227 || prop.kind === 228) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_17.kind === 7) { - checkGrammarNumericLiteral(name_17); + if (name_15.kind === 7) { + checkGrammarNumericLiteral(name_15); } currentKind = Property; } - else if (prop.kind === 135) { + else if (prop.kind === 136) { currentKind = Property; } - else if (prop.kind === 137) { + else if (prop.kind === 138) { currentKind = GetAccessor; } - else if (prop.kind === 138) { + else if (prop.kind === 139) { currentKind = SetAccesor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, name_17.text)) { - seen[name_17.text] = currentKind; + if (!ts.hasProperty(seen, name_15.text)) { + seen[name_15.text] = currentKind; } else { - var existingKind = seen[name_17.text]; + var existingKind = seen[name_15.text]; if (currentKind === Property && existingKind === Property) { - if (inStrictMode) { - grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); - } + continue; } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_17.text] = currentKind | existingKind; + seen[name_15.text] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_15, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_15, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -19557,24 +19959,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 200) { + if (forInOrOfStatement.initializer.kind === 202) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 188 + var diagnostic = forInOrOfStatement.kind === 190 ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 188 + var diagnostic = forInOrOfStatement.kind === 190 ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 188 + var diagnostic = forInOrOfStatement.kind === 190 ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -19597,10 +19999,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 137 && accessor.parameters.length) { + else if (kind === 138 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 138) { + else if (kind === 139) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -19625,7 +20027,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 128 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 129 && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -19635,7 +20037,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 155) { + if (node.parent.kind === 157) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -19643,7 +20045,7 @@ var ts; return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } - if (node.parent.kind === 202) { + if (node.parent.kind === 204) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -19654,22 +20056,22 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 203) { + else if (node.parent.kind === 205) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 146) { + else if (node.parent.kind === 148) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { + case 189: + case 190: + case 191: case 187: case 188: - case 189: - case 185: - case 186: return true; - case 195: + case 197: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -19681,9 +20083,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 195: + case 197: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 190 + var isMisplacedContinueLabel = node.kind === 192 && !isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -19691,8 +20093,8 @@ var ts; return false; } break; - case 194: - if (node.kind === 191 && !node.label) { + case 196: + if (node.kind === 193 && !node.label) { return false; } break; @@ -19705,13 +20107,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 191 + var message = node.kind === 193 ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 191 + var message = node.kind === 193 ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -19723,17 +20125,16 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 152 || node.name.kind === 151) { + if (node.name.kind === 154 || node.name.kind === 153) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } } - return checkGrammarEvalOrArgumentsInStrictMode(node, node.name); } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 188 && node.parent.parent.kind !== 189) { + if (node.parent.parent.kind !== 190 && node.parent.parent.kind !== 191) { if (ts.isInAmbientContext(node)) { if (node.initializer) { var equalsTokenLength = "=".length; @@ -19750,8 +20151,7 @@ var ts; } } var checkLetConstNames = languageVersion >= 2 && (ts.isLet(node) || ts.isConst(node)); - return (checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name)) || - checkGrammarEvalOrArgumentsInStrictMode(node, node.name); + return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { if (name.kind === 65) { @@ -19763,7 +20163,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 176) { + if (element.kind !== 178) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -19780,15 +20180,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 184: - case 185: case 186: - case 193: case 187: case 188: - case 189: - return false; case 195: + case 189: + case 190: + case 191: + return false; + case 197: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -19804,7 +20204,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 168) { + if (expression.kind === 170) { var unaryExpression = expression; if (unaryExpression.operator === 33 || unaryExpression.operator === 34) { expression = unaryExpression.operand; @@ -19823,7 +20223,7 @@ var ts; var inAmbientContext = ts.isInAmbientContext(enumDecl); for (var _i = 0, _a = enumDecl.members; _i < _a.length; _i++) { var node = _a[_i]; - if (node.name.kind === 128) { + if (node.name.kind === 129) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -19865,23 +20265,6 @@ var ts; return true; } } - function checkGrammarEvalOrArgumentsInStrictMode(contextNode, name) { - if (name && name.kind === 65) { - var identifier = name; - if (contextNode && (contextNode.parserContextFlags & 1) && isEvalOrArgumentsIdentifier(identifier)) { - var nameText = ts.declarationNameToString(identifier); - var reportErrorInClassDeclaration = reportStrictModeGrammarErrorInClassDeclaration(identifier, ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText); - if (!reportErrorInClassDeclaration) { - return grammarErrorOnNode(identifier, ts.Diagnostics.Invalid_use_of_0_in_strict_mode, nameText); - } - return reportErrorInClassDeclaration; - } - } - } - function isEvalOrArgumentsIdentifier(node) { - return node.kind === 65 && - (node.text === "eval" || node.text === "arguments"); - } function checkGrammarConstructorTypeParameters(node) { if (node.typeParameters) { return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); @@ -19893,18 +20276,18 @@ var ts; } } function checkGrammarProperty(node) { - if (node.parent.kind === 202) { + if (node.parent.kind === 204) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 203) { + else if (node.parent.kind === 205) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 146) { + else if (node.parent.kind === 148) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -19914,11 +20297,11 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 203 || - node.kind === 210 || - node.kind === 209 || - node.kind === 216 || - node.kind === 215 || + if (node.kind === 205 || + node.kind === 212 || + node.kind === 211 || + node.kind === 218 || + node.kind === 217 || (node.flags & 2) || (node.flags & (1 | 256))) { return false; @@ -19928,7 +20311,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 181) { + if (ts.isDeclaration(decl) || decl.kind === 183) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -19947,7 +20330,7 @@ var ts; if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 180 || node.parent.kind === 207 || node.parent.kind === 228) { + if (node.parent.kind === 182 || node.parent.kind === 209 || node.parent.kind === 230) { var links_1 = getNodeLinks(node.parent); if (!links_1.hasReportedStatementInAmbientContext) { return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -19958,13 +20341,8 @@ var ts; } } function checkGrammarNumericLiteral(node) { - if (node.flags & 16384) { - if (node.parserContextFlags & 1) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode); - } - else if (languageVersion >= 1) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); - } + if (node.flags & 16384 && languageVersion >= 1) { + return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { @@ -19975,8 +20353,6 @@ var ts; return true; } } - initializeTypeChecker(); - return checker; } ts.createTypeChecker = createTypeChecker; })(ts || (ts = {})); @@ -20028,7 +20404,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 210); + ts.Debug.assert(aliasEmitInfo.node.kind === 212); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -20101,10 +20477,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 199) { + if (declaration.kind === 201) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 213 || declaration.kind === 214 || declaration.kind === 211) { + else if (declaration.kind === 215 || declaration.kind === 216 || declaration.kind === 213) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -20115,7 +20491,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 210) { + if (moduleElementEmitInfo.node.kind === 212) { moduleElementEmitInfo.isVisible = true; } else { @@ -20123,12 +20499,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 206) { + if (nodeToCheck.kind === 208) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 206) { + if (nodeToCheck.kind === 208) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -20216,39 +20592,39 @@ var ts; function emitType(type) { switch (type.kind) { case 112: - case 122: - case 120: - case 113: case 123: + case 121: + case 113: + case 124: case 99: case 8: return writeTextOfNode(currentSourceFile, type); - case 177: + case 179: return emitExpressionWithTypeArguments(type); - case 142: - return emitTypeReference(type); - case 145: - return emitTypeQuery(type); - case 147: - return emitArrayType(type); - case 148: - return emitTupleType(type); - case 149: - return emitUnionType(type); - case 150: - return emitParenType(type); - case 143: case 144: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); + case 147: + return emitTypeQuery(type); + case 149: + return emitArrayType(type); + case 150: + return emitTupleType(type); + case 151: + return emitUnionType(type); + case 152: + return emitParenType(type); + case 145: case 146: + return emitSignatureDeclarationWithJsDocComments(type); + case 148: return emitTypeLiteral(type); case 65: return emitEntityName(type); - case 127: + case 128: return emitEntityName(type); } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 209 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 211 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); function writeEntityName(entityName) { @@ -20256,8 +20632,8 @@ var ts; writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 127 ? entityName.left : entityName.expression; - var right = entityName.kind === 127 ? entityName.right : entityName.name; + var left = entityName.kind === 128 ? entityName.left : entityName.expression; + var right = entityName.kind === 128 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); @@ -20266,7 +20642,7 @@ var ts; } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 65 || node.expression.kind === 156); + ts.Debug.assert(node.expression.kind === 65 || node.expression.kind === 158); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -20327,9 +20703,9 @@ var ts; } var count = 0; while (true) { - var name_18 = baseName + "_" + (++count); - if (!ts.hasProperty(currentSourceFile.identifiers, name_18)) { - return name_18; + var name_16 = baseName + "_" + (++count); + if (!ts.hasProperty(currentSourceFile.identifiers, name_16)) { + return name_16; } } } @@ -20370,10 +20746,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 209 || - (node.parent.kind === 228 && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 211 || + (node.parent.kind === 230 && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 228) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 230) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -20382,7 +20758,7 @@ var ts; }); } else { - if (node.kind === 210) { + if (node.kind === 212) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -20400,23 +20776,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 201: - return writeFunctionDeclaration(node); - case 181: - return writeVariableStatement(node); case 203: - return writeInterfaceDeclaration(node); - case 202: - return writeClassDeclaration(node); - case 204: - return writeTypeAliasDeclaration(node); + return writeFunctionDeclaration(node); + case 183: + return writeVariableStatement(node); case 205: - return writeEnumDeclaration(node); + return writeInterfaceDeclaration(node); + case 204: + return writeClassDeclaration(node); case 206: + return writeTypeAliasDeclaration(node); + case 207: + return writeEnumDeclaration(node); + case 208: return writeModuleDeclaration(node); - case 209: + case 211: return writeImportEqualsDeclaration(node); - case 210: + case 212: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -20430,7 +20806,7 @@ var ts; if (node.flags & 256) { write("default "); } - else if (node.kind !== 203) { + else if (node.kind !== 205) { write("declare "); } } @@ -20474,7 +20850,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 212) { + if (namedBindings.kind === 214) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -20500,7 +20876,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 212) { + if (node.importClause.namedBindings.kind === 214) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -20549,9 +20925,14 @@ var ts; function writeModuleDeclaration(node) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - write("module "); + if (node.flags & 32768) { + write("namespace "); + } + else { + write("module "); + } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 207) { + while (node.body.kind !== 209) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -20612,7 +20993,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 135 && (node.parent.flags & 32); + return node.parent.kind === 136 && (node.parent.flags & 32); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -20622,15 +21003,15 @@ var ts; writeTextOfNode(currentSourceFile, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 143 || - node.parent.kind === 144 || - (node.parent.parent && node.parent.parent.kind === 146)) { - ts.Debug.assert(node.parent.kind === 135 || - node.parent.kind === 134 || - node.parent.kind === 143 || - node.parent.kind === 144 || - node.parent.kind === 139 || - node.parent.kind === 140); + if (node.parent.kind === 145 || + node.parent.kind === 146 || + (node.parent.parent && node.parent.parent.kind === 148)) { + ts.Debug.assert(node.parent.kind === 136 || + node.parent.kind === 135 || + node.parent.kind === 145 || + node.parent.kind === 146 || + node.parent.kind === 140 || + node.parent.kind === 141); emitType(node.constraint); } else { @@ -20640,31 +21021,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 202: + case 204: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 203: + case 205: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 140: + case 141: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 139: + case 140: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 136: case 135: - case 134: if (node.parent.flags & 128) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 202) { + else if (node.parent.parent.kind === 204) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 201: + case 203: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -20694,7 +21075,7 @@ var ts; } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 202) { + if (node.parent.parent.kind === 204) { diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; @@ -20771,16 +21152,16 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 199 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 201 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 133 || node.kind === 132) && ts.hasQuestionToken(node)) { + if ((node.kind === 134 || node.kind === 133) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 133 || node.kind === 132) && node.parent.kind === 146) { + if ((node.kind === 134 || node.kind === 133) && node.parent.kind === 148) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32)) { @@ -20789,14 +21170,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 199) { + if (node.kind === 201) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 133 || node.kind === 132) { + else if (node.kind === 134 || node.kind === 133) { if (node.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -20804,7 +21185,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 202) { + else if (node.parent.kind === 204) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -20830,7 +21211,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 176) { + if (element.kind !== 178) { elements.push(element); } } @@ -20896,7 +21277,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 137 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 138 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -20909,7 +21290,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 137 + return accessor.kind === 138 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -20918,7 +21299,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 138) { + if (accessorWithTypeAnnotation.kind === 139) { if (accessorWithTypeAnnotation.parent.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -20964,17 +21345,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 201) { + if (node.kind === 203) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 135) { + else if (node.kind === 136) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 201) { + if (node.kind === 203) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 136) { + else if (node.kind === 137) { write("constructor"); } else { @@ -20991,11 +21372,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 140 || node.kind === 144) { + if (node.kind === 141 || node.kind === 146) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 141) { + if (node.kind === 142) { write("["); } else { @@ -21004,20 +21385,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 141) { + if (node.kind === 142) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 143 || node.kind === 144; - if (isFunctionTypeOrConstructorType || node.parent.kind === 146) { + var isFunctionTypeOrConstructorType = node.kind === 145 || node.kind === 146; + if (isFunctionTypeOrConstructorType || node.parent.kind === 148) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 136 && !(node.flags & 32)) { + else if (node.kind !== 137 && !(node.flags & 32)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -21028,23 +21409,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 140: + case 141: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 139: + case 140: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 141: + case 142: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; + case 136: case 135: - case 134: if (node.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -21052,7 +21433,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 202) { + else if (node.parent.kind === 204) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -21065,7 +21446,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 201: + case 203: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -21097,9 +21478,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 143 || - node.parent.kind === 144 || - node.parent.parent.kind === 146) { + if (node.parent.kind === 145 || + node.parent.kind === 146 || + node.parent.parent.kind === 148) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32)) { @@ -21115,22 +21496,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 136: + case 137: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 140: + case 141: return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 139: + case 140: return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + case 136: case 135: - case 134: if (node.parent.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -21138,7 +21519,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 202) { + else if (node.parent.parent.kind === 204) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -21150,7 +21531,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 201: + case 203: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -21161,12 +21542,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 151) { + if (bindingPattern.kind === 153) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 152) { + else if (bindingPattern.kind === 154) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -21185,10 +21566,10 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 176) { + if (bindingElement.kind === 178) { write(" "); } - else if (bindingElement.kind === 153) { + else if (bindingElement.kind === 155) { if (bindingElement.propertyName) { writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); @@ -21211,39 +21592,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 201: - case 206: - case 209: case 203: - case 202: - case 204: + case 208: + case 211: case 205: + case 204: + case 206: + case 207: return emitModuleElement(node, isModuleElementVisible(node)); - case 181: + case 183: return emitModuleElement(node, isVariableStatementVisible(node)); - case 210: + case 212: return emitModuleElement(node, !node.importClause); - case 216: + case 218: return emitExportDeclaration(node); + case 137: case 136: case 135: - case 134: return writeFunctionDeclaration(node); - case 140: - case 139: case 141: + case 140: + case 142: return emitSignatureDeclarationWithJsDocComments(node); - case 137: case 138: + case 139: return emitAccessorDeclaration(node); + case 134: case 133: - case 132: return emitPropertyDeclaration(node); - case 227: + case 229: return emitEnumMemberDeclaration(node); - case 215: + case 217: return emitExportAssignment(node); - case 228: + case 230: return emitSourceFile(node); } } @@ -21289,7 +21670,7 @@ var ts; } ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; function emitFiles(resolver, host, targetSourceFile) { - var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n __.prototype = b.prototype;\n d.prototype = new __();\n};"; + var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; @@ -21353,7 +21734,6 @@ var ts; var exportFunctionForFile; var generatedNameSet = {}; var nodeToGeneratedName = []; - var blockScopedVariableToGeneratedName; var computedPropertyNamesToGeneratedNames; var extendsEmitted = false; var decorateEmitted = false; @@ -21413,9 +21793,9 @@ var ts; var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_19 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_19)) { - return name_19; + var name_17 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); + if (isUniqueName(name_17)) { + return name_17; } } } @@ -21433,72 +21813,39 @@ var ts; i++; } } - function assignGeneratedName(node, name) { - nodeToGeneratedName[ts.getNodeId(node)] = ts.unescapeIdentifier(name); - } - function generateNameForFunctionOrClassDeclaration(node) { - if (!node.name) { - assignGeneratedName(node, makeUniqueName("default")); - } - } function generateNameForModuleOrEnum(node) { - if (node.name.kind === 65) { - var name_20 = node.name.text; - assignGeneratedName(node, isUniqueLocalName(name_20, node) ? name_20 : makeUniqueName(name_20)); - } + var name = node.name.text; + return isUniqueLocalName(name, node) ? name : makeUniqueName(name); } function generateNameForImportOrExportDeclaration(node) { var expr = ts.getExternalModuleName(node); var baseName = expr.kind === 8 ? ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; - assignGeneratedName(node, makeUniqueName(baseName)); + return makeUniqueName(baseName); } - function generateNameForImportDeclaration(node) { - if (node.importClause) { - generateNameForImportOrExportDeclaration(node); - } - } - function generateNameForExportDeclaration(node) { - if (node.moduleSpecifier) { - generateNameForImportOrExportDeclaration(node); - } - } - function generateNameForExportAssignment(node) { - if (node.expression && node.expression.kind !== 65) { - assignGeneratedName(node, makeUniqueName("default")); - } + function generateNameForExportDefault() { + return makeUniqueName("default"); } function generateNameForNode(node) { switch (node.kind) { - case 201: - case 202: - case 175: - generateNameForFunctionOrClassDeclaration(node); - break; - case 206: - generateNameForModuleOrEnum(node); - generateNameForNode(node.body); - break; - case 205: - generateNameForModuleOrEnum(node); - break; - case 210: - generateNameForImportDeclaration(node); - break; - case 216: - generateNameForExportDeclaration(node); - break; - case 215: - generateNameForExportAssignment(node); - break; + case 65: + return makeUniqueName(node.text); + case 208: + case 207: + return generateNameForModuleOrEnum(node); + case 212: + case 218: + return generateNameForImportOrExportDeclaration(node); + case 203: + case 204: + case 177: + case 217: + return generateNameForExportDefault(); } } function getGeneratedNameForNode(node) { - var nodeId = ts.getNodeId(node); - if (!nodeToGeneratedName[nodeId]) { - generateNameForNode(node); - } - return nodeToGeneratedName[nodeId]; + var id = ts.getNodeId(node); + return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); } function initializeEmitterWithSourceMaps() { var sourceMapDir; @@ -21522,7 +21869,7 @@ var ts; return; } var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; - if (lastEncodedSourceMapSpan.emittedLine == lastRecordedSourceMapSpan.emittedLine) { + if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { if (sourceMapData.sourceMapMappings) { sourceMapData.sourceMapMappings += ","; } @@ -21575,8 +21922,8 @@ var ts; var emittedLine = writer.getLine(); var emittedColumn = writer.getColumn(); if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine != emittedLine || - lastRecordedSourceMapSpan.emittedColumn != emittedColumn || + lastRecordedSourceMapSpan.emittedLine !== emittedLine || + lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { @@ -21630,8 +21977,8 @@ var ts; if (scopeName) { var parentIndex = getSourceMapNameIndex(); if (parentIndex !== -1) { - var name_21 = node.name; - if (!name_21 || name_21.kind !== 128) { + var name_18 = node.name; + if (!name_18 || name_18.kind !== 129) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -21648,19 +21995,19 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 201 || - node.kind === 163 || + else if (node.kind === 203 || + node.kind === 165 || + node.kind === 136 || node.kind === 135 || - node.kind === 134 || - node.kind === 137 || node.kind === 138 || - node.kind === 206 || - node.kind === 202 || - node.kind === 205) { + node.kind === 139 || + node.kind === 208 || + node.kind === 204 || + node.kind === 207) { if (node.name) { - var name_22 = node.name; - scopeName = name_22.kind === 128 - ? ts.getTextOfNode(name_22) + var name_19 = node.name; + scopeName = name_19.kind === 129 + ? ts.getTextOfNode(name_19) : node.name.text; } recordScopeNameStart(scopeName); @@ -21753,19 +22100,19 @@ var ts; else { sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); } - function emitNodeWithSourceMap(node, allowGeneratedIdentifiers) { + function emitNodeWithSourceMap(node) { if (node) { if (ts.nodeIsSynthesized(node)) { - return emitNodeWithoutSourceMap(node, false); + return emitNodeWithoutSourceMap(node); } - if (node.kind != 228) { + if (node.kind !== 230) { recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers); + emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); } else { recordNewSourceFileStart(node); - emitNodeWithoutSourceMap(node, false); + emitNodeWithoutSourceMap(node); } } } @@ -22003,10 +22350,10 @@ var ts; emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); - if (node.template.kind === 172) { + if (node.template.kind === 174) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 170 + var needsParens = templateSpan.expression.kind === 172 && templateSpan.expression.operatorToken.kind === 23; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -22030,7 +22377,7 @@ var ts; } for (var i = 0, n = node.templateSpans.length; i < n; i++) { var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 162 + var needsParens = templateSpan.expression.kind !== 164 && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; if (i > 0 || headEmitted) { write(" + "); @@ -22063,11 +22410,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 158: - case 159: - return parent.expression === template; case 160: + case 161: + return parent.expression === template; case 162: + case 164: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1; @@ -22075,7 +22422,7 @@ var ts; } function comparePrecedenceToBinaryPlus(expression) { switch (expression.kind) { - case 170: + case 172: switch (expression.operatorToken.kind) { case 35: case 36: @@ -22087,8 +22434,8 @@ var ts; default: return -1; } + case 175: case 173: - case 171: return -1; default: return 1; @@ -22100,11 +22447,11 @@ var ts; emit(span.literal); } function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 153); + ts.Debug.assert(node.kind !== 155); if (node.kind === 8) { emitLiteral(node); } - else if (node.kind === 128) { + else if (node.kind === 129) { if (ts.nodeIsDecorated(node.parent)) { if (!computedPropertyNamesToGeneratedNames) { computedPropertyNamesToGeneratedNames = []; @@ -22132,75 +22479,122 @@ var ts; write("\""); } } - function isNotExpressionIdentifier(node) { + function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 130: - case 199: - case 153: - case 133: + case 156: + case 172: + case 160: + case 223: + case 129: + case 173: case 132: - case 225: - case 226: + case 167: + case 187: + case 159: + case 217: + case 185: + case 179: + case 189: + case 190: + case 191: + case 186: + case 161: + case 164: + case 171: + case 170: + case 194: + case 228: + case 176: + case 196: + case 162: + case 180: + case 198: + case 163: + case 168: + case 169: + case 188: + case 195: + case 175: + return true; + case 155: + case 229: + case 131: case 227: - case 135: case 134: case 201: - case 137: - case 138: - case 163: - case 202: - case 203: - case 205: - case 206: - case 209: + return parent.initializer === node; + case 158: + return parent.expression === node; + case 166: + case 165: + return parent.body === node; case 211: - case 212: - return parent.name === node; - case 214: - case 218: - return parent.name === node || parent.propertyName === node; - case 191: - case 190: - case 215: - return false; - case 195: - return node.parent.label === node; + return parent.moduleReference === node; + case 128: + return parent.left === node; } + return false; } function emitExpressionIdentifier(node) { - var substitution = resolver.getExpressionNameSubstitution(node, getGeneratedNameForNode); - if (substitution) { - write(substitution); + var container = resolver.getReferencedExportContainer(node); + if (container) { + if (container.kind === 230) { + if (languageVersion < 2 && compilerOptions.module !== 4) { + write("exports."); + } + } + else { + write(getGeneratedNameForNode(container)); + write("."); + } } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function getGeneratedNameForIdentifier(node) { - if (ts.nodeIsSynthesized(node) || !blockScopedVariableToGeneratedName) { - return undefined; - } - var variableId = resolver.getBlockScopedVariableId(node); - if (variableId === undefined) { - return undefined; - } - return blockScopedVariableToGeneratedName[variableId]; - } - function emitIdentifier(node, allowGeneratedIdentifiers) { - if (allowGeneratedIdentifiers) { - var generatedName = getGeneratedNameForIdentifier(node); - if (generatedName) { - write(generatedName); + else if (languageVersion < 2) { + var declaration = resolver.getReferencedImportDeclaration(node); + if (declaration) { + if (declaration.kind === 213) { + write(getGeneratedNameForNode(declaration.parent)); + write(languageVersion === 0 ? '["default"]' : ".default"); + return; + } + else if (declaration.kind === 216) { + write(getGeneratedNameForNode(declaration.parent.parent.parent)); + write("."); + writeTextOfNode(currentSourceFile, declaration.propertyName || declaration.name); + return; + } + } + declaration = resolver.getReferencedNestedRedeclaration(node); + if (declaration) { + write(getGeneratedNameForNode(declaration.name)); return; } } + writeTextOfNode(currentSourceFile, node); + } + function isNameOfNestedRedeclaration(node) { + if (languageVersion < 2) { + var parent_7 = node.parent; + switch (parent_7.kind) { + case 155: + case 204: + case 207: + case 201: + return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); + } + } + return false; + } + function emitIdentifier(node) { if (!node.parent) { write(node.text); } - else if (!isNotExpressionIdentifier(node)) { + else if (isExpressionIdentifier(node)) { emitExpressionIdentifier(node); } + else if (isNameOfNestedRedeclaration(node)) { + write(getGeneratedNameForNode(node)); + } else { writeTextOfNode(currentSourceFile, node); } @@ -22241,7 +22635,7 @@ var ts; } function emitBindingElement(node) { if (node.propertyName) { - emit(node.propertyName, false); + emit(node.propertyName); write(": "); } if (node.dotDotDotToken) { @@ -22272,11 +22666,11 @@ var ts; function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { case 65: - case 154: case 156: - case 157: case 158: - case 162: + case 159: + case 160: + case 164: return false; } return true; @@ -22293,17 +22687,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 174) { + if (e.kind === 176) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 154) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 156) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 174) { + while (i < length && elements[i].kind !== 176) { i++; } write("["); @@ -22326,7 +22720,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 174; + return node.kind === 176; } function emitArrayLiteral(node) { var elements = node.elements; @@ -22387,7 +22781,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 137 || property.kind === 138) { + if (property.kind === 138 || property.kind === 139) { var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { continue; @@ -22438,13 +22832,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 225) { + if (property.kind === 227) { emit(property.initializer); } - else if (property.kind === 226) { + else if (property.kind === 228) { emitExpressionIdentifier(property.name); } - else if (property.kind === 135) { + else if (property.kind === 136) { emitFunctionDeclaration(property); } else { @@ -22476,7 +22870,7 @@ var ts; var numProperties = properties.length; var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 128) { + if (properties[i].name.kind === 129) { numInitialNonComputedProperties = i; break; } @@ -22490,35 +22884,35 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(170, startsOnNewLine); + var result = ts.createSynthesizedNode(172, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(156); + var result = ts.createSynthesizedNode(158); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(20); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(157); + var result = ts.createSynthesizedNode(159); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; } function parenthesizeForAccess(expr) { - while (expr.kind === 161) { + while (expr.kind === 163) { expr = expr.expression; } if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 159 && + expr.kind !== 161 && expr.kind !== 7) { return expr; } - var node = ts.createSynthesizedNode(162); + var node = ts.createSynthesizedNode(164); node.expression = expr; return node; } @@ -22531,32 +22925,26 @@ var ts; if (languageVersion >= 2 && node.asteriskToken) { write("*"); } - emit(node.name, false); + emit(node.name); if (languageVersion < 2) { write(": function "); } emitSignatureAndBody(node); } function emitPropertyAssignment(node) { - emit(node.name, false); + emit(node.name); write(": "); emit(node.initializer); } + function isNamespaceExportReference(node) { + var container = resolver.getReferencedExportContainer(node); + return container && container.kind !== 230; + } function emitShorthandPropertyAssignment(node) { - emit(node.name, false); - if (languageVersion < 2) { + writeTextOfNode(currentSourceFile, node.name); + if (languageVersion < 2 || isNamespaceExportReference(node.name)) { write(": "); - var generatedName = getGeneratedNameForIdentifier(node.name); - if (generatedName) { - write(generatedName); - } - else { - emitExpressionIdentifier(node.name); - } - } - else if (resolver.getExpressionNameSubstitution(node.name, getGeneratedNameForNode)) { - write(": "); - emitExpressionIdentifier(node.name); + emit(node.name); } } function tryEmitConstantValue(node) { @@ -22567,7 +22955,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 156 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 158 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -22597,7 +22985,7 @@ var ts; var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); write("."); var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); - emit(node.name, false); + emit(node.name); decreaseIndentIf(indentedBeforeDot, indentedAfterDot); } function emitQualifiedName(node) { @@ -22615,10 +23003,10 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 174; }); + return ts.forEach(elements, function (e) { return e.kind === 176; }); } function skipParentheses(node) { - while (node.kind === 162 || node.kind === 161) { + while (node.kind === 164 || node.kind === 163) { node = node.expression; } return node; @@ -22639,12 +23027,12 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 156) { + if (expr.kind === 158) { target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 157) { + else if (expr.kind === 159) { target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); @@ -22685,7 +23073,7 @@ var ts; } else { emit(node.expression); - superCall = node.expression.kind === 156 && node.expression.expression.kind === 91; + superCall = node.expression.kind === 158 && node.expression.expression.kind === 91; } if (superCall && languageVersion < 2) { write(".call("); @@ -22736,20 +23124,20 @@ var ts; } } function emitParenExpression(node) { - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 164) { - if (node.expression.kind === 161) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 166) { + if (node.expression.kind === 163) { var operand = node.expression.expression; - while (operand.kind == 161) { + while (operand.kind === 163) { operand = operand.expression; } - if (operand.kind !== 168 && - operand.kind !== 167 && - operand.kind !== 166 && - operand.kind !== 165 && + if (operand.kind !== 170 && operand.kind !== 169 && - operand.kind !== 159 && - !(operand.kind === 158 && node.parent.kind === 159) && - !(operand.kind === 163 && node.parent.kind === 158)) { + operand.kind !== 168 && + operand.kind !== 167 && + operand.kind !== 171 && + operand.kind !== 161 && + !(operand.kind === 160 && node.parent.kind === 161) && + !(operand.kind === 165 && node.parent.kind === 160)) { emit(operand); return; } @@ -22778,7 +23166,7 @@ var ts; if (!isCurrentFileSystemExternalModule() || node.kind !== 65 || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 199 || node.parent.kind === 153); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 201 || node.parent.kind === 155); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -22792,7 +23180,7 @@ var ts; write("\", "); } write(ts.tokenToString(node.operator)); - if (node.operand.kind === 168) { + if (node.operand.kind === 170) { var operand = node.operand; if (node.operator === 33 && (operand.operator === 33 || operand.operator === 38)) { write(" "); @@ -22835,10 +23223,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 228) { + if (current.kind === 230) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 207) { + else if (ts.isFunctionLike(current) || current.kind === 209) { return false; } else { @@ -22848,8 +23236,8 @@ var ts; } function emitBinaryExpression(node) { if (languageVersion < 2 && node.operatorToken.kind === 53 && - (node.left.kind === 155 || node.left.kind === 154)) { - emitDestructuring(node, node.parent.kind === 183); + (node.left.kind === 157 || node.left.kind === 156)) { + emitDestructuring(node, node.parent.kind === 185); } else { var exportChanged = node.operatorToken.kind >= 53 && @@ -22896,7 +23284,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 180) { + if (node && node.kind === 182) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -22911,12 +23299,12 @@ var ts; emitToken(14, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 207) { - ts.Debug.assert(node.parent.kind === 206); + if (node.kind === 209) { + ts.Debug.assert(node.parent.kind === 208); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 207) { + if (node.kind === 209) { emitTempDeclarations(true); } decreaseIndent(); @@ -22925,7 +23313,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 180) { + if (node.kind === 182) { write(" "); emit(node); } @@ -22937,7 +23325,7 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 164); + emitParenthesizedIf(node.expression, node.expression.kind === 166); write(";"); } function emitIfStatement(node) { @@ -22950,7 +23338,7 @@ var ts; if (node.elseStatement) { writeLine(); emitToken(76, node.thenStatement.end); - if (node.elseStatement.kind === 184) { + if (node.elseStatement.kind === 186) { write(" "); emit(node.elseStatement); } @@ -22962,7 +23350,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 180) { + if (node.statement.kind === 182) { write(" "); } else { @@ -23031,7 +23419,7 @@ var ts; var endPos = emitToken(82, node.pos); write(" "); endPos = emitToken(16, endPos); - if (node.initializer && node.initializer.kind === 200) { + if (node.initializer && node.initializer.kind === 202) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -23052,13 +23440,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 189) { + if (languageVersion < 2 && node.kind === 191) { return emitDownLevelForOfStatement(node); } var endPos = emitToken(82, node.pos); write(" "); endPos = emitToken(16, endPos); - if (node.initializer.kind === 200) { + if (node.initializer.kind === 202) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -23068,7 +23456,7 @@ var ts; else { emit(node.initializer); } - if (node.kind === 188) { + if (node.kind === 190) { write(" in "); } else { @@ -23136,7 +23524,7 @@ var ts; increaseIndent(); var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 200) { + if (node.initializer.kind === 202) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -23158,7 +23546,7 @@ var ts; } else { var assignmentExpression = createBinaryExpression(node.initializer, 53, rhsIterationValue, false); - if (node.initializer.kind === 154 || node.initializer.kind === 155) { + if (node.initializer.kind === 156 || node.initializer.kind === 157) { emitDestructuring(assignmentExpression, true, undefined); } else { @@ -23167,7 +23555,7 @@ var ts; } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 180) { + if (node.statement.kind === 182) { emitLines(node.statement.statements); } else { @@ -23179,7 +23567,7 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 191 ? 66 : 71, node.pos); + emitToken(node.kind === 193 ? 66 : 71, node.pos); emitOptional(" ", node.label); write(";"); } @@ -23224,7 +23612,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 221) { + if (node.kind === 223) { write("case "); emit(node.expression); write(":"); @@ -23279,7 +23667,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 206); + } while (node && node.kind !== 208); return node; } function emitContainingModuleName(node) { @@ -23304,7 +23692,7 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(7); zero.text = "0"; - var result = ts.createSynthesizedNode(167); + var result = ts.createSynthesizedNode(169); result.expression = zero; return result; } @@ -23373,15 +23761,15 @@ var ts; function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; var canDefineTempVariablesInPlace = false; - if (root.kind === 199) { + if (root.kind === 201) { var isExported = ts.getCombinedNodeFlags(root) & 1; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 130) { + else if (root.kind === 131) { canDefineTempVariablesInPlace = true; } - if (root.kind === 170) { + if (root.kind === 172) { emitAssignmentExpression(root); } else { @@ -23392,8 +23780,7 @@ var ts; if (emitCount++) { write(", "); } - renameNonTopLevelLetAndConst(name); - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 199 || name.parent.kind === 153); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 201 || name.parent.kind === 155); var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(exportFunctionForFile + "(\""); @@ -23425,14 +23812,14 @@ var ts; } function createDefaultValueCheck(value, defaultValue) { value = ensureIdentifier(value); - var equals = ts.createSynthesizedNode(170); + var equals = ts.createSynthesizedNode(172); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(30); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(171); + var cond = ts.createSynthesizedNode(173); cond.condition = condition; cond.questionToken = ts.createSynthesizedNode(50); cond.whenTrue = whenTrue; @@ -23446,13 +23833,15 @@ var ts; return node; } function createPropertyAccessForDestructuringProperty(object, propName) { - if (propName.kind !== 65) { - return createElementAccessExpression(object, propName); + var syntheticName = ts.createSynthesizedNode(propName.kind); + syntheticName.text = propName.text; + if (syntheticName.kind !== 65) { + return createElementAccessExpression(object, syntheticName); } - return createPropertyAccessExpression(object, propName); + return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(158); + var call = ts.createSynthesizedNode(160); var sliceIdentifier = ts.createSynthesizedNode(65); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); @@ -23467,8 +23856,8 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 225 || p.kind === 226) { - var propName = (p.name); + if (p.kind === 227 || p.kind === 228) { + var propName = p.name; emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } } @@ -23480,8 +23869,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 176) { - if (e.kind !== 174) { + if (e.kind !== 178) { + if (e.kind !== 176) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -23491,14 +23880,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 170 && target.operatorToken.kind === 53) { + if (target.kind === 172 && target.operatorToken.kind === 53) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 155) { + if (target.kind === 157) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 154) { + else if (target.kind === 156) { emitArrayLiteralAssignment(target, value); } else { @@ -23512,14 +23901,14 @@ var ts; emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 162) { + if (root.parent.kind !== 164) { write("("); } value = ensureIdentifier(value); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 162) { + if (root.parent.kind !== 164) { write(")"); } } @@ -23539,11 +23928,11 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 151) { + if (pattern.kind === 153) { var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 176) { + else if (element.kind !== 178) { if (!element.dotDotDotToken) { emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); } @@ -23569,14 +23958,13 @@ var ts; } } else { - renameNonTopLevelLetAndConst(node.name); var initializer = node.initializer; if (!initializer && languageVersion < 2) { var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 256) && (getCombinedFlagsForIdentifier(node.name) & 4096); if (isUninitializedLet && - node.parent.parent.kind !== 188 && - node.parent.parent.kind !== 189) { + node.parent.parent.kind !== 190 && + node.parent.parent.kind !== 191) { initializer = createVoidZero(); } } @@ -23594,7 +23982,7 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 176) { + if (node.kind === 178) { return; } var name = node.name; @@ -23606,48 +23994,15 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 199 && node.parent.kind !== 153)) { + if (!node.parent || (node.parent.kind !== 201 && node.parent.kind !== 155)) { return 0; } return ts.getCombinedNodeFlags(node.parent); } - function renameNonTopLevelLetAndConst(node) { - if (languageVersion >= 2 || - ts.nodeIsSynthesized(node) || - node.kind !== 65 || - (node.parent.kind !== 199 && node.parent.kind !== 153)) { - return; - } - var combinedFlags = getCombinedFlagsForIdentifier(node); - if (((combinedFlags & 12288) === 0) || combinedFlags & 1) { - return; - } - var list = ts.getAncestor(node, 200); - if (list.parent.kind === 181) { - var isSourceFileLevelBinding = list.parent.parent.kind === 228; - var isModuleLevelBinding = list.parent.parent.kind === 207; - var isFunctionLevelBinding = list.parent.parent.kind === 180 && ts.isFunctionLike(list.parent.parent.parent); - if (isSourceFileLevelBinding || isModuleLevelBinding || isFunctionLevelBinding) { - return; - } - } - var blockScopeContainer = ts.getEnclosingBlockScopeContainer(node); - var parent = blockScopeContainer.kind === 228 - ? blockScopeContainer - : blockScopeContainer.parent; - if (resolver.resolvesToSomeValue(parent, node.text)) { - var variableId = resolver.getBlockScopedVariableId(node); - if (!blockScopedVariableToGeneratedName) { - blockScopedVariableToGeneratedName = []; - } - var generatedName = makeUniqueName(node.text); - blockScopedVariableToGeneratedName[variableId] = generatedName; - } - } function isES6ExportedDeclaration(node) { return !!(node.flags & 1) && languageVersion >= 2 && - node.parent.kind === 228; + node.parent.kind === 230; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -23692,12 +24047,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2) { if (ts.isBindingPattern(node.name)) { - var name_23 = createTempVariable(0); + var name_20 = createTempVariable(0); if (!tempParameters) { tempParameters = []; } - tempParameters.push(name_23); - emit(name_23); + tempParameters.push(name_20); + emit(name_20); } else { emit(node.name); @@ -23785,12 +24140,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 137 ? "get " : "set "); - emit(node.name, false); + write(node.kind === 138 ? "get " : "set "); + emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 164 && languageVersion >= 2; + return node.kind === 166 && languageVersion >= 2; } function emitDeclarationName(node) { if (node.name) { @@ -23801,10 +24156,10 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 163) { + if (node.kind === 165) { return !!node.name; } - if (node.kind === 201) { + if (node.kind === 203) { return !!node.name || languageVersion < 2; } } @@ -23812,7 +24167,7 @@ var ts; if (ts.nodeIsMissing(node.body)) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 135 && node.kind !== 134) { + if (node.kind !== 136 && node.kind !== 135) { emitLeadingComments(node); } if (!shouldEmitAsArrowFunction(node)) { @@ -23832,10 +24187,10 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 && node.kind === 201 && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 && node.kind === 203 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 135 && node.kind !== 134) { + if (node.kind !== 136 && node.kind !== 135) { emitTrailingComments(node); } } @@ -23882,7 +24237,7 @@ var ts; if (!node.body) { write(" { }"); } - else if (node.body.kind === 180) { + else if (node.body.kind === 182) { emitBlockFunctionBody(node, node.body); } else { @@ -23907,10 +24262,10 @@ var ts; } write(" "); var current = body; - while (current.kind === 161) { + while (current.kind === 163) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 155); + emitParenthesizedIf(body, current.kind === 157); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -23982,9 +24337,9 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 183) { + if (statement && statement.kind === 185) { var expr = statement.expression; - if (expr && expr.kind === 158) { + if (expr && expr.kind === 160) { var func = expr.expression; if (func && func.kind === 91) { return statement; @@ -24015,7 +24370,7 @@ var ts; emitNodeWithoutSourceMap(memberName); write("]"); } - else if (memberName.kind === 128) { + else if (memberName.kind === 129) { emitComputedPropertyName(memberName); } else { @@ -24027,7 +24382,7 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 133 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { + if (member.kind === 134 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { properties.push(member); } } @@ -24067,11 +24422,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 179) { + if (member.kind === 181) { writeLine(); write(";"); } - else if (member.kind === 135 || node.kind === 134) { + else if (member.kind === 136 || node.kind === 135) { if (!member.body) { return emitOnlyPinnedOrTripleSlashComments(member); } @@ -24090,7 +24445,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 137 || member.kind === 138) { + else if (member.kind === 138 || member.kind === 139) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -24140,22 +24495,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 135 || node.kind === 134) && !member.body) { + if ((member.kind === 136 || node.kind === 135) && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - else if (member.kind === 135 || - member.kind === 137 || - member.kind === 138) { + else if (member.kind === 136 || + member.kind === 138 || + member.kind === 139) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128) { write("static "); } - if (member.kind === 137) { + if (member.kind === 138) { write("get "); } - else if (member.kind === 138) { + else if (member.kind === 139) { write("set "); } if (member.asteriskToken) { @@ -24166,7 +24521,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 179) { + else if (member.kind === 181) { writeLine(); write(";"); } @@ -24187,10 +24542,10 @@ var ts; function emitConstructorWorker(node, baseTypeElement) { var hasInstancePropertyWithInitializer = false; ts.forEach(node.members, function (member) { - if (member.kind === 136 && !member.body) { + if (member.kind === 137 && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - if (member.kind === 133 && member.initializer && (member.flags & 128) === 0) { + if (member.kind === 134 && member.initializer && (member.flags & 128) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -24290,7 +24645,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 202) { + if (node.kind === 204) { if (thisNodeIsDecorated) { if (isES6ExportedDeclaration(node) && !(node.flags & 256)) { write("export "); @@ -24307,7 +24662,7 @@ var ts; } } var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 175; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 177; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0); @@ -24374,7 +24729,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 202) { + if (node.kind === 204) { if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); } @@ -24432,11 +24787,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 202) { + if (node.kind === 204) { write(";"); } emitEnd(node); - if (node.kind === 202) { + if (node.kind === 204) { emitExportMemberAssignment(node); } if (languageVersion < 2 && node.parent === currentSourceFile && node.name) { @@ -24510,13 +24865,13 @@ var ts; } else { decorators = member.decorators; - if (member.kind === 135) { + if (member.kind === 136) { functionLikeMember = member; } } writeLine(); emitStart(member); - if (member.kind !== 133) { + if (member.kind !== 134) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -24546,7 +24901,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 133) { + if (member.kind !== 134) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -24585,26 +24940,26 @@ var ts; } function shouldEmitTypeMetadata(node) { switch (node.kind) { - case 135: - case 137: + case 136: case 138: - case 133: + case 139: + case 134: return true; } return false; } function shouldEmitReturnTypeMetadata(node) { switch (node.kind) { - case 135: + case 136: return true; } return false; } function shouldEmitParamTypesMetadata(node) { switch (node.kind) { - case 202: - case 135: - case 138: + case 204: + case 136: + case 139: return true; } return false; @@ -24613,7 +24968,7 @@ var ts; var argumentsWritten = 0; if (compilerOptions.emitDecoratorMetadata) { if (shouldEmitTypeMetadata(node)) { - var serializedType = resolver.serializeTypeOfNode(node, getGeneratedNameForNode); + var serializedType = resolver.serializeTypeOfNode(node); if (serializedType) { if (writeComma) { write(", "); @@ -24626,7 +24981,7 @@ var ts; } } if (shouldEmitParamTypesMetadata(node)) { - var serializedTypes = resolver.serializeParameterTypesOfNode(node, getGeneratedNameForNode); + var serializedTypes = resolver.serializeParameterTypesOfNode(node); if (serializedTypes) { if (writeComma || argumentsWritten) { write(", "); @@ -24644,7 +24999,7 @@ var ts; } } if (shouldEmitReturnTypeMetadata(node)) { - var serializedType = resolver.serializeReturnTypeOfNode(node, getGeneratedNameForNode); + var serializedType = resolver.serializeReturnTypeOfNode(node); if (serializedType) { if (writeComma || argumentsWritten) { write(", "); @@ -24774,7 +25129,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 206) { + if (moduleDeclaration.body.kind === 208) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -24809,7 +25164,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 207) { + if (node.body.kind === 209) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -24866,16 +25221,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 209) { + if (node.kind === 211) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 212) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 214) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 210 && node.importClause && !!node.importClause.name; + return node.kind === 212 && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -24902,7 +25257,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 212) { + if (node.importClause.namedBindings.kind === 214) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -24928,7 +25283,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 209 && (node.flags & 1) !== 0; + var isExportedImport = node.kind === 211 && (node.flags & 1) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2) { emitLeadingComments(node); @@ -24940,7 +25295,7 @@ var ts; write(" = "); } else { - var isNakedImport = 210 && !node.importClause; + var isNakedImport = 212 && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -25096,8 +25451,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 201 && - expression.kind !== 202) { + if (expression.kind !== 203 && + expression.kind !== 204) { write(";"); } emitEnd(node); @@ -25133,18 +25488,18 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 210: + case 212: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { externalImports.push(node); } break; - case 209: - if (node.moduleReference.kind === 220 && resolver.isReferencedAliasDeclaration(node)) { + case 211: + if (node.moduleReference.kind === 222 && resolver.isReferencedAliasDeclaration(node)) { externalImports.push(node); } break; - case 216: + case 218: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -25157,12 +25512,12 @@ var ts; else { for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; - var name_24 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_24] || (exportSpecifiers[name_24] = [])).push(specifier); + var name_21 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_21] || (exportSpecifiers[name_21] = [])).push(specifier); } } break; - case 215: + case 217: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -25182,13 +25537,16 @@ var ts; write("}"); } } - function getLocalNameForExternalImport(importNode) { - var namespaceDeclaration = getNamespaceDeclarationNode(importNode); - if (namespaceDeclaration && !isDefaultImport(importNode)) { + function getLocalNameForExternalImport(node) { + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - else { - return getGeneratedNameForNode(importNode); + if (node.kind === 212 && node.importClause) { + return getGeneratedNameForNode(node); + } + if (node.kind === 218 && node.moduleSpecifier) { + return getGeneratedNameForNode(node); } } function getExternalModuleNameText(importNode) { @@ -25206,8 +25564,8 @@ var ts; var started = false; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; - var skipNode = importNode.kind === 216 || - (importNode.kind === 210 && !importNode.importClause); + var skipNode = importNode.kind === 218 || + (importNode.kind === 212 && !importNode.importClause); if (skipNode) { continue; } @@ -25232,7 +25590,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 216 && externalImport.exportClause) { + if (externalImport.kind === 218 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -25261,7 +25619,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 216) { + if (externalImport.kind !== 218) { continue; } var exportDecl = externalImport; @@ -25331,11 +25689,11 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_25 = local.kind === 65 + var name_22 = local.kind === 65 ? local : local.name; - if (name_25) { - var text = ts.unescapeIdentifier(name_25.text); + if (name_22) { + var text = ts.unescapeIdentifier(name_22.text); if (ts.hasProperty(seen, text)) { continue; } @@ -25346,7 +25704,7 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 202 || local.kind === 206 || local.kind === 205) { + if (local.kind === 204 || local.kind === 208 || local.kind === 207) { emitDeclarationName(local); } else { @@ -25380,21 +25738,21 @@ var ts; if (node.flags & 2) { return; } - if (node.kind === 201) { + if (node.kind === 203) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 202) { + if (node.kind === 204) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 205) { + if (node.kind === 207) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -25403,7 +25761,7 @@ var ts; } return; } - if (node.kind === 206) { + if (node.kind === 208) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -25412,17 +25770,17 @@ var ts; } return; } - if (node.kind === 199 || node.kind === 153) { + if (node.kind === 201 || node.kind === 155) { if (shouldHoistVariable(node, false)) { - var name_26 = node.name; - if (name_26.kind === 65) { + var name_23 = node.name; + if (name_23.kind === 65) { if (!hoistedVars) { hoistedVars = []; } - hoistedVars.push(name_26); + hoistedVars.push(name_23); } else { - ts.forEachChild(name_26, visit); + ts.forEachChild(name_23, visit); } } return; @@ -25441,7 +25799,7 @@ var ts; return false; } return (ts.getCombinedNodeFlags(node) & 12288) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 228; + ts.getEnclosingBlockScopeContainer(node).kind === 230; } function isCurrentFileSystemExternalModule() { return compilerOptions.module === 4 && ts.isExternalModule(currentSourceFile); @@ -25458,10 +25816,10 @@ var ts; emitSetters(exportStarFunction); writeLine(); emitExecute(node, startIndex); - emitTempDeclarations(true); decreaseIndent(); writeLine(); write("}"); + emitTempDeclarations(true); } function emitSetters(exportStarFunction) { write("setters:["); @@ -25476,27 +25834,27 @@ var ts; var parameterName = "_" + importVariableName; write("function (" + parameterName + ") {"); switch (importNode.kind) { - case 210: + case 212: if (!importNode.importClause) { break; } - case 209: + case 211: ts.Debug.assert(importVariableName !== ""); increaseIndent(); writeLine(); write(importVariableName + " = " + parameterName + ";"); writeLine(); - var defaultName = importNode.kind === 210 + var defaultName = importNode.kind === 212 ? importNode.importClause.name : importNode.name; if (defaultName) { emitExportMemberAssignments(defaultName); writeLine(); } - if (importNode.kind === 210 && + if (importNode.kind === 212 && importNode.importClause.namedBindings) { var namedBindings = importNode.importClause.namedBindings; - if (namedBindings.kind === 212) { + if (namedBindings.kind === 214) { emitExportMemberAssignments(namedBindings.name); writeLine(); } @@ -25510,7 +25868,7 @@ var ts; } decreaseIndent(); break; - case 216: + case 218: ts.Debug.assert(importVariableName !== ""); increaseIndent(); if (importNode.exportClause) { @@ -25544,10 +25902,10 @@ var ts; for (var i = startIndex; i < node.statements.length; ++i) { var statement = node.statements[i]; switch (statement.kind) { - case 216: - case 210: - case 209: - case 201: + case 218: + case 212: + case 211: + case 203: continue; } writeLine(); @@ -25561,7 +25919,11 @@ var ts; collectExternalModuleInfo(node); ts.Debug.assert(!exportFunctionForFile); exportFunctionForFile = makeUniqueName("exports"); - write("System.register(["); + write("System.register("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + write("["); for (var i = 0; i < externalImports.length; ++i) { var text = getExternalModuleNameText(externalImports[i]); if (i !== 0) { @@ -25634,8 +25996,8 @@ var ts; collectExternalModuleInfo(node); writeLine(); write("define("); - if (node.amdModuleName) { - write("\"" + node.amdModuleName + "\", "); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); } emitAMDDependencies(node, true); write(") {"); @@ -25764,7 +26126,7 @@ var ts; } emitLeadingComments(node.endOfFileToken); } - function emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers) { + function emitNodeWithoutSourceMap(node) { if (!node) { return; } @@ -25775,48 +26137,47 @@ var ts; if (emitComments) { emitLeadingComments(node); } - emitJavaScriptWorker(node, allowGeneratedIdentifiers); + emitJavaScriptWorker(node); if (emitComments) { emitTrailingComments(node); } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 203: - case 201: - case 210: - case 209: - case 204: - case 215: - return false; - case 181: - return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 206: - return shouldEmitModuleDeclaration(node); case 205: + case 203: + case 212: + case 211: + case 206: + case 217: + return false; + case 183: + return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); + case 208: + return shouldEmitModuleDeclaration(node); + case 207: return shouldEmitEnumDeclaration(node); } - if (node.kind !== 180 && + if (node.kind !== 182 && node.parent && - node.parent.kind === 164 && + node.parent.kind === 166 && node.parent.body === node && compilerOptions.target <= 1) { return false; } return true; } - function emitJavaScriptWorker(node, allowGeneratedIdentifiers) { - if (allowGeneratedIdentifiers === void 0) { allowGeneratedIdentifiers = true; } + function emitJavaScriptWorker(node) { switch (node.kind) { case 65: - return emitIdentifier(node, allowGeneratedIdentifiers); - case 130: + return emitIdentifier(node); + case 131: return emitParameter(node); + case 136: case 135: - case 134: return emitMethod(node); - case 137: case 138: + case 139: return emitAccessor(node); case 93: return emitThis(node); @@ -25836,131 +26197,131 @@ var ts; case 12: case 13: return emitLiteral(node); - case 172: - return emitTemplateExpression(node); - case 178: - return emitTemplateSpan(node); - case 127: - return emitQualifiedName(node); - case 151: - return emitObjectBindingPattern(node); - case 152: - return emitArrayBindingPattern(node); - case 153: - return emitBindingElement(node); - case 154: - return emitArrayLiteral(node); - case 155: - return emitObjectLiteral(node); - case 225: - return emitPropertyAssignment(node); - case 226: - return emitShorthandPropertyAssignment(node); - case 128: - return emitComputedPropertyName(node); - case 156: - return emitPropertyAccess(node); - case 157: - return emitIndexedAccess(node); - case 158: - return emitCallExpression(node); - case 159: - return emitNewExpression(node); - case 160: - return emitTaggedTemplateExpression(node); - case 161: - return emit(node.expression); - case 162: - return emitParenExpression(node); - case 201: - case 163: - case 164: - return emitFunctionDeclaration(node); - case 165: - return emitDeleteExpression(node); - case 166: - return emitTypeOfExpression(node); - case 167: - return emitVoidExpression(node); - case 168: - return emitPrefixUnaryExpression(node); - case 169: - return emitPostfixUnaryExpression(node); - case 170: - return emitBinaryExpression(node); - case 171: - return emitConditionalExpression(node); case 174: - return emitSpreadElementExpression(node); - case 173: - return emitYieldExpression(node); - case 176: - return; + return emitTemplateExpression(node); case 180: - case 207: - return emitBlock(node); - case 181: - return emitVariableStatement(node); - case 182: - return write(";"); - case 183: - return emitExpressionStatement(node); - case 184: - return emitIfStatement(node); - case 185: - return emitDoStatement(node); - case 186: - return emitWhileStatement(node); - case 187: - return emitForStatement(node); - case 189: - case 188: - return emitForInOrForOfStatement(node); - case 190: - case 191: - return emitBreakOrContinueStatement(node); - case 192: - return emitReturnStatement(node); - case 193: - return emitWithStatement(node); - case 194: - return emitSwitchStatement(node); - case 221: - case 222: - return emitCaseOrDefaultClause(node); - case 195: - return emitLabelledStatement(node); - case 196: - return emitThrowStatement(node); - case 197: - return emitTryStatement(node); - case 224: - return emitCatchClause(node); - case 198: - return emitDebuggerStatement(node); - case 199: - return emitVariableDeclaration(node); - case 175: - return emitClassExpression(node); - case 202: - return emitClassDeclaration(node); - case 203: - return emitInterfaceDeclaration(node); - case 205: - return emitEnumDeclaration(node); + return emitTemplateSpan(node); + case 128: + return emitQualifiedName(node); + case 153: + return emitObjectBindingPattern(node); + case 154: + return emitArrayBindingPattern(node); + case 155: + return emitBindingElement(node); + case 156: + return emitArrayLiteral(node); + case 157: + return emitObjectLiteral(node); case 227: - return emitEnumMember(node); - case 206: - return emitModuleDeclaration(node); - case 210: - return emitImportDeclaration(node); - case 209: - return emitImportEqualsDeclaration(node); - case 216: - return emitExportDeclaration(node); - case 215: - return emitExportAssignment(node); + return emitPropertyAssignment(node); case 228: + return emitShorthandPropertyAssignment(node); + case 129: + return emitComputedPropertyName(node); + case 158: + return emitPropertyAccess(node); + case 159: + return emitIndexedAccess(node); + case 160: + return emitCallExpression(node); + case 161: + return emitNewExpression(node); + case 162: + return emitTaggedTemplateExpression(node); + case 163: + return emit(node.expression); + case 164: + return emitParenExpression(node); + case 203: + case 165: + case 166: + return emitFunctionDeclaration(node); + case 167: + return emitDeleteExpression(node); + case 168: + return emitTypeOfExpression(node); + case 169: + return emitVoidExpression(node); + case 170: + return emitPrefixUnaryExpression(node); + case 171: + return emitPostfixUnaryExpression(node); + case 172: + return emitBinaryExpression(node); + case 173: + return emitConditionalExpression(node); + case 176: + return emitSpreadElementExpression(node); + case 175: + return emitYieldExpression(node); + case 178: + return; + case 182: + case 209: + return emitBlock(node); + case 183: + return emitVariableStatement(node); + case 184: + return write(";"); + case 185: + return emitExpressionStatement(node); + case 186: + return emitIfStatement(node); + case 187: + return emitDoStatement(node); + case 188: + return emitWhileStatement(node); + case 189: + return emitForStatement(node); + case 191: + case 190: + return emitForInOrForOfStatement(node); + case 192: + case 193: + return emitBreakOrContinueStatement(node); + case 194: + return emitReturnStatement(node); + case 195: + return emitWithStatement(node); + case 196: + return emitSwitchStatement(node); + case 223: + case 224: + return emitCaseOrDefaultClause(node); + case 197: + return emitLabelledStatement(node); + case 198: + return emitThrowStatement(node); + case 199: + return emitTryStatement(node); + case 226: + return emitCatchClause(node); + case 200: + return emitDebuggerStatement(node); + case 201: + return emitVariableDeclaration(node); + case 177: + return emitClassExpression(node); + case 204: + return emitClassDeclaration(node); + case 205: + return emitInterfaceDeclaration(node); + case 207: + return emitEnumDeclaration(node); + case 229: + return emitEnumMember(node); + case 208: + return emitModuleDeclaration(node); + case 212: + return emitImportDeclaration(node); + case 211: + return emitImportEqualsDeclaration(node); + case 218: + return emitExportDeclaration(node); + case 217: + return emitExportAssignment(node); + case 230: return emitSourceFileNode(node); } } @@ -25988,7 +26349,7 @@ var ts; } function getLeadingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 228 || node.pos !== node.parent.pos) { + if (node.parent.kind === 230 || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { return getLeadingCommentsWithoutDetachedComments(); } @@ -26000,7 +26361,7 @@ var ts; } function getTrailingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 228 || node.end !== node.parent.end) { + if (node.parent.kind === 230 || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } @@ -26178,7 +26539,7 @@ var ts; } ts.createCompilerHost = createCompilerHost; function getPreEmitDiagnostics(program, sourceFile) { - var diagnostics = program.getSyntacticDiagnostics(sourceFile).concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics(sourceFile)); + var diagnostics = program.getOptionsDiagnostics().concat(program.getSyntacticDiagnostics(sourceFile), program.getGlobalDiagnostics(), program.getSemanticDiagnostics(sourceFile)); if (program.getCompilerOptions().declaration) { diagnostics.concat(program.getDeclarationDiagnostics(sourceFile)); } @@ -26211,16 +26572,17 @@ var ts; function createProgram(rootNames, options, host) { var program; var files = []; - var filesByName = {}; var diagnostics = ts.createDiagnosticCollection(); - var seenNoDefaultLib = options.noLib; var commonSourceDirectory; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; + var classifiableNames; + var skipDefaultLib = options.noLib; var start = new Date().getTime(); host = host || createCompilerHost(options); + var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); }); ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - if (!seenNoDefaultLib) { + if (!skipDefaultLib) { processRootFile(host.getDefaultLibFileName(options), true); } verifyCompilerOptions(); @@ -26230,11 +26592,12 @@ var ts; getSourceFiles: function () { return files; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, + getOptionsDiagnostics: getOptionsDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, getSemanticDiagnostics: getSemanticDiagnostics, getDeclarationDiagnostics: getDeclarationDiagnostics, - getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics, getTypeChecker: getTypeChecker, + getClassifiableNames: getClassifiableNames, getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker, getCommonSourceDirectory: function () { return commonSourceDirectory; }, emit: emit, @@ -26245,6 +26608,17 @@ var ts; getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); } }; return program; + function getClassifiableNames() { + if (!classifiableNames) { + getTypeChecker(); + classifiableNames = {}; + for (var _i = 0; _i < files.length; _i++) { + var sourceFile = files[_i]; + ts.copyMap(sourceFile.classifiableNames, classifiableNames); + } + } + return classifiableNames; + } function getEmitHost(writeFileCallback) { return { getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, @@ -26274,8 +26648,7 @@ var ts; return emitResult; } function getSourceFile(fileName) { - fileName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - return ts.hasProperty(filesByName, fileName) ? filesByName[fileName] : undefined; + return filesByName.get(fileName); } function getDiagnosticsHelper(sourceFile, getDiagnostics) { if (sourceFile) { @@ -26314,16 +26687,14 @@ var ts; return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); } } - function getCompilerOptionsDiagnostics() { + function getOptionsDiagnostics() { var allDiagnostics = []; ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function getGlobalDiagnostics() { - var typeChecker = getDiagnosticsProducingTypeChecker(); var allDiagnostics = []; - ts.addRange(allDiagnostics, typeChecker.getGlobalDiagnostics()); - ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); + ts.addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function hasExtension(fileName) { @@ -26357,14 +26728,17 @@ var ts; } } else { - if (options.allowNonTsExtensions && !findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd)) { - diagnostic = ts.Diagnostics.File_0_not_found; - diagnosticArgument = [fileName]; - } - else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, isDefaultLib, refFile, refPos, refEnd); })) { - diagnostic = ts.Diagnostics.File_0_not_found; - fileName += ".ts"; - diagnosticArgument = [fileName]; + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd); + if (!nonTsFile) { + if (options.allowNonTsExtensions) { + diagnostic = ts.Diagnostics.File_0_not_found; + diagnosticArgument = [fileName]; + } + else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, isDefaultLib, refFile, refPos, refEnd); })) { + diagnostic = ts.Diagnostics.File_0_not_found; + fileName += ".ts"; + diagnosticArgument = [fileName]; + } } } if (diagnostic) { @@ -26378,16 +26752,16 @@ var ts; } function findSourceFile(fileName, isDefaultLib, refFile, refStart, refLength) { var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - if (ts.hasProperty(filesByName, canonicalName)) { + if (filesByName.contains(canonicalName)) { return getSourceFileFromCache(fileName, canonicalName, false); } else { var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); - if (ts.hasProperty(filesByName, canonicalAbsolutePath)) { + if (filesByName.contains(canonicalAbsolutePath)) { return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); } - var file = filesByName[canonicalName] = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { if (refFile) { diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } @@ -26395,15 +26769,17 @@ var ts; diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } }); + filesByName.set(canonicalName, file); if (file) { - seenNoDefaultLib = seenNoDefaultLib || file.hasNoDefaultLib; - filesByName[canonicalAbsolutePath] = file; + skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; + filesByName.set(canonicalAbsolutePath, file); if (!options.noResolve) { var basePath = ts.getDirectoryPath(fileName); processReferencedFiles(file, basePath); processImportedModules(file, basePath); } if (isDefaultLib) { + file.isDefaultLib = true; files.unshift(file); } else { @@ -26413,7 +26789,7 @@ var ts; return file; } function getSourceFileFromCache(fileName, canonicalName, useAbsolutePath) { - var file = filesByName[canonicalName]; + var file = filesByName.get(canonicalName); if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { @@ -26431,7 +26807,7 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 210 || node.kind === 209 || node.kind === 216) { + if (node.kind === 212 || node.kind === 211 || node.kind === 218) { var moduleNameExpr = ts.getExternalModuleName(node); if (moduleNameExpr && moduleNameExpr.kind === 8) { var moduleNameText = moduleNameExpr.text; @@ -26452,7 +26828,7 @@ var ts; } } } - else if (node.kind === 206 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { + else if (node.kind === 208 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { ts.forEachChild(node.body, function (node) { if (ts.isExternalModuleImportEqualsDeclaration(node) && ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 8) { @@ -26710,9 +27086,14 @@ var ts; name: "noResolve", type: "boolean" }, + { + name: "skipDefaultLibCheck", + type: "boolean" + }, { name: "out", type: "string", + isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: ts.Diagnostics.FILE }, diff --git a/bin/tsserver.js b/bin/tsserver.js index 9c655a0b0c1..6f4c99b36a6 100644 --- a/bin/tsserver.js +++ b/bin/tsserver.js @@ -31,6 +31,36 @@ var ts; /// var ts; (function (ts) { + function createFileMap(getCanonicalFileName) { + var files = {}; + return { + get: get, + set: set, + contains: contains, + remove: remove, + forEachValue: forEachValueInMap + }; + function set(fileName, value) { + files[normalizeKey(fileName)] = value; + } + function get(fileName) { + return files[normalizeKey(fileName)]; + } + function contains(fileName) { + return hasProperty(files, normalizeKey(fileName)); + } + function remove(fileName) { + var key = normalizeKey(fileName); + delete files[key]; + } + function forEachValueInMap(f) { + forEachValue(files, f); + } + function normalizeKey(key) { + return getCanonicalFileName(normalizeSlashes(key)); + } + } + ts.createFileMap = createFileMap; function forEach(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -498,7 +528,7 @@ var ts; function getNormalizedPathComponents(path, currentDirectory) { path = normalizeSlashes(path); var rootLength = getRootLength(path); - if (rootLength == 0) { + if (rootLength === 0) { path = combinePaths(normalizeSlashes(currentDirectory), path); rootLength = getRootLength(path); } @@ -1116,14 +1146,26 @@ var ts; A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, - Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" }, - Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, + Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Modules are automatically in strict mode." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators are only available when targeting ECMAScript 6 or higher." }, Generators_are_not_allowed_in_an_ambient_context: { code: 1221, category: ts.DiagnosticCategory.Error, key: "Generators are not allowed in an ambient context." }, An_overload_signature_cannot_be_declared_as_a_generator: { code: 1222, category: ts.DiagnosticCategory.Error, key: "An overload signature cannot be declared as a generator." }, _0_tag_already_specified: { code: 1223, category: ts.DiagnosticCategory.Error, key: "'{0}' tag already specified." }, + Signature_0_must_have_a_type_predicate: { code: 1224, category: ts.DiagnosticCategory.Error, key: "Signature '{0}' must have a type predicate." }, + Cannot_find_parameter_0: { code: 1225, category: ts.DiagnosticCategory.Error, key: "Cannot find parameter '{0}'." }, + Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: ts.DiagnosticCategory.Error, key: "Type predicate '{0}' is not assignable to '{1}'." }, + Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' is not in the same position as parameter '{1}'." }, + A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: ts.DiagnosticCategory.Error, key: "A type predicate is only allowed in return type position for functions and methods." }, + A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: ts.DiagnosticCategory.Error, key: "A type predicate cannot reference a rest parameter." }, + A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: ts.DiagnosticCategory.Error, key: "A type predicate cannot reference element '{0}' in a binding pattern." }, + An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: ts.DiagnosticCategory.Error, key: "An export assignment can only be used in a module." }, + An_import_declaration_can_only_be_used_in_a_namespace_or_module: { code: 1232, category: ts.DiagnosticCategory.Error, key: "An import declaration can only be used in a namespace or module." }, + An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: ts.DiagnosticCategory.Error, key: "An export declaration can only be used in a module." }, + An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: ts.DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." }, + A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: ts.DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -1317,6 +1359,11 @@ var ts; Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, No_best_common_type_exists_among_yield_expressions: { code: 2504, category: ts.DiagnosticCategory.Error, key: "No best common type exists among yield expressions." }, A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: ts.DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." }, + _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: ts.DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own base expression." }, + Type_0_is_not_a_constructor_function_type: { code: 2507, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not a constructor function type." }, + No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: ts.DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." }, + Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: ts.DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." }, + Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: ts.DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -1526,7 +1573,7 @@ var ts; "false": 80, "finally": 81, "for": 82, - "from": 125, + "from": 126, "function": 83, "get": 116, "if": 84, @@ -1535,36 +1582,37 @@ var ts; "in": 86, "instanceof": 87, "interface": 103, + "is": 117, "let": 104, - "module": 117, - "namespace": 118, + "module": 118, + "namespace": 119, "new": 88, "null": 89, - "number": 120, + "number": 121, "package": 105, "private": 106, "protected": 107, "public": 108, - "require": 119, + "require": 120, "return": 90, - "set": 121, + "set": 122, "static": 109, - "string": 122, + "string": 123, "super": 91, "switch": 92, - "symbol": 123, + "symbol": 124, "this": 93, "throw": 94, "true": 95, "try": 96, - "type": 124, + "type": 125, "typeof": 97, "var": 98, "void": 99, "while": 100, "with": 101, "yield": 110, - "of": 126, + "of": 127, "{": 14, "}": 15, "(": 16, @@ -1767,6 +1815,25 @@ var ts; return ch >= 48 && ch <= 55; } ts.isOctalDigit = isOctalDigit; + function couldStartTrivia(text, pos) { + var ch = text.charCodeAt(pos); + switch (ch) { + case 13: + case 10: + case 9: + case 11: + case 12: + case 32: + case 47: + case 60: + case 61: + case 62: + return true; + default: + return ch > 127; + } + } + ts.couldStartTrivia = couldStartTrivia; function skipTrivia(text, pos, stopAfterLineBreak) { while (true) { var ch = text.charCodeAt(pos); @@ -2229,7 +2296,7 @@ var ts; error(ts.Diagnostics.Unexpected_end_of_text); isInvalidExtendedEscape = true; } - else if (text.charCodeAt(pos) == 125) { + else if (text.charCodeAt(pos) === 125) { pos++; } else { @@ -2849,9 +2916,14 @@ var ts; name: "noResolve", type: "boolean" }, + { + name: "skipDefaultLibCheck", + type: "boolean" + }, { name: "out", type: "string", + isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: ts.Diagnostics.FILE }, @@ -3152,7 +3224,7 @@ var ts; ts.getDeclarationOfKind = getDeclarationOfKind; var stringWriters = []; function getSingleLineStringWriter() { - if (stringWriters.length == 0) { + if (stringWriters.length === 0) { var str = ""; var writeText = function (text) { return str += text; }; return { @@ -3199,7 +3271,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 228) { + while (node && node.kind !== 230) { node = node.parent; } return node; @@ -3288,15 +3360,15 @@ var ts; return current; } switch (current.kind) { - case 228: + case 230: + case 210: + case 226: case 208: - case 224: - case 206: - case 187: - case 188: case 189: + case 190: + case 191: return current; - case 180: + case 182: if (!isFunctionLike(current.parent)) { return current; } @@ -3307,9 +3379,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 199 && + declaration.kind === 201 && declaration.parent && - declaration.parent.kind === 224; + declaration.parent.kind === 226; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3345,22 +3417,22 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 228: + case 230: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 199: - case 153: - case 202: - case 175: - case 203: - case 206: - case 205: - case 227: case 201: - case 163: + case 155: + case 204: + case 177: + case 205: + case 208: + case 207: + case 229: + case 203: + case 165: errorNode = node.name; break; } @@ -3382,11 +3454,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 205 && isConst(node); + return node.kind === 207 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 153 || isBindingPattern(node))) { + while (node && (node.kind === 155 || isBindingPattern(node))) { node = node.parent; } return node; @@ -3394,14 +3466,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 199) { + if (node.kind === 201) { node = node.parent; } - if (node && node.kind === 200) { + if (node && node.kind === 202) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 181) { + if (node && node.kind === 183) { flags |= node.flags; } return flags; @@ -3416,11 +3488,11 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 183 && node.expression.kind === 8; + return node.kind === 185 && node.expression.kind === 8; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - if (node.kind === 130 || node.kind === 129) { + if (node.kind === 131 || node.kind === 130) { return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); } else { @@ -3439,68 +3511,68 @@ var ts; ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (142 <= node.kind && node.kind <= 150) { + if (144 <= node.kind && node.kind <= 152) { return true; } switch (node.kind) { case 112: - case 120: - case 122: - case 113: + case 121: case 123: + case 113: + case 124: return true; case 99: - return node.parent.kind !== 167; + return node.parent.kind !== 169; case 8: - return node.parent.kind === 130; - case 177: - return true; + return node.parent.kind === 131; + case 179: + return !isExpressionWithTypeArgumentsInClassExtendsClause(node); case 65: - if (node.parent.kind === 127 && node.parent.right === node) { + if (node.parent.kind === 128 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 156 && node.parent.name === node) { + else if (node.parent.kind === 158 && node.parent.name === node) { node = node.parent; } - case 127: - case 156: - ts.Debug.assert(node.kind === 65 || node.kind === 127 || node.kind === 156, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 128: + case 158: + ts.Debug.assert(node.kind === 65 || node.kind === 128 || node.kind === 158, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_1 = node.parent; - if (parent_1.kind === 145) { + if (parent_1.kind === 147) { return false; } - if (142 <= parent_1.kind && parent_1.kind <= 150) { + if (144 <= parent_1.kind && parent_1.kind <= 152) { return true; } switch (parent_1.kind) { - case 177: - return true; - case 129: - return node === parent_1.constraint; - case 133: - case 132: + case 179: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); case 130: - case 199: - return node === parent_1.type; + return node === parent_1.constraint; + case 134: + case 133: + case 131: case 201: - case 163: - case 164: + return node === parent_1.type; + case 203: + case 165: + case 166: + case 137: case 136: case 135: - case 134: - case 137: case 138: - return node === parent_1.type; case 139: + return node === parent_1.type; case 140: case 141: + case 142: return node === parent_1.type; - case 161: + case 163: return node === parent_1.type; - case 158: - case 159: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 160: + case 161: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 162: return false; } } @@ -3511,23 +3583,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 192: + case 194: return visitor(node); - case 208: - case 180: - case 184: - case 185: + case 210: + case 182: case 186: case 187: case 188: case 189: - case 193: - case 194: - case 221: - case 222: + case 190: + case 191: case 195: - case 197: + case 196: + case 223: case 224: + case 197: + case 199: + case 226: return ts.forEachChild(node, traverse); } } @@ -3537,22 +3609,22 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 173: + case 175: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } + case 207: case 205: - case 203: + case 208: case 206: case 204: - case 202: return; default: if (isFunctionLike(node)) { var name_4 = node.name; - if (name_4 && name_4.kind === 128) { + if (name_4 && name_4.kind === 129) { traverse(name_4.expression); return; } @@ -3567,14 +3639,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 153: + case 155: + case 229: + case 131: case 227: - case 130: - case 225: + case 134: case 133: - case 132: - case 226: - case 199: + case 228: + case 201: return true; } } @@ -3584,8 +3656,8 @@ var ts; function isAccessor(node) { if (node) { switch (node.kind) { - case 137: case 138: + case 139: return true; } } @@ -3594,26 +3666,26 @@ var ts; ts.isAccessor = isAccessor; function isClassLike(node) { if (node) { - return node.kind === 202 || node.kind === 175; + return node.kind === 204 || node.kind === 177; } } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 136: - case 163: - case 201: - case 164: - case 135: - case 134: case 137: + case 165: + case 203: + case 166: + case 136: + case 135: case 138: case 139: case 140: case 141: - case 143: - case 144: + case 142: + case 145: + case 146: return true; } } @@ -3621,11 +3693,11 @@ var ts; } ts.isFunctionLike = isFunctionLike; function isFunctionBlock(node) { - return node && node.kind === 180 && isFunctionLike(node.parent); + return node && node.kind === 182 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 135 && node.parent.kind === 155; + return node && node.kind === 136 && node.parent.kind === 157; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -3644,36 +3716,36 @@ var ts; return undefined; } switch (node.kind) { - case 128: - if (node.parent.parent.kind === 202) { + case 129: + if (node.parent.parent.kind === 204) { return node; } node = node.parent; break; - case 131: - if (node.parent.kind === 130 && isClassElement(node.parent.parent)) { + case 132: + if (node.parent.kind === 131 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 164: + case 166: if (!includeArrowFunctions) { continue; } - case 201: - case 163: - case 206: - case 133: - case 132: - case 135: + case 203: + case 165: + case 208: case 134: + case 133: case 136: + case 135: case 137: case 138: - case 205: - case 228: + case 139: + case 207: + case 230: return node; } } @@ -3685,40 +3757,40 @@ var ts; if (!node) return node; switch (node.kind) { - case 128: - if (node.parent.parent.kind === 202) { + case 129: + if (node.parent.parent.kind === 204) { return node; } node = node.parent; break; - case 131: - if (node.parent.kind === 130 && isClassElement(node.parent.parent)) { + case 132: + if (node.parent.kind === 131 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 201: - case 163: - case 164: + case 203: + case 165: + case 166: if (!includeFunctions) { continue; } - case 133: - case 132: - case 135: case 134: + case 133: case 136: + case 135: case 137: case 138: + case 139: return node; } } } ts.getSuperContainer = getSuperContainer; function getInvokedExpression(node) { - if (node.kind === 160) { + if (node.kind === 162) { return node.tag; } return node.expression; @@ -3726,40 +3798,40 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 202: + case 204: return true; - case 133: - return node.parent.kind === 202; - case 130: - return node.parent.body && node.parent.parent.kind === 202; - case 137: + case 134: + return node.parent.kind === 204; + case 131: + return node.parent.body && node.parent.parent.kind === 204; case 138: - case 135: - return node.body && node.parent.kind === 202; + case 139: + case 136: + return node.body && node.parent.kind === 204; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 202: + case 204: if (node.decorators) { return true; } return false; - case 133: - case 130: + case 134: + case 131: if (node.decorators) { return true; } return false; - case 137: + case 138: if (node.body && node.decorators) { return true; } return false; - case 135: - case 138: + case 136: + case 139: if (node.body && node.decorators) { return true; } @@ -3770,10 +3842,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 202: + case 204: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 135: - case 138: + case 136: + case 139: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -3791,8 +3863,6 @@ var ts; case 95: case 80: case 9: - case 154: - case 155: case 156: case 157: case 158: @@ -3801,71 +3871,75 @@ var ts; case 161: case 162: case 163: - case 175: case 164: - case 167: case 165: + case 177: case 166: - case 168: case 169: + case 167: + case 168: case 170: case 171: - case 174: case 172: - case 10: - case 176: case 173: + case 176: + case 174: + case 10: + case 178: + case 175: return true; - case 127: - while (node.parent.kind === 127) { + case 128: + while (node.parent.kind === 128) { node = node.parent; } - return node.parent.kind === 145; + return node.parent.kind === 147; case 65: - if (node.parent.kind === 145) { + if (node.parent.kind === 147) { return true; } case 7: case 8: var parent_2 = node.parent; switch (parent_2.kind) { - case 199: - case 130: + case 201: + case 131: + case 134: case 133: - case 132: + case 229: case 227: - case 225: - case 153: + case 155: return parent_2.initializer === node; - case 183: - case 184: case 185: case 186: - case 192: - case 193: - case 194: - case 221: - case 196: - case 194: - return parent_2.expression === node; case 187: + case 188: + case 194: + case 195: + case 196: + case 223: + case 198: + case 196: + return parent_2.expression === node; + case 189: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 200) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 202) || forStatement.condition === node || forStatement.incrementor === node; - case 188: - case 189: + case 190: + case 191: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 200) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 202) || forInStatement.expression === node; - case 161: + case 163: return node === parent_2.expression; - case 178: + case 180: return node === parent_2.expression; - case 128: + case 129: return node === parent_2.expression; - case 131: + case 132: return true; + case 179: + return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { return true; @@ -3882,7 +3956,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 209 && node.moduleReference.kind === 220; + return node.kind === 211 && node.moduleReference.kind === 222; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -3891,20 +3965,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 209 && node.moduleReference.kind !== 220; + return node.kind === 211 && node.moduleReference.kind !== 222; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 210) { + if (node.kind === 212) { return node.moduleSpecifier; } - if (node.kind === 209) { + if (node.kind === 211) { var reference = node.moduleReference; - if (reference.kind === 220) { + if (reference.kind === 222) { return reference.expression; } } - if (node.kind === 216) { + if (node.kind === 218) { return node.moduleSpecifier; } } @@ -3912,15 +3986,15 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 130: + case 131: return node.questionToken !== undefined; + case 136: case 135: - case 134: return node.questionToken !== undefined; - case 226: - case 225: + case 228: + case 227: + case 134: case 133: - case 132: return node.questionToken !== undefined; } } @@ -3928,9 +4002,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 241 && + return node.kind === 243 && node.parameters.length > 0 && - node.parameters[0].type.kind === 243; + node.parameters[0].type.kind === 245; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -3944,15 +4018,15 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 249); + return getJSDocTag(node, 251); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 248); + return getJSDocTag(node, 250); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 250); + return getJSDocTag(node, 252); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { @@ -3961,7 +4035,7 @@ var ts; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 247) { + if (t.kind === 249) { var parameterTag = t; var name_5 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_5.text === parameterName) { @@ -3980,12 +4054,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 64) { - if (node.type && node.type.kind === 242) { + if (node.type && node.type.kind === 244) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 242; + return paramTag.typeExpression.type.kind === 244; } } return node.dotDotDotToken !== undefined; @@ -4006,7 +4080,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 152 || node.kind === 151); + return !!node && (node.kind === 154 || node.kind === 153); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -4021,33 +4095,33 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 164: - case 153: - case 202: - case 136: - case 205: - case 227: - case 218: - case 201: - case 163: - case 137: - case 211: - case 209: - case 214: - case 203: - case 135: - case 134: - case 206: - case 212: - case 130: - case 225: - case 133: - case 132: - case 138: - case 226: + case 166: + case 155: case 204: - case 129: - case 199: + case 137: + case 207: + case 229: + case 220: + case 203: + case 165: + case 138: + case 213: + case 211: + case 216: + case 205: + case 136: + case 135: + case 208: + case 214: + case 131: + case 227: + case 134: + case 133: + case 139: + case 228: + case 206: + case 130: + case 201: return true; } return false; @@ -4055,25 +4129,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 191: - case 190: - case 198: - case 185: - case 183: - case 182: - case 188: - case 189: - case 187: - case 184: - case 195: - case 192: - case 194: - case 94: - case 197: - case 181: - case 186: case 193: - case 215: + case 192: + case 200: + case 187: + case 185: + case 184: + case 190: + case 191: + case 189: + case 186: + case 197: + case 194: + case 196: + case 94: + case 199: + case 183: + case 188: + case 195: + case 217: return true; default: return false; @@ -4082,13 +4156,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 136: - case 133: - case 135: case 137: - case 138: case 134: - case 141: + case 136: + case 138: + case 139: + case 135: + case 142: return true; default: return false; @@ -4100,7 +4174,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 214 || parent.kind === 218) { + if (parent.kind === 216 || parent.kind === 220) { if (parent.propertyName) { return true; } @@ -4111,13 +4185,43 @@ var ts; return false; } ts.isDeclarationName = isDeclarationName; + function isIdentifierName(node) { + var parent = node.parent; + switch (parent.kind) { + case 134: + case 133: + case 136: + case 135: + case 138: + case 139: + case 229: + case 227: + case 158: + return parent.name === node; + case 128: + if (parent.right === node) { + while (parent.kind === 128) { + parent = parent.parent; + } + return parent.kind === 147; + } + return false; + case 155: + case 216: + return parent.propertyName === node; + case 220: + return true; + } + return false; + } + ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 209 || - node.kind === 211 && !!node.name || - node.kind === 212 || + return node.kind === 211 || + node.kind === 213 && !!node.name || node.kind === 214 || - node.kind === 218 || - node.kind === 215 && node.expression.kind === 65; + node.kind === 216 || + node.kind === 220 || + node.kind === 217 && node.expression.kind === 65; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { @@ -4200,7 +4304,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 66 <= token && token <= 126; + return 66 <= token && token <= 127; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -4209,19 +4313,19 @@ var ts; ts.isTrivia = isTrivia; function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 128 && + declaration.name.kind === 129 && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; function isWellKnownSymbolSyntactically(node) { - return node.kind === 156 && isESSymbolIdentifier(node.expression); + return node.kind === 158 && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { if (name.kind === 65 || name.kind === 8 || name.kind === 7) { return name.text; } - if (name.kind === 128) { + if (name.kind === 129) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -4256,18 +4360,18 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 130; + return root.kind === 131; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 153) { + while (node.kind === 155) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 206 || n.kind === 228; + return isFunctionLike(n) || n.kind === 208 || n.kind === 230; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -4491,7 +4595,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 136 && nodeIsPresent(member.body)) { + if (member.kind === 137 && nodeIsPresent(member.body)) { return member; } }); @@ -4514,10 +4618,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 137) { + if (accessor.kind === 138) { getAccessor = accessor; } - else if (accessor.kind === 138) { + else if (accessor.kind === 139) { setAccessor = accessor; } else { @@ -4526,7 +4630,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 137 || member.kind === 138) + if ((member.kind === 138 || member.kind === 139) && (member.flags & 128) === (accessor.flags & 128)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -4537,10 +4641,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 137 && !getAccessor) { + if (member.kind === 138 && !getAccessor) { getAccessor = member; } - if (member.kind === 138 && !setAccessor) { + if (member.kind === 139 && !setAccessor) { setAccessor = member; } } @@ -4661,22 +4765,22 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 156: - case 157: - case 159: case 158: + case 159: + case 161: case 160: - case 154: case 162: - case 155: - case 175: - case 163: + case 156: + case 164: + case 157: + case 177: + case 165: case 65: case 9: case 7: case 8: case 10: - case 172: + case 174: case 80: case 89: case 93: @@ -4692,6 +4796,12 @@ var ts; return token >= 53 && token <= 64; } ts.isAssignmentOperator = isAssignmentOperator; + function isExpressionWithTypeArgumentsInClassExtendsClause(node) { + return node.kind === 179 && + node.parent.token === 79 && + node.parent.parent.kind === 204; + } + ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isSupportedExpressionWithTypeArguments(node) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } @@ -4700,7 +4810,7 @@ var ts; if (node.kind === 65) { return true; } - else if (node.kind === 156) { + else if (node.kind === 158) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -4708,8 +4818,8 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 127 && node.parent.right === node) || - (node.parent.kind === 156 && node.parent.name === node); + return (node.parent.kind === 128 && node.parent.right === node) || + (node.parent.kind === 158 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function getLocalSymbolForExportDefault(symbol) { @@ -4836,6 +4946,12 @@ var ts; return start <= textSpanEnd(span) && end >= span.start; } ts.textSpanIntersectsWith = textSpanIntersectsWith; + function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { + var end1 = start1 + length1; + var end2 = start2 + length2; + return start2 <= end1 && end2 >= start1; + } + ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; function textSpanIntersectsWithPosition(span, position) { return position <= textSpanEnd(span) && position >= span.start; } @@ -4906,9 +5022,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 129) { + if (d && d.kind === 130) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 203) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 205) { return current; } } @@ -4920,7 +5036,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(252); + var nodeConstructors = new Array(254); ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -4958,20 +5074,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 127: + case 128: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 129: + case 130: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 130: + case 131: + case 134: case 133: - case 132: - case 225: - case 226: - case 199: - case 153: + case 227: + case 228: + case 201: + case 155: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -4980,24 +5096,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 143: - case 144: - case 139: + case 145: + case 146: case 140: case 141: + case 142: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 135: - case 134: case 136: + case 135: case 137: case 138: - case 163: - case 201: - case 164: + case 139: + case 165: + case 203: + case 166: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -5008,263 +5124,267 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 142: + case 144: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 145: - return visitNode(cbNode, node.exprName); - case 146: - return visitNodes(cbNodes, node.members); + case 143: + return visitNode(cbNode, node.parameterName) || + visitNode(cbNode, node.type); case 147: - return visitNode(cbNode, node.elementType); + return visitNode(cbNode, node.exprName); case 148: - return visitNodes(cbNodes, node.elementTypes); + return visitNodes(cbNodes, node.members); case 149: - return visitNodes(cbNodes, node.types); + return visitNode(cbNode, node.elementType); case 150: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.elementTypes); case 151: + return visitNodes(cbNodes, node.types); case 152: - return visitNodes(cbNodes, node.elements); + return visitNode(cbNode, node.type); + case 153: case 154: return visitNodes(cbNodes, node.elements); - case 155: - return visitNodes(cbNodes, node.properties); case 156: + return visitNodes(cbNodes, node.elements); + case 157: + return visitNodes(cbNodes, node.properties); + case 158: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 157: + case 159: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 158: - case 159: + case 160: + case 161: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 160: + case 162: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 161: + case 163: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 162: - return visitNode(cbNode, node.expression); - case 165: - return visitNode(cbNode, node.expression); - case 166: + case 164: return visitNode(cbNode, node.expression); case 167: return visitNode(cbNode, node.expression); case 168: + return visitNode(cbNode, node.expression); + case 169: + return visitNode(cbNode, node.expression); + case 170: return visitNode(cbNode, node.operand); - case 173: + case 175: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 169: + case 171: return visitNode(cbNode, node.operand); - case 170: + case 172: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 171: + case 173: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 174: + case 176: return visitNode(cbNode, node.expression); - case 180: - case 207: + case 182: + case 209: return visitNodes(cbNodes, node.statements); - case 228: + case 230: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 181: + case 183: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 200: + case 202: return visitNodes(cbNodes, node.declarations); - case 183: + case 185: return visitNode(cbNode, node.expression); - case 184: + case 186: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 185: + case 187: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 186: + case 188: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 187: + case 189: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 188: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 189: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 190: - case 191: - return visitNode(cbNode, node.label); - case 192: - return visitNode(cbNode, node.expression); - case 193: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 191: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 192: + case 193: + return visitNode(cbNode, node.label); case 194: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.caseBlock); - case 208: - return visitNodes(cbNodes, node.clauses); - case 221: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.statements); - case 222: - return visitNodes(cbNodes, node.statements); + return visitNode(cbNode, node.expression); case 195: - return visitNode(cbNode, node.label) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 196: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.caseBlock); + case 210: + return visitNodes(cbNodes, node.clauses); + case 223: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.statements); + case 224: + return visitNodes(cbNodes, node.statements); case 197: + return visitNode(cbNode, node.label) || + visitNode(cbNode, node.statement); + case 198: + return visitNode(cbNode, node.expression); + case 199: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 224: + case 226: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 131: + case 132: return visitNode(cbNode, node.expression); - case 202: - case 175: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); - case 203: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); case 204: + case 177: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 205: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 227: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); case 206: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); + case 207: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 229: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 208: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 209: + case 211: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 210: + case 212: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 211: + case 213: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 212: + case 214: return visitNode(cbNode, node.name); - case 213: - case 217: + case 215: + case 219: return visitNodes(cbNodes, node.elements); - case 216: + case 218: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 214: - case 218: + case 216: + case 220: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 215: + case 217: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 172: + case 174: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 178: + case 180: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 128: + case 129: return visitNode(cbNode, node.expression); - case 223: + case 225: return visitNodes(cbNodes, node.types); - case 177: + case 179: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 220: + case 222: return visitNode(cbNode, node.expression); - case 219: + case 221: return visitNodes(cbNodes, node.decorators); - case 229: - return visitNode(cbNode, node.type); - case 233: - return visitNodes(cbNodes, node.types); - case 234: - return visitNodes(cbNodes, node.types); - case 232: - return visitNode(cbNode, node.elementType); - case 236: + case 231: return visitNode(cbNode, node.type); case 235: + return visitNodes(cbNodes, node.types); + case 236: + return visitNodes(cbNodes, node.types); + case 234: + return visitNode(cbNode, node.elementType); + case 238: return visitNode(cbNode, node.type); case 237: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.type); case 239: + return visitNodes(cbNodes, node.members); + case 241: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 240: - return visitNode(cbNode, node.type); - case 241: - return visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); case 242: return visitNode(cbNode, node.type); case 243: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); case 244: return visitNode(cbNode, node.type); - case 238: + case 245: + return visitNode(cbNode, node.type); + case 246: + return visitNode(cbNode, node.type); + case 240: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 245: - return visitNodes(cbNodes, node.tags); case 247: + return visitNodes(cbNodes, node.tags); + case 249: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 248: - return visitNode(cbNode, node.typeExpression); - case 249: - return visitNode(cbNode, node.typeExpression); case 250: + return visitNode(cbNode, node.typeExpression); + case 251: + return visitNode(cbNode, node.typeExpression); + case 252: return visitNodes(cbNodes, node.typeParameters); } } @@ -5338,7 +5458,7 @@ var ts; sourceFile = createSourceFile(fileName, languageVersion); token = nextToken(); processReferenceComments(sourceFile); - sourceFile.statements = parseList(0, true, parseSourceElement); + sourceFile.statements = parseList(0, parseStatement); ts.Debug.assert(token === 1); sourceFile.endOfFileToken = parseTokenNode(); setExternalModuleIndicator(sourceFile); @@ -5359,9 +5479,9 @@ var ts; return; function visit(node) { switch (node.kind) { - case 181: - case 201: - case 130: + case 183: + case 203: + case 131: addJSDocComment(node); } forEachChild(node, visit); @@ -5399,7 +5519,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(228, 0); + var sourceFile = createNode(230, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -5417,9 +5537,6 @@ var ts; contextFlags &= ~flag; } } - function setStrictModeContext(val) { - setContextFlag(val, 1); - } function setDisallowInContext(val) { setContextFlag(val, 2); } @@ -5490,9 +5607,6 @@ var ts; function inYieldContext() { return (contextFlags & 4) !== 0; } - function inStrictModeContext() { - return (contextFlags & 1) !== 0; - } function inGeneratorParameterContext() { return (contextFlags & 8) !== 0; } @@ -5701,7 +5815,7 @@ var ts; return token === 8 || token === 7 || isIdentifierOrKeyword(); } function parseComputedPropertyName() { - var node = createNode(128); + var node = createNode(129); parseExpected(18); var yieldContext = inYieldContext(); if (inGeneratorParameterContext()) { @@ -5755,23 +5869,21 @@ var ts; switch (parsingContext) { case 0: case 1: - return !(token === 22 && inErrorRecovery) && isStartOfModuleElement(); - case 2: - case 4: - return !(token === 22 && inErrorRecovery) && isStartOfStatement(); case 3: + return !(token === 22 && inErrorRecovery) && isStartOfStatement(); + case 2: return token === 67 || token === 73; - case 5: + case 4: return isStartOfTypeMember(); - case 6: + case 5: return lookAhead(isClassMemberStart) || (token === 22 && !inErrorRecovery); - case 7: + case 6: return token === 18 || isLiteralPropertyName(); - case 13: + case 12: return token === 18 || token === 35 || isLiteralPropertyName(); - case 10: + case 9: return isLiteralPropertyName(); - case 8: + case 7: if (token === 14) { return lookAhead(isValidHeritageClauseObjectLiteral); } @@ -5781,29 +5893,29 @@ var ts; else { return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); } - case 9: + case 8: return isIdentifierOrPattern(); - case 11: + case 10: return token === 23 || token === 21 || isIdentifierOrPattern(); - case 16: - return isIdentifier(); - case 12: - case 14: - return token === 23 || token === 21 || isStartOfExpression(); case 15: + return isIdentifier(); + case 11: + case 13: + return token === 23 || token === 21 || isStartOfExpression(); + case 14: return isStartOfParameter(); + case 16: case 17: - case 18: return token === 23 || isStartOfType(); - case 19: + case 18: return isHeritageClause(); - case 20: + case 19: return isIdentifierOrKeyword(); + case 20: case 21: - case 22: - case 24: - return JSDocParser.isJSDocType(); case 23: + return JSDocParser.isJSDocType(); + case 22: return isSimplePropertyName(); } ts.Debug.fail("Non-exhaustive case in 'isListElement'."); @@ -5838,41 +5950,40 @@ var ts; switch (kind) { case 1: case 2: - case 3: + case 4: case 5: case 6: - case 7: - case 13: - case 10: - case 20: - return token === 15; - case 4: - return token === 15 || token === 67 || token === 73; - case 8: - return token === 14 || token === 79 || token === 102; - case 9: - return isVariableDeclaratorListTerminator(); - case 16: - return token === 25 || token === 16 || token === 14 || token === 79 || token === 102; case 12: - return token === 17 || token === 22; - case 14: - case 18: - case 11: - return token === 19; - case 15: - return token === 17 || token === 19; - case 17: - return token === 25 || token === 16; + case 9: case 19: + return token === 15; + case 3: + return token === 15 || token === 67 || token === 73; + case 7: + return token === 14 || token === 79 || token === 102; + case 8: + return isVariableDeclaratorListTerminator(); + case 15: + return token === 25 || token === 16 || token === 14 || token === 79 || token === 102; + case 11: + return token === 17 || token === 22; + case 13: + case 17: + case 10: + return token === 19; + case 14: + return token === 17 || token === 19; + case 16: + return token === 25 || token === 16; + case 18: return token === 14 || token === 15; - case 21: + case 20: return token === 17 || token === 51 || token === 15; - case 22: + case 21: return token === 25 || token === 15; - case 24: - return token === 19 || token === 15; case 23: + return token === 19 || token === 15; + case 22: return token === 15; } } @@ -5889,7 +6000,7 @@ var ts; return false; } function isInSomeParsingContext() { - for (var kind = 0; kind < 25; kind++) { + for (var kind = 0; kind < 24; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, true) || isListTerminator(kind)) { return true; @@ -5898,43 +6009,25 @@ var ts; } return false; } - function parseList(kind, checkForStrictMode, parseElement) { + function parseList(kind, parseElement) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; var result = []; result.pos = getNodePos(); - var savedStrictModeContext = inStrictModeContext(); while (!isListTerminator(kind)) { if (isListElement(kind, false)) { var element = parseListElement(kind, parseElement); result.push(element); - if (checkForStrictMode && !inStrictModeContext()) { - if (ts.isPrologueDirective(element)) { - if (isUseStrictPrologueDirective(element)) { - setStrictModeContext(true); - checkForStrictMode = false; - } - } - else { - checkForStrictMode = false; - } - } continue; } if (abortParsingListOrMoveToNextToken(kind)) { break; } } - setStrictModeContext(savedStrictModeContext); result.end = getNodeEnd(); parsingContext = saveParsingContext; return result; } - function isUseStrictPrologueDirective(node) { - ts.Debug.assert(ts.isPrologueDirective(node)); - var nodeText = ts.getTextOfNodeFromSourceText(sourceText, node.expression); - return nodeText === '"use strict"' || nodeText === "'use strict'"; - } function parseListElement(parsingContext, parseElement) { var node = currentNode(parsingContext); if (node) { @@ -5959,7 +6052,7 @@ var ts; if (ts.containsParseError(node)) { return undefined; } - var nodeContextFlags = node.parserContextFlags & 63; + var nodeContextFlags = node.parserContextFlags & 62; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -5975,61 +6068,47 @@ var ts; } function canReuseNode(node, parsingContext) { switch (parsingContext) { - case 1: - return isReusableModuleElement(node); - case 6: - return isReusableClassMember(node); - case 3: - return isReusableSwitchClause(node); - case 2: - case 4: - return isReusableStatement(node); - case 7: - return isReusableEnumMember(node); case 5: + return isReusableClassMember(node); + case 2: + return isReusableSwitchClause(node); + case 0: + case 1: + case 3: + return isReusableStatement(node); + case 6: + return isReusableEnumMember(node); + case 4: return isReusableTypeMember(node); - case 9: - return isReusableVariableDeclaration(node); - case 15: - return isReusableParameter(node); - case 19: - case 16: - case 18: - case 17: - case 12: - case 13: case 8: - } - return false; - } - function isReusableModuleElement(node) { - if (node) { - switch (node.kind) { - case 210: - case 209: - case 216: - case 215: - case 202: - case 203: - case 206: - case 205: - return true; - } - return isReusableStatement(node); + return isReusableVariableDeclaration(node); + case 14: + return isReusableParameter(node); + case 18: + case 15: + case 17: + case 16: + case 11: + case 12: + case 7: } return false; } function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 136: - case 141: - case 135: case 137: + case 142: case 138: - case 133: - case 179: + case 139: + case 134: + case 181: return true; + case 136: + var methodDeclaration = node; + var nameIsConstructor = methodDeclaration.name.kind === 65 && + methodDeclaration.name.originalKeywordKind === 114; + return !nameIsConstructor; } } return false; @@ -6037,8 +6116,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 221: - case 222: + case 223: + case 224: return true; } } @@ -6047,56 +6126,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 201: - case 181: - case 180: - case 184: + case 203: case 183: - case 196: - case 192: - case 194: - case 191: - case 190: - case 188: - case 189: - case 187: - case 186: - case 193: case 182: - case 197: - case 195: + case 186: case 185: case 198: + case 194: + case 196: + case 193: + case 192: + case 190: + case 191: + case 189: + case 188: + case 195: + case 184: + case 199: + case 197: + case 187: + case 200: + case 212: + case 211: + case 218: + case 217: + case 208: + case 204: + case 205: + case 207: + case 206: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 227; + return node.kind === 229; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 140: - case 134: case 141: - case 132: - case 139: + case 135: + case 142: + case 133: + case 140: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 199) { + if (node.kind !== 201) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 130) { + if (node.kind !== 131) { return false; } var parameter = node; @@ -6114,29 +6202,28 @@ var ts; switch (context) { case 0: return ts.Diagnostics.Declaration_or_statement_expected; case 1: return ts.Diagnostics.Declaration_or_statement_expected; - case 2: return ts.Diagnostics.Statement_expected; - case 3: return ts.Diagnostics.case_or_default_expected; - case 4: return ts.Diagnostics.Statement_expected; - case 5: return ts.Diagnostics.Property_or_signature_expected; - case 6: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; - case 7: return ts.Diagnostics.Enum_member_expected; - case 8: return ts.Diagnostics.Expression_expected; - case 9: return ts.Diagnostics.Variable_declaration_expected; - case 10: return ts.Diagnostics.Property_destructuring_pattern_expected; - case 11: return ts.Diagnostics.Array_element_destructuring_pattern_expected; - case 12: return ts.Diagnostics.Argument_expression_expected; - case 13: return ts.Diagnostics.Property_assignment_expected; - case 14: return ts.Diagnostics.Expression_or_comma_expected; - case 15: return ts.Diagnostics.Parameter_declaration_expected; - case 16: return ts.Diagnostics.Type_parameter_declaration_expected; - case 17: return ts.Diagnostics.Type_argument_expected; - case 18: return ts.Diagnostics.Type_expected; - case 19: return ts.Diagnostics.Unexpected_token_expected; - case 20: return ts.Diagnostics.Identifier_expected; - case 21: return ts.Diagnostics.Parameter_declaration_expected; - case 22: return ts.Diagnostics.Type_argument_expected; - case 24: return ts.Diagnostics.Type_expected; - case 23: return ts.Diagnostics.Property_assignment_expected; + case 2: return ts.Diagnostics.case_or_default_expected; + case 3: return ts.Diagnostics.Statement_expected; + case 4: return ts.Diagnostics.Property_or_signature_expected; + case 5: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; + case 6: return ts.Diagnostics.Enum_member_expected; + case 7: return ts.Diagnostics.Expression_expected; + case 8: return ts.Diagnostics.Variable_declaration_expected; + case 9: return ts.Diagnostics.Property_destructuring_pattern_expected; + case 10: return ts.Diagnostics.Array_element_destructuring_pattern_expected; + case 11: return ts.Diagnostics.Argument_expression_expected; + case 12: return ts.Diagnostics.Property_assignment_expected; + case 13: return ts.Diagnostics.Expression_or_comma_expected; + case 14: return ts.Diagnostics.Parameter_declaration_expected; + case 15: return ts.Diagnostics.Type_parameter_declaration_expected; + case 16: return ts.Diagnostics.Type_argument_expected; + case 17: return ts.Diagnostics.Type_expected; + case 18: return ts.Diagnostics.Unexpected_token_expected; + case 19: return ts.Diagnostics.Identifier_expected; + case 20: return ts.Diagnostics.Parameter_declaration_expected; + case 21: return ts.Diagnostics.Type_argument_expected; + case 23: return ts.Diagnostics.Type_expected; + case 22: return ts.Diagnostics.Property_assignment_expected; } } ; @@ -6195,7 +6282,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(20)) { - var node = createNode(127, entity.pos); + var node = createNode(128, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -6203,7 +6290,7 @@ var ts; return entity; } function parseRightSideOfDot(allowIdentifierNames) { - if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord()) { + if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { return createMissingNode(65, true, ts.Diagnostics.Identifier_expected); @@ -6212,7 +6299,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(172); + var template = createNode(174); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 11, "Template head has wrong token kind"); var templateSpans = []; @@ -6225,7 +6312,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(178); + var span = createNode(180); span.expression = allowInAnd(parseExpression); var literal; if (token === 15) { @@ -6258,22 +6345,30 @@ var ts; } return node; } - function parseTypeReference() { - var node = createNode(142); - node.typeName = parseEntityName(false, ts.Diagnostics.Type_expected); + function parseTypeReferenceOrTypePredicate() { + var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); + if (typeName.kind === 65 && token === 117 && !scanner.hasPrecedingLineBreak()) { + nextToken(); + var node_1 = createNode(143, typeName.pos); + node_1.parameterName = typeName; + node_1.type = parseType(); + return finishNode(node_1); + } + var node = createNode(144, typeName.pos); + node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 24) { - node.typeArguments = parseBracketedList(17, parseType, 24, 25); + node.typeArguments = parseBracketedList(16, parseType, 24, 25); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(145); + var node = createNode(147); parseExpected(97); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(129); + var node = createNode(130); node.name = parseIdentifier(); if (parseOptional(79)) { if (isStartOfType() || !isStartOfExpression()) { @@ -6287,7 +6382,7 @@ var ts; } function parseTypeParameters() { if (token === 24) { - return parseBracketedList(16, parseTypeParameter, 24, 25); + return parseBracketedList(15, parseTypeParameter, 24, 25); } } function parseParameterType() { @@ -6308,7 +6403,7 @@ var ts; } } function parseParameter() { - var node = createNode(130); + var node = createNode(131); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(21); @@ -6342,7 +6437,7 @@ var ts; var savedGeneratorParameterContext = inGeneratorParameterContext(); setYieldContext(yieldAndGeneratorParameterContext); setGeneratorParameterContext(yieldAndGeneratorParameterContext); - var result = parseDelimitedList(15, parseParameter); + var result = parseDelimitedList(14, parseParameter); setYieldContext(savedYieldContext); setGeneratorParameterContext(savedGeneratorParameterContext); if (!parseExpected(17) && requireCompleteParameterList) { @@ -6360,7 +6455,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 140) { + if (kind === 141) { parseExpected(88); } fillSignature(51, false, false, node); @@ -6400,10 +6495,10 @@ var ts; return token === 51 || token === 23 || token === 19; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(141, fullStart); + var node = createNode(142, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.parameters = parseBracketedList(15, parseParameter, 18, 19); + node.parameters = parseBracketedList(14, parseParameter, 18, 19); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); @@ -6413,7 +6508,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(50); if (token === 16 || token === 24) { - var method = createNode(134, fullStart); + var method = createNode(135, fullStart); method.name = name; method.questionToken = questionToken; fillSignature(51, false, false, method); @@ -6421,7 +6516,7 @@ var ts; return finishNode(method); } else { - var property = createNode(132, fullStart); + var property = createNode(133, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -6463,14 +6558,14 @@ var ts; switch (token) { case 16: case 24: - return parseSignatureMember(139); + return parseSignatureMember(140); case 18: return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); case 88: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(140); + return parseSignatureMember(141); } case 8: case 7: @@ -6500,14 +6595,14 @@ var ts; return token === 16 || token === 24; } function parseTypeLiteral() { - var node = createNode(146); + var node = createNode(148); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; if (parseExpected(14)) { - members = parseList(5, false, parseTypeMember); + members = parseList(4, parseTypeMember); parseExpected(15); } else { @@ -6516,12 +6611,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(148); - node.elementTypes = parseBracketedList(18, parseType, 18, 19); + var node = createNode(150); + node.elementTypes = parseBracketedList(17, parseType, 18, 19); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(150); + var node = createNode(152); parseExpected(16); node.type = parseType(); parseExpected(17); @@ -6529,7 +6624,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 144) { + if (kind === 146) { parseExpected(88); } fillSignature(32, false, false, node); @@ -6542,12 +6637,12 @@ var ts; function parseNonArrayType() { switch (token) { case 112: - case 122: - case 120: - case 113: case 123: + case 121: + case 113: + case 124: var node = tryParse(parseKeywordAndNoDot); - return node || parseTypeReference(); + return node || parseTypeReferenceOrTypePredicate(); case 99: return parseTokenNode(); case 97: @@ -6559,16 +6654,16 @@ var ts; case 16: return parseParenthesizedType(); default: - return parseTypeReference(); + return parseTypeReferenceOrTypePredicate(); } } function isStartOfType() { switch (token) { case 112: - case 122: - case 120: - case 113: case 123: + case 121: + case 113: + case 124: case 99: case 97: case 14: @@ -6590,7 +6685,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(18)) { parseExpected(19); - var node = createNode(147, type.pos); + var node = createNode(149, type.pos); node.elementType = type; type = finishNode(node); } @@ -6605,7 +6700,7 @@ var ts; types.push(parseArrayTypeOrHigher()); } types.end = getNodeEnd(); - var node = createNode(149, type.pos); + var node = createNode(151, type.pos); node.types = types; type = finishNode(node); } @@ -6650,10 +6745,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(143); + return parseFunctionOrConstructorType(145); } if (token === 88) { - return parseFunctionOrConstructorType(144); + return parseFunctionOrConstructorType(146); } return parseUnionTypeOrHigher(); } @@ -6774,10 +6869,7 @@ var ts; if (inYieldContext()) { return true; } - if (inStrictModeContext()) { - return true; - } - return lookAhead(nextTokenIsIdentifierOnSameLine); + return lookAhead(nextTokenIsIdentifierOrKeywordOrNumberOnSameLine); } return false; } @@ -6786,7 +6878,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(173); + var node = createNode(175); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token === 35 || isStartOfExpression())) { @@ -6800,8 +6892,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 32, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(164, identifier.pos); - var parameter = createNode(130, identifier.pos); + var node = createNode(166, identifier.pos); + var parameter = createNode(131, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -6879,7 +6971,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(164); + var node = createNode(166); fillSignature(51, false, !allowAmbiguity, node); if (!node.parameters) { return undefined; @@ -6907,7 +6999,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(171, leftOperand.pos); + var node = createNode(173, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -6920,7 +7012,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 86 || t === 126; + return t === 86 || t === 127; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -6981,33 +7073,33 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(170, left.pos); + var node = createNode(172, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(168); + var node = createNode(170); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(165); + var node = createNode(167); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(166); + var node = createNode(168); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(167); + var node = createNode(169); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -7037,7 +7129,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token === 38 || token === 39) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(169, expression.pos); + var node = createNode(171, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -7060,14 +7152,14 @@ var ts; if (token === 16 || token === 20) { return expression; } - var node = createNode(156, expression.pos); + var node = createNode(158, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(20, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } function parseTypeAssertion() { - var node = createNode(161); + var node = createNode(163); parseExpected(24); node.type = parseType(); parseExpected(25); @@ -7078,7 +7170,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(20); if (dotToken) { - var propertyAccess = createNode(156, expression.pos); + var propertyAccess = createNode(158, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); @@ -7086,7 +7178,7 @@ var ts; continue; } if (!inDecoratorContext() && parseOptional(18)) { - var indexedAccess = createNode(157, expression.pos); + var indexedAccess = createNode(159, expression.pos); indexedAccess.expression = expression; if (token !== 19) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -7100,7 +7192,7 @@ var ts; continue; } if (token === 10 || token === 11) { - var tagExpression = createNode(160, expression.pos); + var tagExpression = createNode(162, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 10 ? parseLiteralNode() @@ -7119,7 +7211,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(158, expression.pos); + var callExpr = createNode(160, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -7127,7 +7219,7 @@ var ts; continue; } else if (token === 16) { - var callExpr = createNode(158, expression.pos); + var callExpr = createNode(160, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -7138,7 +7230,7 @@ var ts; } function parseArgumentList() { parseExpected(16); - var result = parseDelimitedList(12, parseArgumentExpression); + var result = parseDelimitedList(11, parseArgumentExpression); parseExpected(17); return result; } @@ -7146,7 +7238,7 @@ var ts; if (!parseOptional(24)) { return undefined; } - var typeArguments = parseDelimitedList(17, parseType); + var typeArguments = parseDelimitedList(16, parseType); if (!parseExpected(25)) { return undefined; } @@ -7217,42 +7309,42 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(162); + var node = createNode(164); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); return finishNode(node); } function parseSpreadElement() { - var node = createNode(174); + var node = createNode(176); parseExpected(21); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 21 ? parseSpreadElement() : - token === 23 ? createNode(176) : + token === 23 ? createNode(178) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(154); + var node = createNode(156); parseExpected(18); if (scanner.hasPrecedingLineBreak()) node.flags |= 512; - node.elements = parseDelimitedList(14, parseArgumentOrArrayLiteralElement); + node.elements = parseDelimitedList(13, parseArgumentOrArrayLiteralElement); parseExpected(19); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(116)) { - return parseAccessorDeclaration(137, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(121)) { return parseAccessorDeclaration(138, fullStart, decorators, modifiers); } + else if (parseContextualModifier(122)) { + return parseAccessorDeclaration(139, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { @@ -7272,13 +7364,13 @@ var ts; return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } if ((token === 23 || token === 15) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(226, fullStart); + var shorthandDeclaration = createNode(228, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(225, fullStart); + var propertyAssignment = createNode(227, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; parseExpected(51); @@ -7287,12 +7379,12 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(155); + var node = createNode(157); parseExpected(14); if (scanner.hasPrecedingLineBreak()) { node.flags |= 512; } - node.properties = parseDelimitedList(13, parseObjectLiteralElement, true); + node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); parseExpected(15); return finishNode(node); } @@ -7301,7 +7393,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(163); + var node = createNode(165); parseExpected(83); node.asteriskToken = parseOptionalToken(35); node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); @@ -7316,7 +7408,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(159); + var node = createNode(161); parseExpected(88); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -7325,10 +7417,10 @@ var ts; } return finishNode(node); } - function parseBlock(ignoreMissingOpenBrace, checkForStrictMode, diagnosticMessage) { - var node = createNode(180); + function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { + var node = createNode(182); if (parseExpected(14, diagnosticMessage) || ignoreMissingOpenBrace) { - node.statements = parseList(2, checkForStrictMode, parseStatement); + node.statements = parseList(1, parseStatement); parseExpected(15); } else { @@ -7343,7 +7435,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var block = parseBlock(ignoreMissingOpenBrace, true, diagnosticMessage); + var block = parseBlock(ignoreMissingOpenBrace, diagnosticMessage); if (saveDecoratorContext) { setDecoratorContext(true); } @@ -7351,12 +7443,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(182); + var node = createNode(184); parseExpected(22); return finishNode(node); } function parseIfStatement() { - var node = createNode(184); + var node = createNode(186); parseExpected(84); parseExpected(16); node.expression = allowInAnd(parseExpression); @@ -7366,7 +7458,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(185); + var node = createNode(187); parseExpected(75); node.statement = parseStatement(); parseExpected(100); @@ -7377,7 +7469,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(186); + var node = createNode(188); parseExpected(100); parseExpected(16); node.expression = allowInAnd(parseExpression); @@ -7400,21 +7492,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(86)) { - var forInStatement = createNode(188, pos); + var forInStatement = createNode(190, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(17); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(126)) { - var forOfStatement = createNode(189, pos); + else if (parseOptional(127)) { + var forOfStatement = createNode(191, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(17); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(187, pos); + var forStatement = createNode(189, pos); forStatement.initializer = initializer; parseExpected(22); if (token !== 22 && token !== 17) { @@ -7432,7 +7524,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 191 ? 66 : 71); + parseExpected(kind === 193 ? 66 : 71); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -7440,7 +7532,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(192); + var node = createNode(194); parseExpected(90); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -7449,7 +7541,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(193); + var node = createNode(195); parseExpected(101); parseExpected(16); node.expression = allowInAnd(parseExpression); @@ -7458,32 +7550,32 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(221); + var node = createNode(223); parseExpected(67); node.expression = allowInAnd(parseExpression); parseExpected(51); - node.statements = parseList(4, false, parseStatement); + node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(222); + var node = createNode(224); parseExpected(73); parseExpected(51); - node.statements = parseList(4, false, parseStatement); + node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { return token === 67 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(194); + var node = createNode(196); parseExpected(92); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); - var caseBlock = createNode(208, scanner.getStartPos()); + var caseBlock = createNode(210, scanner.getStartPos()); parseExpected(14); - caseBlock.clauses = parseList(3, false, parseCaseOrDefaultClause); + caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(15); node.caseBlock = finishNode(caseBlock); return finishNode(node); @@ -7491,35 +7583,35 @@ var ts; function parseThrowStatement() { // ThrowStatement[Yield] : // throw [no LineTerminator here]Expression[In, ?Yield]; - var node = createNode(196); + var node = createNode(198); parseExpected(94); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(197); + var node = createNode(199); parseExpected(96); - node.tryBlock = parseBlock(false, false); + node.tryBlock = parseBlock(false); node.catchClause = token === 68 ? parseCatchClause() : undefined; if (!node.catchClause || token === 81) { parseExpected(81); - node.finallyBlock = parseBlock(false, false); + node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(224); + var result = createNode(226); parseExpected(68); if (parseExpected(16)) { result.variableDeclaration = parseVariableDeclaration(); } parseExpected(17); - result.block = parseBlock(false, false); + result.block = parseBlock(false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(198); + var node = createNode(200); parseExpected(72); parseSemicolon(); return finishNode(node); @@ -7528,13 +7620,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 65 && parseOptional(51)) { - var labeledStatement = createNode(195, fullStart); + var labeledStatement = createNode(197, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(183, fullStart); + var expressionStatement = createNode(185, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -7547,7 +7639,11 @@ var ts; nextToken(); return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); } - function parseDeclarationFlags() { + function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { + nextToken(); + return (isIdentifierOrKeyword() || token === 7) && !scanner.hasPrecedingLineBreak(); + } + function isDeclaration() { while (true) { switch (token) { case 98: @@ -7556,28 +7652,30 @@ var ts; case 83: case 69: case 77: - return 1; + return true; case 103: - case 124: - nextToken(); - return isIdentifierOrKeyword() ? 1 : 0; - case 117: + case 125: + return nextTokenIsIdentifierOnSameLine(); case 118: + case 119: + return nextTokenIsIdentifierOrStringLiteralOnSameLine(); + case 115: nextToken(); - return isIdentifierOrKeyword() || token === 8 ? 2 : 0; + if (scanner.hasPrecedingLineBreak()) { + return false; + } + continue; case 85: nextToken(); return token === 8 || token === 35 || - token === 14 || isIdentifierOrKeyword() ? - 2 : 0; + token === 14 || isIdentifierOrKeyword(); case 78: nextToken(); if (token === 53 || token === 35 || token === 14 || token === 73) { - return 2; + return true; } continue; - case 115: case 108: case 106: case 107: @@ -7585,14 +7683,14 @@ var ts; nextToken(); continue; default: - return 0; + return false; } } } - function getDeclarationFlags() { - return lookAhead(parseDeclarationFlags); + function isStartOfDeclaration() { + return lookAhead(isDeclaration); } - function getStatementFlags() { + function isStartOfStatement() { switch (token) { case 52: case 22: @@ -7616,56 +7714,39 @@ var ts; case 72: case 68: case 81: - return 1; + return true; case 70: case 78: case 85: - return getDeclarationFlags(); + return isStartOfDeclaration(); case 115: case 103: - case 117: case 118: - case 124: - return getDeclarationFlags() || 1; + case 119: + case 125: + return true; case 108: case 106: case 107: case 109: - return getDeclarationFlags() || - (lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? 0 : 1); + return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: - return isStartOfExpression() ? 1 : 0; + return isStartOfExpression(); } } - function isStartOfStatement() { - return (getStatementFlags() & 1) !== 0; - } - function isStartOfModuleElement() { - return (getStatementFlags() & 3) !== 0; - } - function nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine() { + function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return !scanner.hasPrecedingLineBreak() && - (isIdentifier() || token === 14 || token === 18); + return isIdentifier() || token === 14 || token === 18; } function isLetDeclaration() { - return inStrictModeContext() || lookAhead(nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine); + return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } function parseStatement() { - return parseModuleElementOfKind(1); - } - function parseModuleElement() { - return parseModuleElementOfKind(3); - } - function parseSourceElement() { - return parseModuleElementOfKind(3); - } - function parseModuleElementOfKind(flags) { switch (token) { case 22: return parseEmptyStatement(); case 14: - return parseBlock(false, false); + return parseBlock(false); case 98: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); case 104: @@ -7686,9 +7767,9 @@ var ts; case 82: return parseForOrForInOrForOfStatement(); case 71: - return parseBreakOrContinueStatement(190); + return parseBreakOrContinueStatement(192); case 66: - return parseBreakOrContinueStatement(191); + return parseBreakOrContinueStatement(193); case 90: return parseReturnStatement(); case 101: @@ -7705,20 +7786,20 @@ var ts; return parseDebuggerStatement(); case 52: return parseDeclaration(); - case 70: + case 103: + case 125: + case 118: + case 119: case 115: + case 70: case 77: case 78: case 85: - case 103: - case 117: - case 118: case 106: case 107: case 108: case 109: - case 124: - if (getDeclarationFlags() & flags) { + if (isStartOfDeclaration()) { return parseDeclaration(); } break; @@ -7740,12 +7821,12 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 103: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 124: + case 125: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 77: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 117: case 118: + case 119: return parseModuleDeclaration(fullStart, decorators, modifiers); case 85: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); @@ -7755,8 +7836,8 @@ var ts; parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: - if (decorators) { - var node = createMissingNode(219, true, ts.Diagnostics.Declaration_expected); + if (decorators || modifiers) { + var node = createMissingNode(221, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -7764,6 +7845,10 @@ var ts; } } } + function nextTokenIsIdentifierOrStringLiteralOnSameLine() { + nextToken(); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 8); + } function parseFunctionBlockOrSemicolon(isGenerator, diagnosticMessage) { if (token !== 14 && canParseSemicolon()) { parseSemicolon(); @@ -7773,16 +7858,16 @@ var ts; } function parseArrayBindingElement() { if (token === 23) { - return createNode(176); + return createNode(178); } - var node = createNode(153); + var node = createNode(155); node.dotDotDotToken = parseOptionalToken(21); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(153); + var node = createNode(155); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); if (tokenIsIdentifier && token !== 51) { @@ -7797,16 +7882,16 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(151); + var node = createNode(153); parseExpected(14); - node.elements = parseDelimitedList(10, parseObjectBindingElement); + node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(15); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(152); + var node = createNode(154); parseExpected(18); - node.elements = parseDelimitedList(11, parseArrayBindingElement); + node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(19); return finishNode(node); } @@ -7823,7 +7908,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(199); + var node = createNode(201); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -7832,7 +7917,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(200); + var node = createNode(202); switch (token) { case 98: break; @@ -7846,13 +7931,13 @@ var ts; ts.Debug.fail(); } nextToken(); - if (token === 126 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 127 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { var savedDisallowIn = inDisallowInContext(); setDisallowInContext(inForStatementInitializer); - node.declarations = parseDelimitedList(9, parseVariableDeclaration); + node.declarations = parseDelimitedList(8, parseVariableDeclaration); setDisallowInContext(savedDisallowIn); } return finishNode(node); @@ -7861,7 +7946,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 17; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(181, fullStart); + var node = createNode(183, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -7869,7 +7954,7 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(201, fullStart); + var node = createNode(203, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(83); @@ -7880,7 +7965,7 @@ var ts; return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(136, pos); + var node = createNode(137, pos); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(114); @@ -7889,7 +7974,7 @@ var ts; return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(135, fullStart); + var method = createNode(136, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -7900,7 +7985,7 @@ var ts; return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(133, fullStart); + var property = createNode(134, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -7969,7 +8054,7 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 121 || idToken === 116) { + if (!ts.isKeyword(idToken) || idToken === 122 || idToken === 116) { return true; } switch (token) { @@ -7996,7 +8081,7 @@ var ts; decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(131, decoratorStart); + var decorator = createNode(132, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -8029,7 +8114,7 @@ var ts; } function parseClassElement() { if (token === 22) { - var result = createNode(179); + var result = createNode(181); nextToken(); return finishNode(result); } @@ -8053,21 +8138,19 @@ var ts; token === 18) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } - if (decorators) { + if (decorators || modifiers) { var name_6 = createMissingNode(65, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_6, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 175); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 177); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 202); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 204); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { - var savedStrictModeContext = inStrictModeContext(); - setStrictModeContext(true); var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); @@ -8084,9 +8167,7 @@ var ts; else { node.members = createMissingList(); } - var finishedNode = finishNode(node); - setStrictModeContext(savedStrictModeContext); - return finishedNode; + return finishNode(node); } function parseHeritageClauses(isClassHeritageClause) { // ClassTail[Yield,GeneratorParameter] : See 14.5 @@ -8100,23 +8181,23 @@ var ts; return undefined; } function parseHeritageClausesWorker() { - return parseList(19, false, parseHeritageClause); + return parseList(18, parseHeritageClause); } function parseHeritageClause() { if (token === 79 || token === 102) { - var node = createNode(223); + var node = createNode(225); node.token = token; nextToken(); - node.types = parseDelimitedList(8, parseExpressionWithTypeArguments); + node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); return finishNode(node); } return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(177); + var node = createNode(179); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 24) { - node.typeArguments = parseBracketedList(17, parseType, 24, 25); + node.typeArguments = parseBracketedList(16, parseType, 24, 25); } return finishNode(node); } @@ -8124,10 +8205,10 @@ var ts; return token === 79 || token === 102; } function parseClassMembers() { - return parseList(6, false, parseClassElement); + return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(203, fullStart); + var node = createNode(205, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(103); @@ -8138,30 +8219,31 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(204, fullStart); + var node = createNode(206, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(124); + parseExpected(125); node.name = parseIdentifier(); + node.typeParameters = parseTypeParameters(); parseExpected(53); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNode(227, scanner.getStartPos()); + var node = createNode(229, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(205, fullStart); + var node = createNode(207, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(77); node.name = parseIdentifier(); if (parseExpected(14)) { - node.members = parseDelimitedList(7, parseEnumMember); + node.members = parseDelimitedList(6, parseEnumMember); parseExpected(15); } else { @@ -8170,9 +8252,9 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(207, scanner.getStartPos()); + var node = createNode(209, scanner.getStartPos()); if (parseExpected(14)) { - node.statements = parseList(1, false, parseModuleElement); + node.statements = parseList(1, parseStatement); parseExpected(15); } else { @@ -8181,7 +8263,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(206, fullStart); + var node = createNode(208, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; @@ -8192,7 +8274,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(206, fullStart); + var node = createNode(208, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -8201,11 +8283,11 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(118)) { + if (parseOptional(119)) { flags |= 32768; } else { - parseExpected(117); + parseExpected(118); if (token === 8) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -8213,7 +8295,7 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 119 && + return token === 120 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -8222,7 +8304,7 @@ var ts; function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 23 || - token === 125; + token === 126; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { parseExpected(85); @@ -8230,8 +8312,8 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 && token !== 125) { - var importEqualsDeclaration = createNode(209, fullStart); + if (token !== 23 && token !== 126) { + var importEqualsDeclaration = createNode(211, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; @@ -8241,14 +8323,14 @@ var ts; return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(210, fullStart); + var importDeclaration = createNode(212, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || token === 35 || token === 14) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(125); + parseExpected(126); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -8261,13 +8343,13 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(211, fullStart); + var importClause = createNode(213, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(23)) { - importClause.namedBindings = token === 35 ? parseNamespaceImport() : parseNamedImportsOrExports(213); + importClause.namedBindings = token === 35 ? parseNamespaceImport() : parseNamedImportsOrExports(215); } return finishNode(importClause); } @@ -8277,8 +8359,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(220); - parseExpected(119); + var node = createNode(222); + parseExpected(120); parseExpected(16); node.expression = parseModuleSpecifier(); parseExpected(17); @@ -8292,7 +8374,7 @@ var ts; return result; } function parseNamespaceImport() { - var namespaceImport = createNode(212); + var namespaceImport = createNode(214); parseExpected(35); parseExpected(111); namespaceImport.name = parseIdentifier(); @@ -8300,14 +8382,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(20, kind === 213 ? parseImportSpecifier : parseExportSpecifier, 14, 15); + node.elements = parseBracketedList(19, kind === 215 ? parseImportSpecifier : parseExportSpecifier, 14, 15); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(218); + return parseImportOrExportSpecifier(220); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(214); + return parseImportOrExportSpecifier(216); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -8326,22 +8408,22 @@ var ts; else { node.name = identifierName; } - if (kind === 214 && checkIdentifierIsKeyword) { + if (kind === 216 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216, fullStart); + var node = createNode(218, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(35)) { - parseExpected(125); + parseExpected(126); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(217); - if (parseOptional(125)) { + node.exportClause = parseNamedImportsOrExports(219); + if (parseOptional(126)) { node.moduleSpecifier = parseModuleSpecifier(); } } @@ -8349,7 +8431,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(215, fullStart); + var node = createNode(217, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(53)) { @@ -8414,15 +8496,15 @@ var ts; } sourceFile.referencedFiles = referencedFiles; sourceFile.amdDependencies = amdDependencies; - sourceFile.amdModuleName = amdModuleName; + sourceFile.moduleName = amdModuleName; } function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 - || node.kind === 209 && node.moduleReference.kind === 220 - || node.kind === 210 - || node.kind === 215 - || node.kind === 216 + || node.kind === 211 && node.moduleReference.kind === 222 + || node.kind === 212 + || node.kind === 217 + || node.kind === 218 ? node : undefined; }); @@ -8457,7 +8539,7 @@ var ts; function parseJSDocTypeExpression(start, length) { scanner.setText(sourceText, start, length); token = nextToken(); - var result = createNode(229); + var result = createNode(231); parseExpected(14); result.type = parseJSDocTopLevelType(); parseExpected(15); @@ -8468,12 +8550,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token === 44) { - var unionType = createNode(233, type.pos); + var unionType = createNode(235, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token === 53) { - var optionalType = createNode(240, type.pos); + var optionalType = createNode(242, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -8484,20 +8566,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 18) { - var arrayType = createNode(232, type.pos); + var arrayType = createNode(234, type.pos); arrayType.elementType = type; nextToken(); parseExpected(19); type = finishNode(arrayType); } else if (token === 50) { - var nullableType = createNode(235, type.pos); + var nullableType = createNode(237, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token === 46) { - var nonNullableType = createNode(236, type.pos); + var nonNullableType = createNode(238, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -8531,40 +8613,40 @@ var ts; case 93: return parseJSDocThisType(); case 112: - case 122: - case 120: - case 113: case 123: + case 121: + case 113: + case 124: case 99: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(244); + var result = createNode(246); nextToken(); parseExpected(51); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(243); + var result = createNode(245); nextToken(); parseExpected(51); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(242); + var result = createNode(244); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(241); + var result = createNode(243); nextToken(); parseExpected(16); - result.parameters = parseDelimitedList(21, parseJSDocParameter); + result.parameters = parseDelimitedList(20, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(17); if (token === 51) { @@ -8574,18 +8656,18 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(130); + var parameter = createNode(131); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(240, type.pos); + var result = createNode(242, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(239); + var result = createNode(241); result.name = parseSimplePropertyName(); while (parseOptional(20)) { if (token === 24) { @@ -8600,7 +8682,7 @@ var ts; } function parseTypeArguments() { nextToken(); - var typeArguments = parseDelimitedList(22, parseJSDocType); + var typeArguments = parseDelimitedList(21, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); parseExpected(25); @@ -8614,21 +8696,21 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(127, left.pos); + var result = createNode(128, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(237); + var result = createNode(239); nextToken(); - result.members = parseDelimitedList(23, parseJSDocRecordMember); + result.members = parseDelimitedList(22, parseJSDocRecordMember); checkForTrailingComma(result.members); parseExpected(15); return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(238); + var result = createNode(240); result.name = parseSimplePropertyName(); if (token === 51) { nextToken(); @@ -8637,15 +8719,15 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(236); + var result = createNode(238); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(234); + var result = createNode(236); nextToken(); - result.types = parseDelimitedList(24, parseJSDocType); + result.types = parseDelimitedList(23, parseJSDocType); checkForTrailingComma(result.types); parseExpected(19); return finishNode(result); @@ -8657,7 +8739,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(233); + var result = createNode(235); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(17); @@ -8675,7 +8757,7 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(230); + var result = createNode(232); nextToken(); return finishNode(result); } @@ -8688,11 +8770,11 @@ var ts; token === 25 || token === 53 || token === 44) { - var result = createNode(231, pos); + var result = createNode(233, pos); return finishNode(result); } else { - var result = createNode(235, pos); + var result = createNode(237, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -8763,7 +8845,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(245, start); + var result = createNode(247, start); result.tags = tags; return finishNode(result, end); } @@ -8801,7 +8883,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(246, atToken.pos); + var result = createNode(248, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -8853,7 +8935,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(247, atToken.pos); + var result = createNode(249, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -8863,27 +8945,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 248; })) { + if (ts.forEach(tags, function (t) { return t.kind === 250; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(248, atToken.pos); + var result = createNode(250, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 249; })) { + if (ts.forEach(tags, function (t) { return t.kind === 251; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(249, atToken.pos); + var result = createNode(251, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 250; })) { + if (ts.forEach(tags, function (t) { return t.kind === 252; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -8896,7 +8978,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(129, name_7.pos); + var typeParameter = createNode(130, name_7.pos); typeParameter.name = name_7; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -8907,7 +8989,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(250, atToken.pos); + var result = createNode(252, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -9222,16 +9304,16 @@ var ts; (function (ts) { ts.bindTime = 0; function getModuleInstanceState(node) { - if (node.kind === 203 || node.kind === 204) { + if (node.kind === 205 || node.kind === 206) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 210 || node.kind === 209) && !(node.flags & 1)) { + else if ((node.kind === 212 || node.kind === 211) && !(node.flags & 1)) { return 0; } - else if (node.kind === 207) { + else if (node.kind === 209) { var state = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -9247,7 +9329,7 @@ var ts; }); return state; } - else if (node.kind === 206) { + else if (node.kind === 208) { return getModuleInstanceState(node.body); } else { @@ -9266,11 +9348,14 @@ var ts; var container; var blockScopeContainer; var lastContainer; + var inStrictMode = !!file.externalModuleIndicator; var symbolCount = 0; var Symbol = ts.objectAllocator.getSymbolConstructor(); + var classifiableNames = {}; if (!file.locals) { bind(file); file.symbolCount = symbolCount; + file.classifiableNames = classifiableNames; } return; function createSymbol(flags, name) { @@ -9296,10 +9381,10 @@ var ts; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 206 && node.name.kind === 8) { + if (node.kind === 208 && node.name.kind === 8) { return '"' + node.name.text + '"'; } - if (node.name.kind === 128) { + if (node.name.kind === 129) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -9307,22 +9392,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 136: + case 137: return "__constructor"; - case 143: - case 139: - return "__call"; - case 144: + case 145: case 140: - return "__new"; + return "__call"; + case 146: case 141: + return "__new"; + case 142: return "__index"; - case 216: + case 218: return "__export"; - case 215: + case 217: return node.isExportEquals ? "export=" : "default"; - case 201: - case 202: + case 203: + case 204: return node.flags & 256 ? "default" : undefined; } } @@ -9337,6 +9422,9 @@ var ts; symbol = ts.hasProperty(symbolTable, name) ? symbolTable[name] : (symbolTable[name] = createSymbol(0, name)); + if (name && (includes & 788448)) { + classifiableNames[name] = name; + } if (symbol.flags & excludes) { if (node.name) { node.name.parent = node; @@ -9361,7 +9449,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 218 || (node.kind === 209 && hasExportModifier)) { + if (node.kind === 220 || (node.kind === 211 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -9407,36 +9495,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 175: - case 202: - case 203: + case 177: + case 204: case 205: - case 146: - case 155: + case 207: + case 148: + case 157: return 1; - case 139: case 140: case 141: - case 135: - case 134: - case 201: + case 142: case 136: + case 135: + case 203: case 137: case 138: - case 143: - case 144: - case 163: - case 164: - case 206: - case 228: - return 5; - case 224: - case 187: - case 188: - case 189: + case 139: + case 145: + case 146: + case 165: + case 166: case 208: + case 230: + case 206: + return 5; + case 226: + case 189: + case 190: + case 191: + case 210: return 2; - case 180: + case 182: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -9452,32 +9541,33 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 206: + case 208: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 228: + case 230: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 175: - case 202: + case 177: + case 204: return declareClassMember(node, symbolFlags, symbolExcludes); - case 205: + case 207: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 146: - case 155: - case 203: + case 148: + case 157: + case 205: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 143: - case 144: - case 139: + case 145: + case 146: case 140: case 141: - case 135: - case 134: + case 142: case 136: + case 135: case 137: case 138: - case 201: - case 163: - case 164: + case 139: + case 203: + case 165: + case 166: + case 206: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -9501,11 +9591,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 228 ? node : node.body; - if (body.kind === 228 || body.kind === 207) { + var body = node.kind === 230 ? node : node.body; + if (body.kind === 230 || body.kind === 209) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 216 || stat.kind === 215) { + if (stat.kind === 218 || stat.kind === 217) { return true; } } @@ -9550,16 +9640,41 @@ var ts; typeLiteralSymbol.members = (_a = {}, _a[symbol.name] = symbol, _a); var _a; } + function bindObjectLiteralExpression(node) { + if (inStrictMode) { + var seen = {}; + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var prop = _a[_i]; + if (prop.name.kind !== 65) { + continue; + } + var identifier = prop.name; + var currentKind = prop.kind === 227 || prop.kind === 228 || prop.kind === 136 + ? 1 + : 2; + var existingKind = seen[identifier.text]; + if (!existingKind) { + seen[identifier.text] = currentKind; + continue; + } + if (currentKind === 1 && existingKind === 1) { + var span = ts.getErrorSpanForNode(file, identifier); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode)); + } + } + } + return bindAnonymousDeclaration(node, 4096, "__object"); + } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); addDeclarationToSymbol(symbol, node, symbolFlags); } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 206: + case 208: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 228: + case 230: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -9575,79 +9690,223 @@ var ts; function bindBlockScopedVariableDeclaration(node) { bindBlockScopedDeclaration(node, 2, 107455); } + function checkStrictModeIdentifier(node) { + if (inStrictMode && + node.originalKeywordKind >= 102 && + node.originalKeywordKind <= 110 && + !ts.isIdentifierName(node)) { + if (!file.parseDiagnostics.length) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); + } + } + } + function getStrictModeIdentifierMessage(node) { + if (ts.getAncestor(node, 204) || ts.getAncestor(node, 177)) { + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode; + } + if (file.externalModuleIndicator) { + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode; + } + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode; + } + function checkStrictModeBinaryExpression(node) { + if (inStrictMode && ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) { + checkStrictModeEvalOrArguments(node, node.left); + } + } + function checkStrictModeCatchClause(node) { + if (inStrictMode && node.variableDeclaration) { + checkStrictModeEvalOrArguments(node, node.variableDeclaration.name); + } + } + function checkStrictModeDeleteExpression(node) { + if (inStrictMode && node.expression.kind === 65) { + var span = ts.getErrorSpanForNode(file, node.expression); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); + } + } + function isEvalOrArgumentsIdentifier(node) { + return node.kind === 65 && + (node.text === "eval" || node.text === "arguments"); + } + function checkStrictModeEvalOrArguments(contextNode, name) { + if (name && name.kind === 65) { + var identifier = name; + if (isEvalOrArgumentsIdentifier(identifier)) { + var span = ts.getErrorSpanForNode(file, name); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, getStrictModeEvalOrArgumentsMessage(contextNode), identifier.text)); + } + } + } + function getStrictModeEvalOrArgumentsMessage(node) { + if (ts.getAncestor(node, 204) || ts.getAncestor(node, 177)) { + return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode; + } + if (file.externalModuleIndicator) { + return ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode; + } + return ts.Diagnostics.Invalid_use_of_0_in_strict_mode; + } + function checkStrictModeFunctionName(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.name); + } + } + function checkStrictModeNumericLiteral(node) { + if (inStrictMode && node.flags & 16384) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); + } + } + function checkStrictModePostfixUnaryExpression(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.operand); + } + } + function checkStrictModePrefixUnaryExpression(node) { + if (inStrictMode) { + if (node.operator === 38 || node.operator === 39) { + checkStrictModeEvalOrArguments(node, node.operand); + } + } + } + function checkStrictModeWithStatement(node) { + if (inStrictMode) { + grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); + } + } + function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + var span = ts.getSpanOfTokenAtPosition(file, node.pos); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); + } function getDestructuringParameterName(node) { return "__" + ts.indexOf(node.parent.parameters, node); } function bind(node) { node.parent = parent; + var savedInStrictMode = inStrictMode; + if (!savedInStrictMode) { + updateStrictMode(node); + } bindWorker(node); bindChildren(node); + inStrictMode = savedInStrictMode; + } + function updateStrictMode(node) { + switch (node.kind) { + case 230: + case 209: + updateStrictModeStatementList(node.statements); + return; + case 182: + if (ts.isFunctionLike(node.parent)) { + updateStrictModeStatementList(node.statements); + } + return; + case 204: + case 177: + inStrictMode = true; + return; + } + } + function updateStrictModeStatementList(statements) { + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (!ts.isPrologueDirective(statement)) { + return; + } + if (isUseStrictPrologueDirective(statement)) { + inStrictMode = true; + return; + } + } + } + function isUseStrictPrologueDirective(node) { + var nodeText = ts.getTextOfNodeFromSourceText(file.text, node.expression); + return nodeText === '"use strict"' || nodeText === "'use strict'"; } function bindWorker(node) { switch (node.kind) { - case 129: - return declareSymbolAndAddToSymbolTable(node, 262144, 530912); - case 130: - return bindParameter(node); - case 199: - case 153: - return bindVariableDeclarationOrBindingElement(node); - case 133: - case 132: - return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); - case 225: + case 65: + return checkStrictModeIdentifier(node); + case 172: + return checkStrictModeBinaryExpression(node); case 226: - return bindPropertyOrMethodOrAccessor(node, 4, 107455); + return checkStrictModeCatchClause(node); + case 167: + return checkStrictModeDeleteExpression(node); + case 7: + return checkStrictModeNumericLiteral(node); + case 171: + return checkStrictModePostfixUnaryExpression(node); + case 170: + return checkStrictModePrefixUnaryExpression(node); + case 195: + return checkStrictModeWithStatement(node); + case 130: + return declareSymbolAndAddToSymbolTable(node, 262144, 530912); + case 131: + return bindParameter(node); + case 201: + case 155: + return bindVariableDeclarationOrBindingElement(node); + case 134: + case 133: + return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); case 227: + case 228: + return bindPropertyOrMethodOrAccessor(node, 4, 107455); + case 229: return bindPropertyOrMethodOrAccessor(node, 8, 107455); - case 139: case 140: case 141: + case 142: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 135: - case 134: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); - case 201: - return declareSymbolAndAddToSymbolTable(node, 16, 106927); case 136: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); - case 137: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); - case 138: - return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 143: - case 144: - return bindFunctionOrConstructorType(node); - case 146: - return bindAnonymousDeclaration(node, 2048, "__type"); - case 155: - return bindAnonymousDeclaration(node, 4096, "__object"); - case 163: - case 164: - return bindAnonymousDeclaration(node, 16, "__function"); - case 175: - case 202: - return bindClassLikeDeclaration(node); + case 135: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); case 203: - return bindBlockScopedDeclaration(node, 64, 792992); + checkStrictModeFunctionName(node); + return declareSymbolAndAddToSymbolTable(node, 16, 106927); + case 137: + return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 138: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 139: + return bindPropertyOrMethodOrAccessor(node, 65536, 74687); + case 145: + case 146: + return bindFunctionOrConstructorType(node); + case 148: + return bindAnonymousDeclaration(node, 2048, "__type"); + case 157: + return bindObjectLiteralExpression(node); + case 165: + case 166: + checkStrictModeFunctionName(node); + return bindAnonymousDeclaration(node, 16, "__function"); + case 177: case 204: - return bindBlockScopedDeclaration(node, 524288, 793056); + return bindClassLikeDeclaration(node); case 205: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 64, 792992); case 206: + return bindBlockScopedDeclaration(node, 524288, 793056); + case 207: + return bindEnumDeclaration(node); + case 208: return bindModuleDeclaration(node); - case 209: - case 212: - case 214: - case 218: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); case 211: - return bindImportClause(node); + case 214: case 216: + case 220: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 213: + return bindImportClause(node); + case 218: return bindExportDeclaration(node); - case 215: + case 217: return bindExportAssignment(node); - case 228: + case 230: return bindSourceFileIfExternalModule(); } } @@ -9658,7 +9917,10 @@ var ts; } } function bindExportAssignment(node) { - if (node.expression.kind === 65) { + if (!container.symbol || !container.symbol.exports) { + bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); + } + else if (node.expression.kind === 65) { declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); } else { @@ -9666,7 +9928,10 @@ var ts; } } function bindExportDeclaration(node) { - if (!node.exportClause) { + if (!container.symbol || !container.symbol.exports) { + bindAnonymousDeclaration(node, 1073741824, getDeclarationName(node)); + } + else if (!node.exportClause) { declareSymbol(container.symbol.exports, container.symbol, node, 1073741824, 0); } } @@ -9676,7 +9941,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 202) { + if (node.kind === 204) { bindBlockScopedDeclaration(node, 32, 899583); } else { @@ -9699,6 +9964,9 @@ var ts; : bindBlockScopedDeclaration(node, 256, 899327); } function bindVariableDeclarationOrBindingElement(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.name); + } if (!ts.isBindingPattern(node.name)) { if (ts.isBlockOrCatchScoped(node)) { bindBlockScopedVariableDeclaration(node); @@ -9712,6 +9980,9 @@ var ts; } } function bindParameter(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.name); + } if (ts.isBindingPattern(node.name)) { bindAnonymousDeclaration(node, 1, getDestructuringParameterName(node)); } @@ -9719,8 +9990,8 @@ var ts; declareSymbolAndAddToSymbolTable(node, 1, 107455); } if (node.flags & 112 && - node.parent.kind === 136 && - (node.parent.parent.kind === 202 || node.parent.parent.kind === 175)) { + node.parent.kind === 137 && + (node.parent.parent.kind === 204 || node.parent.parent.kind === 177)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); } @@ -9817,8 +10088,8 @@ var ts; emptyGenericType.instantiations = {}; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var anySignature = createSignature(undefined, undefined, emptyArray, anyType, 0, false, false); - var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, false, false); + var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); + var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); var globals = {}; var globalESSymbolConstructorSymbol; var globalObjectType; @@ -9869,6 +10140,11 @@ var ts; flags: 2097152 } }; + var subtypeRelation = {}; + var assignableRelation = {}; + var identityRelation = {}; + initializeTypeChecker(); + return checker; function getEmitResolver(sourceFile) { getDiagnostics(sourceFile); return emitResolver; @@ -10008,10 +10284,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 228); + return ts.getAncestor(node, 230); } function isGlobalSourceFile(node) { - return node.kind === 228 && !ts.isExternalModule(node); + return node.kind === 230 && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -10059,34 +10335,37 @@ var ts; } } switch (location.kind) { - case 228: + case 230: if (!ts.isExternalModule(location)) break; - case 206: - if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8914931)) { - if (result.flags & meaning || !(result.flags & 8388608 && getDeclarationOfAliasSymbol(result).kind === 218)) { - break loop; + case 208: + var moduleExports = getSymbolOfNode(location).exports; + if (location.kind === 230 || + (location.kind === 208 && location.name.kind === 8)) { + if (ts.hasProperty(moduleExports, name) && + moduleExports[name].flags === 8388608 && + ts.getDeclarationOfKind(moduleExports[name], 220)) { + break; } - result = undefined; - } - else if (location.kind === 228 || - (location.kind === 206 && location.name.kind === 8)) { - result = getSymbolOfNode(location).exports["default"]; + result = moduleExports["default"]; var localSymbol = ts.getLocalSymbolForExportDefault(result); if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; } result = undefined; } + if (result = getSymbol(moduleExports, name, meaning & 8914931)) { + break loop; + } break; - case 205: + case 207: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 134: case 133: - case 132: - if (location.parent.kind === 202 && !(location.flags & 128)) { + if (location.parent.kind === 204 && !(location.flags & 128)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455)) { @@ -10095,8 +10374,8 @@ var ts; } } break; - case 202: - case 203: + case 204: + case 205: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { if (lastLocation && lastLocation.flags & 128) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -10105,28 +10384,28 @@ var ts; break loop; } break; - case 128: + case 129: grandparent = location.parent.parent; - if (grandparent.kind === 202 || grandparent.kind === 203) { + if (grandparent.kind === 204 || grandparent.kind === 205) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 135: - case 134: case 136: + case 135: case 137: case 138: - case 201: - case 164: + case 139: + case 203: + case 166: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 163: + case 165: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -10139,7 +10418,7 @@ var ts; } } break; - case 175: + case 177: if (meaning & 32) { var className = location.name; if (className && name === className.text) { @@ -10148,8 +10427,8 @@ var ts; } } break; - case 131: - if (location.parent && location.parent.kind === 130) { + case 132: + if (location.parent && location.parent.kind === 131) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -10187,14 +10466,14 @@ var ts; ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); if (!isUsedBeforeDeclaration) { - var variableDeclaration = ts.getAncestor(declaration, 199); + var variableDeclaration = ts.getAncestor(declaration, 201); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 181 || - variableDeclaration.parent.parent.kind === 187) { + if (variableDeclaration.parent.parent.kind === 183 || + variableDeclaration.parent.parent.kind === 189) { isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 189 || - variableDeclaration.parent.parent.kind === 188) { + else if (variableDeclaration.parent.parent.kind === 191 || + variableDeclaration.parent.parent.kind === 190) { var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); } @@ -10216,10 +10495,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 209) { + if (node.kind === 211) { return node; } - while (node && node.kind !== 210) { + while (node && node.kind !== 212) { node = node.parent; } return node; @@ -10229,7 +10508,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 220) { + if (node.moduleReference.kind === 222) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -10318,17 +10597,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 209: - return getTargetOfImportEqualsDeclaration(node); case 211: + return getTargetOfImportEqualsDeclaration(node); + case 213: return getTargetOfImportClause(node); - case 212: - return getTargetOfNamespaceImport(node); case 214: + return getTargetOfNamespaceImport(node); + case 216: return getTargetOfImportSpecifier(node); - case 218: + case 220: return getTargetOfExportSpecifier(node); - case 215: + case 217: return getTargetOfExportAssignment(node); } } @@ -10370,10 +10649,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 215) { + if (node.kind === 217) { checkExpressionCached(node.expression); } - else if (node.kind === 218) { + else if (node.kind === 220) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -10383,17 +10662,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 209); + importDeclaration = ts.getAncestor(entityName, 211); ts.Debug.assert(importDeclaration !== undefined); } if (entityName.kind === 65 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 65 || entityName.parent.kind === 127) { + if (entityName.kind === 65 || entityName.parent.kind === 128) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 209); + ts.Debug.assert(entityName.parent.kind === 211); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -10412,9 +10691,9 @@ var ts; return undefined; } } - else if (name.kind === 127 || name.kind === 156) { - var left = name.kind === 127 ? name.left : name.expression; - var right = name.kind === 127 ? name.right : name.name; + else if (name.kind === 128 || name.kind === 158) { + var left = name.kind === 128 ? name.left : name.expression; + var right = name.kind === 128 ? name.right : name.name; var namespace = resolveEntityName(left, 1536); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -10559,7 +10838,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 136 && ts.nodeIsPresent(member.body)) { + if (member.kind === 137 && ts.nodeIsPresent(member.body)) { return member; } } @@ -10624,17 +10903,17 @@ var ts; } } switch (location_1.kind) { - case 228: + case 230: if (!ts.isExternalModule(location_1)) { break; } - case 206: + case 208: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 202: - case 203: + case 204: + case 205: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -10749,8 +11028,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 206 && declaration.name.kind === 8) || - (declaration.kind === 228 && ts.isExternalModule(declaration)); + return (declaration.kind === 208 && declaration.name.kind === 8) || + (declaration.kind === 230 && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -10782,11 +11061,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 145) { + if (entityName.parent.kind === 147) { meaning = 107455 | 1048576; } - else if (entityName.kind === 127 || entityName.kind === 156 || - entityName.parent.kind === 209) { + else if (entityName.kind === 128 || entityName.kind === 158 || + entityName.parent.kind === 211) { meaning = 1536; } else { @@ -10816,6 +11095,13 @@ var ts; ts.releaseStringWriter(writer); return result; } + function signatureToString(signature, enclosingDeclaration, flags) { + var writer = ts.getSingleLineStringWriter(); + getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); + var result = writer.string(); + ts.releaseStringWriter(writer); + return result; + } function typeToString(type, enclosingDeclaration, flags) { var writer = ts.getSingleLineStringWriter(); getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); @@ -10830,10 +11116,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 150) { + while (node.kind === 152) { node = node.parent; } - if (node.kind === 204) { + if (node.kind === 206) { return getSymbolOfNode(node); } } @@ -11040,7 +11326,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 228 || declaration.parent.kind === 207; + return declaration.parent.kind === 230 || declaration.parent.kind === 209; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -11114,7 +11400,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); writePunctuation(writer, 51); writeSpace(writer); - writeKeyword(writer, 122); + writeKeyword(writer, 123); writePunctuation(writer, 19); writePunctuation(writer, 51); writeSpace(writer); @@ -11127,7 +11413,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); writePunctuation(writer, 51); writeSpace(writer); - writeKeyword(writer, 120); + writeKeyword(writer, 121); writePunctuation(writer, 19); writePunctuation(writer, 51); writeSpace(writer); @@ -11170,7 +11456,7 @@ var ts; function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { var targetSymbol = getTargetSymbol(symbol); if (targetSymbol.flags & 32 || targetSymbol.flags & 64) { - buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterface(symbol), writer, enclosingDeclaraiton, flags); + buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); } } function buildTypeParameterDisplay(tp, writer, enclosingDeclaration, flags, symbolStack) { @@ -11272,12 +11558,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 206) { + if (node.kind === 208) { if (node.name.kind === 8) { return node; } } - else if (node.kind === 228) { + else if (node.kind === 230) { return ts.isExternalModule(node) ? node : undefined; } } @@ -11320,58 +11606,58 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 153: + case 155: return isDeclarationVisible(node.parent.parent); - case 199: + case 201: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 206: - case 202: - case 203: + case 208: case 204: - case 201: case 205: - case 209: + case 206: + case 203: + case 207: + case 211: var parent_4 = getDeclarationContainer(node); if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 209 && parent_4.kind !== 228 && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 211 && parent_4.kind !== 230 && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } return isDeclarationVisible(parent_4); - case 133: - case 132: - case 137: - case 138: - case 135: case 134: + case 133: + case 138: + case 139: + case 136: + case 135: if (node.flags & (32 | 64)) { return false; } - case 136: - case 140: - case 139: + case 137: case 141: - case 130: - case 207: - case 143: - case 144: - case 146: + case 140: case 142: - case 147: + case 131: + case 209: + case 145: + case 146: case 148: + case 144: case 149: case 150: + case 151: + case 152: return isDeclarationVisible(node.parent); - case 211: - case 212: + case 213: case 214: + case 216: return false; - case 129: - case 228: + case 130: + case 230: return true; - case 215: + case 217: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -11387,10 +11673,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 215) { + if (node.parent && node.parent.kind === 217) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 218) { + else if (node.parent.kind === 220) { exportSymbol = getTargetOfExportSpecifier(node.parent); } var result = []; @@ -11436,7 +11722,7 @@ var ts; } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); - return node.kind === 199 ? node.parent.parent.parent : node.parent; + return node.kind === 201 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); @@ -11462,7 +11748,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 151) { + if (pattern.kind === 153) { var name_9 = declaration.propertyName || declaration.name; type = getTypeOfPropertyOfType(parentType, name_9.text) || isNumericLiteralName(name_9.text) && getIndexTypeOfType(parentType, 1) || @@ -11499,10 +11785,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 188) { + if (declaration.parent.parent.kind === 190) { return anyType; } - if (declaration.parent.parent.kind === 189) { + if (declaration.parent.parent.kind === 191) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -11511,10 +11797,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 130) { + if (declaration.kind === 131) { var func = declaration.parent; - if (func.kind === 138 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 137); + if (func.kind === 139 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 138); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -11527,7 +11813,7 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 226) { + if (declaration.kind === 228) { return checkIdentifier(declaration.name); } return undefined; @@ -11556,7 +11842,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 176 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 178 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -11571,7 +11857,7 @@ var ts; return createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern) { - return pattern.kind === 151 + return pattern.kind === 153 ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -11581,7 +11867,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - return declaration.kind !== 225 ? getWidenedType(type) : type; + return declaration.kind !== 227 ? getWidenedType(type) : type; } if (ts.isBindingPattern(declaration.name)) { return getTypeFromBindingPattern(declaration.name); @@ -11589,7 +11875,7 @@ var ts; type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 130 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 131 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -11602,10 +11888,10 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 224) { + if (declaration.parent.kind === 226) { return links.type = anyType; } - if (declaration.kind === 215) { + if (declaration.kind === 217) { return links.type = checkExpression(declaration.expression); } if (!pushTypeResolution(symbol)) { @@ -11633,7 +11919,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 137) { + if (accessor.kind === 138) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -11649,8 +11935,8 @@ var ts; if (!pushTypeResolution(symbol)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 137); - var setter = ts.getDeclarationOfKind(symbol, 138); + var getter = ts.getDeclarationOfKind(symbol, 138); + var setter = ts.getDeclarationOfKind(symbol, 139); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -11676,7 +11962,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 137); + var getter_1 = ts.getDeclarationOfKind(symbol, 138); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -11765,9 +12051,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 202 || node.kind === 201 || - node.kind === 163 || node.kind === 135 || - node.kind === 164) { + if (node.kind === 204 || node.kind === 203 || + node.kind === 165 || node.kind === 136 || + node.kind === 166) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -11776,14 +12062,14 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var kind = symbol.flags & 32 ? 202 : 203; + var kind = symbol.flags & 32 ? 204 : 205; return appendOuterTypeParameters(undefined, ts.getDeclarationOfKind(symbol, kind)); } - function getLocalTypeParametersOfClassOrInterface(symbol) { + function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 203 || node.kind === 202) { + if (node.kind === 205 || node.kind === 204 || node.kind === 206) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -11793,56 +12079,109 @@ var ts; return result; } function getTypeParametersOfClassOrInterface(symbol) { - return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterface(symbol)); + return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); + } + function isConstructorType(type) { + return type.flags & 48128 && getSignaturesOfType(type, 1).length > 0; + } + function getBaseTypeNodeOfClass(type) { + return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); + } + function getConstructorsForTypeArguments(type, typeArgumentNodes) { + var typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; + return ts.filter(getSignaturesOfType(type, 1), function (sig) { return (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount; }); + } + function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { + var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); + if (typeArgumentNodes) { + var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); + signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments); }); + } + return signatures; + } + function getBaseConstructorTypeOfClass(type) { + if (!type.resolvedBaseConstructorType) { + var baseTypeNode = getBaseTypeNodeOfClass(type); + if (!baseTypeNode) { + return type.resolvedBaseConstructorType = undefinedType; + } + if (!pushTypeResolution(type)) { + return unknownType; + } + var baseConstructorType = checkExpression(baseTypeNode.expression); + if (baseConstructorType.flags & 48128) { + resolveObjectOrUnionTypeMembers(baseConstructorType); + } + if (!popTypeResolution()) { + error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); + return type.resolvedBaseConstructorType = unknownType; + } + if (baseConstructorType !== unknownType && baseConstructorType !== nullType && !isConstructorType(baseConstructorType)) { + error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); + return type.resolvedBaseConstructorType = unknownType; + } + type.resolvedBaseConstructorType = baseConstructorType; + } + return type.resolvedBaseConstructorType; } function getBaseTypes(type) { - var typeWithBaseTypes = type; - if (!typeWithBaseTypes.baseTypes) { + if (!type.resolvedBaseTypes) { if (type.symbol.flags & 32) { - resolveBaseTypesOfClass(typeWithBaseTypes); + resolveBaseTypesOfClass(type); } else if (type.symbol.flags & 64) { - resolveBaseTypesOfInterface(typeWithBaseTypes); + resolveBaseTypesOfInterface(type); } else { ts.Debug.fail("type must be class or interface"); } } - return typeWithBaseTypes.baseTypes; + return type.resolvedBaseTypes; } function resolveBaseTypesOfClass(type) { - type.baseTypes = []; - var declaration = ts.getDeclarationOfKind(type.symbol, 202); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(declaration); - if (baseTypeNode) { - var baseType = getTypeFromTypeNode(baseTypeNode); - if (baseType !== unknownType) { - if (getTargetType(baseType).flags & 1024) { - if (type !== baseType && !hasBaseType(baseType, type)) { - type.baseTypes.push(baseType); - } - else { - error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1)); - } - } - else { - error(baseTypeNode, ts.Diagnostics.A_class_may_only_extend_another_class); - } - } + type.resolvedBaseTypes = emptyArray; + var baseContructorType = getBaseConstructorTypeOfClass(type); + if (!(baseContructorType.flags & 48128)) { + return; } + var baseTypeNode = getBaseTypeNodeOfClass(type); + var baseType; + if (baseContructorType.symbol && baseContructorType.symbol.flags & 32) { + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseContructorType.symbol); + } + else { + var constructors = getInstantiatedConstructorsForTypeArguments(baseContructorType, baseTypeNode.typeArguments); + if (!constructors.length) { + error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); + return; + } + baseType = getReturnTypeOfSignature(constructors[0]); + } + if (baseType === unknownType) { + return; + } + if (!(getTargetType(baseType).flags & (1024 | 2048))) { + error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); + return; + } + if (type === baseType || hasBaseType(baseType, type)) { + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1)); + return; + } + type.resolvedBaseTypes = [baseType]; } function resolveBaseTypesOfInterface(type) { - type.baseTypes = []; + type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 203 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 205 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { if (getTargetType(baseType).flags & (1024 | 2048)) { if (type !== baseType && !hasBaseType(baseType, type)) { - type.baseTypes.push(baseType); + type.resolvedBaseTypes.push(baseType); } else { error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1)); @@ -11862,7 +12201,7 @@ var ts; var kind = symbol.flags & 32 ? 1024 : 2048; var type = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); - var localTypeParameters = getLocalTypeParametersOfClassOrInterface(symbol); + var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (outerTypeParameters || localTypeParameters) { type.flags |= 4096; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); @@ -11882,9 +12221,16 @@ var ts; if (!pushTypeResolution(links)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 204); + var declaration = ts.getDeclarationOfKind(symbol, 206); var type = getTypeFromTypeNode(declaration.type); - if (!popTypeResolution()) { + if (popTypeResolution()) { + links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + if (links.typeParameters) { + links.instantiations = {}; + links.instantiations[getTypeListId(links.typeParameters)] = type; + } + } + else { type = unknownType; error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } @@ -11906,7 +12252,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 129).constraint) { + if (!ts.getDeclarationOfKind(symbol, 130).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -12021,34 +12367,42 @@ var ts; }); setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } - function createSignature(declaration, typeParameters, parameters, resolvedReturnType, minArgumentCount, hasRestParameter, hasStringLiterals) { + function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); sig.declaration = declaration; sig.typeParameters = typeParameters; sig.parameters = parameters; sig.resolvedReturnType = resolvedReturnType; + sig.typePredicate = typePredicate; sig.minArgumentCount = minArgumentCount; sig.hasRestParameter = hasRestParameter; sig.hasStringLiterals = hasStringLiterals; return sig; } function cloneSignature(sig) { - return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); + return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); } function getDefaultConstructSignatures(classType) { - var baseTypes = getBaseTypes(classType); - if (baseTypes.length) { - var baseType = baseTypes[0]; - var baseSignatures = getSignaturesOfType(getTypeOfSymbol(baseType.symbol), 1); - return ts.map(baseSignatures, function (baseSignature) { - var signature = baseType.flags & 4096 ? - getSignatureInstantiation(baseSignature, baseType.typeArguments) : cloneSignature(baseSignature); - signature.typeParameters = classType.localTypeParameters; - signature.resolvedReturnType = classType; - return signature; - }); + if (!getBaseTypes(classType).length) { + return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)]; } - return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, 0, false, false)]; + var baseConstructorType = getBaseConstructorTypeOfClass(classType); + var baseSignatures = getSignaturesOfType(baseConstructorType, 1); + var baseTypeNode = getBaseTypeNodeOfClass(classType); + var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); + var typeArgCount = typeArguments ? typeArguments.length : 0; + var result = []; + for (var _i = 0; _i < baseSignatures.length; _i++) { + var baseSig = baseSignatures[_i]; + var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; + if (typeParamCount === typeArgCount) { + var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + sig.typeParameters = classType.localTypeParameters; + sig.resolvedReturnType = classType; + result.push(sig); + } + } + return result; } function createTupleTypeMemberSymbols(memberTypes) { var members = {}; @@ -12147,10 +12501,10 @@ var ts; if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); } - var baseTypes = getBaseTypes(classType); - if (baseTypes.length) { + var baseConstructorType = getBaseConstructorTypeOfClass(classType); + if (baseConstructorType.flags & 48128) { members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(getTypeOfSymbol(baseTypes[0].symbol))); + addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); } } stringIndexType = undefined; @@ -12356,7 +12710,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 136 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 137 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -12378,22 +12732,31 @@ var ts; minArgumentCount = declaration.parameters.length; } var returnType; + var typePredicate; if (classType) { returnType = classType; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); + if (declaration.type.kind === 143) { + var typePredicateNode = declaration.type; + typePredicate = { + parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, + parameterIndex: typePredicateNode.parameterName ? getTypePredicateParameterIndex(declaration.parameters, typePredicateNode.parameterName) : undefined, + type: getTypeFromTypeNode(typePredicateNode.type) + }; + } } else { - if (declaration.kind === 137 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 138); + if (declaration.kind === 138 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 139); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { returnType = anyType; } } - links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); + links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); } return links.resolvedSignature; } @@ -12404,19 +12767,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 143: - case 144: - case 201: - case 135: - case 134: + case 145: + case 146: + case 203: case 136: - case 139: + case 135: + case 137: case 140: case 141: - case 137: + case 142: case 138: - case 163: - case 164: + case 139: + case 165: + case 166: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -12486,7 +12849,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 136 || signature.declaration.kind === 140; + var isConstructor = signature.declaration.kind === 137 || signature.declaration.kind === 141; var type = createObjectType(32768 | 131072); type.members = emptySymbols; type.properties = emptyArray; @@ -12500,7 +12863,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 120 : 122; + var syntaxKind = kind === 1 ? 121 : 123; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { var len = indexSymbol.declarations.length; @@ -12530,13 +12893,13 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 129).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 130).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 129).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 130).parent); } function getTypeListId(types) { switch (types.length) { @@ -12583,18 +12946,18 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 129; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 130; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 142 && n.typeName.kind === 65) { + if (n.kind === 144 && n.typeName.kind === 65) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); if (symbol && (symbol.flags & 262144)) { - links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent == typeParameter.parent; }); + links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent === typeParameter.parent; }); } } if (links.isIllegalTypeReferenceInConstraint) { @@ -12608,55 +12971,71 @@ var ts; check(typeParameter.constraint); } } - function getTypeFromTypeReferenceOrExpressionWithTypeArguments(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - var type; - if (node.kind !== 177 || ts.isSupportedExpressionWithTypeArguments(node)) { - var typeNameOrExpression = node.kind === 142 - ? node.typeName - : node.expression; - var symbol = resolveEntityName(typeNameOrExpression, 793056); - if (symbol) { - if ((symbol.flags & 262144) && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { - type = unknownType; - } - else { - type = createTypeReferenceIfGeneric(getDeclaredTypeOfSymbol(symbol), node, node.typeArguments); - } - } + function getTypeFromClassOrInterfaceReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var typeParameters = type.localTypeParameters; + if (typeParameters) { + if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1), typeParameters.length); + return unknownType; } - links.resolvedType = type || unknownType; + return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); } - return links.resolvedType; - } - function createTypeReferenceIfGeneric(type, node, typeArguments) { - if (type.flags & (1024 | 2048) && type.flags & 4096) { - var localTypeParameters = type.localTypeParameters; - var expectedTypeArgCount = localTypeParameters ? localTypeParameters.length : 0; - var typeArgCount = typeArguments ? typeArguments.length : 0; - if (typeArgCount === expectedTypeArgCount) { - if (typeArgCount) { - return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(typeArguments, getTypeFromTypeNode))); - } - } - else { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1), expectedTypeArgCount); - return undefined; - } - } - else { - if (typeArguments) { - error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); - return undefined; - } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); + return unknownType; } return type; } + function getTypeFromTypeAliasReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var links = getSymbolLinks(symbol); + var typeParameters = links.typeParameters; + if (typeParameters) { + if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); + return unknownType; + } + var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); + var id = getTypeListId(typeArguments); + return links.instantiations[id] || (links.instantiations[id] = instantiateType(type, createTypeMapper(typeParameters, typeArguments))); + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); + return unknownType; + } + return type; + } + function getTypeFromNonGenericTypeReference(node, symbol) { + if (symbol.flags & 262144 && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { + return unknownType; + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); + return unknownType; + } + return getDeclaredTypeOfSymbol(symbol); + } + function getTypeFromTypeReference(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + var typeNameOrExpression = node.kind === 144 ? node.typeName : + ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : + undefined; + var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; + var type = symbol === unknownSymbol ? unknownType : + symbol.flags & (32 | 64) ? getTypeFromClassOrInterfaceReference(node, symbol) : + symbol.flags & 524288 ? getTypeFromTypeAliasReference(node, symbol) : + getTypeFromNonGenericTypeReference(node, symbol); + links.resolvedSymbol = symbol; + links.resolvedType = type; + } + return links.resolvedType; + } function getTypeFromTypeQueryNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getWidenedType(checkExpressionOrQualifiedName(node.exprName)); + links.resolvedType = getWidenedType(checkExpression(node.exprName)); } return links.resolvedType; } @@ -12666,9 +13045,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 202: - case 203: + case 204: case 205: + case 207: return declaration; } } @@ -12869,38 +13248,40 @@ var ts; switch (node.kind) { case 112: return anyType; - case 122: + case 123: return stringType; - case 120: + case 121: return numberType; case 113: return booleanType; - case 123: + case 124: return esSymbolType; case 99: return voidType; case 8: return getTypeFromStringLiteral(node); - case 142: - return getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); - case 177: - return getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); - case 145: - return getTypeFromTypeQueryNode(node); - case 147: - return getTypeFromArrayTypeNode(node); - case 148: - return getTypeFromTupleTypeNode(node); - case 149: - return getTypeFromUnionTypeNode(node); - case 150: - return getTypeFromTypeNode(node.type); - case 143: case 144: + return getTypeFromTypeReference(node); + case 143: + return booleanType; + case 179: + return getTypeFromTypeReference(node); + case 147: + return getTypeFromTypeQueryNode(node); + case 149: + return getTypeFromArrayTypeNode(node); + case 150: + return getTypeFromTupleTypeNode(node); + case 151: + return getTypeFromUnionTypeNode(node); + case 152: + return getTypeFromTypeNode(node.type); + case 145: case 146: + case 148: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 65: - case 127: + case 128: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -12990,11 +13371,19 @@ var ts; } function instantiateSignature(signature, mapper, eraseTypeParameters) { var freshTypeParameters; + var freshTypePredicate; if (signature.typeParameters && !eraseTypeParameters) { freshTypeParameters = instantiateList(signature.typeParameters, mapper, instantiateTypeParameter); mapper = combineTypeMappers(createTypeMapper(signature.typeParameters, freshTypeParameters), mapper); } - var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + if (signature.typePredicate) { + freshTypePredicate = { + parameterName: signature.typePredicate.parameterName, + parameterIndex: signature.typePredicate.parameterIndex, + type: instantiateType(signature.typePredicate.type, mapper) + }; + } + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -13051,27 +13440,27 @@ var ts; return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 135 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 163: - case 164: + case 165: + case 166: return isContextSensitiveFunctionLikeDeclaration(node); - case 155: + case 157: return ts.forEach(node.properties, isContextSensitive); - case 154: + case 156: return ts.forEach(node.elements, isContextSensitive); - case 171: + case 173: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 170: + case 172: return node.operatorToken.kind === 49 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 225: + case 227: return isContextSensitive(node.initializer); + case 136: case 135: - case 134: return isContextSensitiveFunctionLikeDeclaration(node); - case 162: + case 164: return isContextSensitive(node.expression); } return false; @@ -13079,23 +13468,20 @@ var ts; function isContextSensitiveFunctionLikeDeclaration(node) { return !node.typeParameters && node.parameters.length && !ts.forEach(node.parameters, function (p) { return p.type; }); } - function getTypeWithoutConstructors(type) { + function getTypeWithoutSignatures(type) { if (type.flags & 48128) { var resolved = resolveObjectOrUnionTypeMembers(type); if (resolved.constructSignatures.length) { var result = createObjectType(32768, type.symbol); result.members = resolved.members; result.properties = resolved.properties; - result.callSignatures = resolved.callSignatures; + result.callSignatures = emptyArray; result.constructSignatures = emptyArray; type = result; } } return type; } - var subtypeRelation = {}; - var assignableRelation = {}; - var identityRelation = {}; function isTypeIdenticalTo(source, target) { return checkTypeRelatedTo(source, target, identityRelation, undefined); } @@ -13346,9 +13732,9 @@ var ts; maybeStack[depth][id] = 1; depth++; var saveExpandingFlags = expandingFlags; - if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack)) + if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) expandingFlags |= 1; - if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack)) + if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth)) expandingFlags |= 2; var result; if (expandingFlags === 3) { @@ -13381,21 +13767,6 @@ var ts; } return result; } - function isDeeplyNestedGeneric(type, stack) { - if (type.flags & (4096 | 65536) && depth >= 10) { - var symbol = type.symbol; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (t.flags & (4096 | 65536) && t.symbol === symbol) { - count++; - if (count >= 10) - return true; - } - } - } - return false; - } function propertiesRelatedTo(source, target, reportErrors) { if (relation === identityRelation) { return propertiesIdenticalTo(source, target); @@ -13566,6 +13937,33 @@ var ts; } result &= related; } + if (source.typePredicate && target.typePredicate) { + var hasDifferentParameterIndex = source.typePredicate.parameterIndex !== target.typePredicate.parameterIndex; + var hasDifferentTypes; + if (hasDifferentParameterIndex || + (hasDifferentTypes = !isTypeIdenticalTo(source.typePredicate.type, target.typePredicate.type))) { + if (reportErrors) { + var sourceParamText = source.typePredicate.parameterName; + var targetParamText = target.typePredicate.parameterName; + var sourceTypeText = typeToString(source.typePredicate.type); + var targetTypeText = typeToString(target.typePredicate.type); + if (hasDifferentParameterIndex) { + reportError(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceParamText, targetParamText); + } + else if (hasDifferentTypes) { + reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceTypeText, targetTypeText); + } + reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, sourceParamText + " is " + sourceTypeText, targetParamText + " is " + targetTypeText); + } + return 0; + } + } + else if (!source.typePredicate && target.typePredicate) { + if (reportErrors) { + reportError(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); + } + return 0; + } var t = getReturnTypeOfSignature(target); if (t === voidType) return result; @@ -13655,6 +14053,21 @@ var ts; return 0; } } + function isDeeplyNestedGeneric(type, stack, depth) { + if (type.flags & (4096 | 65536) && depth >= 5) { + var symbol = type.symbol; + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (t.flags & (4096 | 65536) && t.symbol === symbol) { + count++; + if (count >= 5) + return true; + } + } + } + return false; + } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypes) !== 0; } @@ -13845,22 +14258,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 134: case 133: - case 132: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 130: + case 131: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 201: + case 203: + case 136: case 135: - case 134: - case 137: case 138: - case 163: - case 164: + case 139: + case 165: + case 166: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -13932,20 +14345,6 @@ var ts; } return false; } - function isWithinDepthLimit(type, stack) { - if (depth >= 5) { - var target_1 = type.target; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (t.flags & 4096 && t.target === target_1) { - count++; - } - } - return count < 5; - } - return true; - } function inferFromTypes(source, target) { if (source === anyFunctionType) { return; @@ -14003,22 +14402,26 @@ var ts; } else if (source.flags & 48128 && (target.flags & (4096 | 8192) || (target.flags & 32768) && target.symbol && target.symbol.flags & (8192 | 2048))) { - if (!isInProcess(source, target) && isWithinDepthLimit(source, sourceStack) && isWithinDepthLimit(target, targetStack)) { - if (depth === 0) { - sourceStack = []; - targetStack = []; - } - sourceStack[depth] = source; - targetStack[depth] = target; - depth++; - inferFromProperties(source, target); - inferFromSignatures(source, target, 0); - inferFromSignatures(source, target, 1); - inferFromIndexTypes(source, target, 0, 0); - inferFromIndexTypes(source, target, 1, 1); - inferFromIndexTypes(source, target, 0, 1); - depth--; + if (isInProcess(source, target)) { + return; } + if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { + return; + } + if (depth === 0) { + sourceStack = []; + targetStack = []; + } + sourceStack[depth] = source; + targetStack[depth] = target; + depth++; + inferFromProperties(source, target); + inferFromSignatures(source, target, 0); + inferFromSignatures(source, target, 1); + inferFromIndexTypes(source, target, 0, 0); + inferFromIndexTypes(source, target, 1, 1); + inferFromIndexTypes(source, target, 0, 1); + depth--; } } function inferFromProperties(source, target) { @@ -14043,7 +14446,14 @@ var ts; } function inferFromSignature(source, target) { forEachMatchingParameterType(source, target, inferFromTypes); - inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + if (source.typePredicate && target.typePredicate) { + if (target.typePredicate.parameterIndex === source.typePredicate.parameterIndex) { + inferFromTypes(source.typePredicate.type, target.typePredicate.type); + } + } + else { + inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + } } function inferFromIndexTypes(source, target, sourceKind, targetKind) { var targetIndexType = getIndexTypeOfType(target, targetKind); @@ -14103,10 +14513,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 145: + case 147: return true; case 65: - case 127: + case 128: node = node.parent; continue; default: @@ -14148,7 +14558,7 @@ var ts; function isAssignedInBinaryExpression(node) { if (node.operatorToken.kind >= 53 && node.operatorToken.kind <= 64) { var n = node.left; - while (n.kind === 162) { + while (n.kind === 164) { n = n.expression; } if (n.kind === 65 && getResolvedSymbol(n) === symbol) { @@ -14165,46 +14575,46 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 170: + case 172: return isAssignedInBinaryExpression(node); - case 199: - case 153: - return isAssignedInVariableDeclaration(node); - case 151: - case 152: - case 154: + case 201: case 155: + return isAssignedInVariableDeclaration(node); + case 153: + case 154: case 156: case 157: case 158: case 159: + case 160: case 161: - case 162: - case 168: - case 165: - case 166: + case 163: + case 164: + case 170: case 167: + case 168: case 169: case 171: - case 174: - case 180: - case 181: + case 173: + case 176: + case 182: case 183: - case 184: case 185: case 186: case 187: case 188: case 189: - case 192: - case 193: + case 190: + case 191: case 194: - case 221: - case 222: case 195: case 196: - case 197: + case 223: case 224: + case 197: + case 198: + case 199: + case 226: return ts.forEachChild(node, isAssignedIn); } return false; @@ -14241,17 +14651,17 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 184: + case 186: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 171: + case 173: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 170: + case 172: if (child === node.right) { if (node.operatorToken.kind === 48) { narrowedType = narrowType(type, node.left, true); @@ -14261,14 +14671,14 @@ var ts; } } break; - case 228: - case 206: - case 201: - case 135: - case 134: - case 137: - case 138: + case 230: + case 208: + case 203: case 136: + case 135: + case 138: + case 139: + case 137: break loop; } if (narrowedType !== type) { @@ -14282,7 +14692,7 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 166 || expr.right.kind !== 8) { + if (expr.left.kind !== 168 || expr.right.kind !== 8) { return type; } var left = expr.left; @@ -14361,20 +14771,44 @@ var ts; } } if (targetType) { - if (isTypeSubtypeOf(targetType, type)) { - return targetType; - } - if (type.flags & 16384) { - return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); })); + return getNarrowedType(type, targetType); + } + return type; + } + function getNarrowedType(originalType, narrowedTypeCandidate) { + if (isTypeSubtypeOf(narrowedTypeCandidate, originalType)) { + return narrowedTypeCandidate; + } + if (originalType.flags & 16384) { + return getUnionType(ts.filter(originalType.types, function (t) { return isTypeSubtypeOf(t, narrowedTypeCandidate); })); + } + return originalType; + } + function narrowTypeByTypePredicate(type, expr, assumeTrue) { + if (type.flags & 1) { + return type; + } + var signature = getResolvedSignature(expr); + if (signature.typePredicate && + expr.arguments[signature.typePredicate.parameterIndex] && + getSymbolAtLocation(expr.arguments[signature.typePredicate.parameterIndex]) === symbol) { + if (!assumeTrue) { + if (type.flags & 16384) { + return getUnionType(ts.filter(type.types, function (t) { return !isTypeSubtypeOf(t, signature.typePredicate.type); })); + } + return type; } + return getNarrowedType(type, signature.typePredicate.type); } return type; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 162: + case 160: + return narrowTypeByTypePredicate(type, expr, assumeTrue); + case 164: return narrowType(type, expr.expression, assumeTrue); - case 170: + case 172: var operator = expr.operatorToken.kind; if (operator === 30 || operator === 31) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -14389,7 +14823,7 @@ var ts; return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 168: + case 170: if (expr.operator === 46) { return narrowType(type, expr.operand, !assumeTrue); } @@ -14400,7 +14834,7 @@ var ts; } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); - if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 164 && languageVersion < 2) { + if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 166 && languageVersion < 2) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } if (symbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { @@ -14424,15 +14858,15 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 224) { + symbol.valueDeclaration.parent.kind === 226) { return; } var container = symbol.valueDeclaration; - while (container.kind !== 200) { + while (container.kind !== 202) { container = container.parent; } container = container.parent; - if (container.kind === 181) { + if (container.kind === 183) { container = container.parent; } var inFunction = isInsideFunction(node.parent, container); @@ -14449,9 +14883,9 @@ var ts; } } function captureLexicalThis(node, container) { - var classNode = container.parent && container.parent.kind === 202 ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 204 ? container.parent : undefined; getNodeLinks(node).flags |= 2; - if (container.kind === 133 || container.kind === 136) { + if (container.kind === 134 || container.kind === 137) { getNodeLinks(classNode).flags |= 4; } else { @@ -14461,36 +14895,36 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 164) { + if (container.kind === 166) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 206: + case 208: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 205: + case 207: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 136: + case 137: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 134: case 133: - case 132: if (container.flags & 128) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 128: + case 129: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } if (needToCaptureLexicalThis) { captureLexicalThis(node, container); } - var classNode = container.parent && container.parent.kind === 202 ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 204 ? container.parent : undefined; if (classNode) { var symbol = getSymbolOfNode(classNode); return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); @@ -14499,23 +14933,21 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 130) { + if (n.kind === 131) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 158 && node.parent.expression === node; - var enclosingClass = ts.getAncestor(node, 202); - var baseClass; - if (enclosingClass && ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); - var baseTypes = getBaseTypes(classType); - baseClass = baseTypes.length && baseTypes[0]; - } - if (!baseClass) { - error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); + var isCallExpression = node.parent.kind === 160 && node.parent.expression === node; + var classDeclaration = ts.getAncestor(node, 204); + var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); + var baseClassType = classType && getBaseTypes(classType)[0]; + if (!baseClassType) { + if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { + error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); + } return unknownType; } var container = ts.getSuperContainer(node, true); @@ -14523,31 +14955,31 @@ var ts; var canUseSuperExpression = false; var needToCaptureLexicalThis; if (isCallExpression) { - canUseSuperExpression = container.kind === 136; + canUseSuperExpression = container.kind === 137; } else { needToCaptureLexicalThis = false; - while (container && container.kind === 164) { + while (container && container.kind === 166) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } - if (container && container.parent && container.parent.kind === 202) { + if (container && container.parent && container.parent.kind === 204) { if (container.flags & 128) { canUseSuperExpression = - container.kind === 135 || - container.kind === 134 || - container.kind === 137 || - container.kind === 138; + container.kind === 136 || + container.kind === 135 || + container.kind === 138 || + container.kind === 139; } else { canUseSuperExpression = - container.kind === 135 || - container.kind === 134 || - container.kind === 137 || + container.kind === 136 || + container.kind === 135 || container.kind === 138 || + container.kind === 139 || + container.kind === 134 || container.kind === 133 || - container.kind === 132 || - container.kind === 136; + container.kind === 137; } } } @@ -14555,13 +14987,13 @@ var ts; var returnType; if ((container.flags & 128) || isCallExpression) { getNodeLinks(node).flags |= 32; - returnType = getTypeOfSymbol(baseClass.symbol); + returnType = getBaseConstructorTypeOfClass(classType); } else { getNodeLinks(node).flags |= 16; - returnType = baseClass; + returnType = baseClassType; } - if (container.kind === 136 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 137 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); returnType = unknownType; } @@ -14571,7 +15003,7 @@ var ts; return returnType; } } - if (container && container.kind === 128) { + if (container && container.kind === 129) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -14609,7 +15041,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 130) { + if (declaration.kind === 131) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -14642,8 +15074,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 136 || - functionDecl.kind === 137 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 138))) { + functionDecl.kind === 137 || + functionDecl.kind === 138 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 139))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -14662,7 +15094,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 160) { + if (template.parent.kind === 162) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -14770,34 +15202,34 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 199: - case 130: + case 201: + case 131: + case 134: case 133: - case 132: - case 153: + case 155: return getContextualTypeForInitializerExpression(node); - case 164: - case 192: + case 166: + case 194: return getContextualTypeForReturnExpression(node); - case 173: + case 175: return getContextualTypeForYieldOperand(parent); - case 158: - case 159: - return getContextualTypeForArgument(parent, node); + case 160: case 161: + return getContextualTypeForArgument(parent, node); + case 163: return getTypeFromTypeNode(parent.type); - case 170: + case 172: return getContextualTypeForBinaryOperand(node); - case 225: + case 227: return getContextualTypeForObjectLiteralElement(parent); - case 154: + case 156: return getContextualTypeForElementExpression(node); - case 171: + case 173: return getContextualTypeForConditionalOperand(node); - case 178: - ts.Debug.assert(parent.parent.kind === 172); + case 180: + ts.Debug.assert(parent.parent.kind === 174); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 162: + case 164: return getContextualType(parent); } return undefined; @@ -14812,7 +15244,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 163 || node.kind === 164; + return node.kind === 165 || node.kind === 166; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -14820,7 +15252,7 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 135 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -14864,13 +15296,13 @@ var ts; } function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 170 && parent.operatorToken.kind === 53 && parent.left === node) { + if (parent.kind === 172 && parent.operatorToken.kind === 53 && parent.left === node) { return true; } - if (parent.kind === 225) { + if (parent.kind === 227) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 154) { + if (parent.kind === 156) { return isAssignmentTarget(parent); } return false; @@ -14889,7 +15321,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 174) { + if (inDestructuringPattern && e.kind === 176) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -14901,7 +15333,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 174; + hasSpreadElement = hasSpreadElement || e.kind === 176; } if (!hasSpreadElement) { var contextualType = getContextualType(node); @@ -14912,7 +15344,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 128 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 129 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); @@ -14945,18 +15377,18 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 225 || - memberDecl.kind === 226 || + if (memberDecl.kind === 227 || + memberDecl.kind === 228 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 225) { + if (memberDecl.kind === 227) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 135) { + else if (memberDecl.kind === 136) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 226); + ts.Debug.assert(memberDecl.kind === 228); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -14971,7 +15403,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 137 || memberDecl.kind === 138); + ts.Debug.assert(memberDecl.kind === 138 || memberDecl.kind === 139); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -15004,7 +15436,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 133; + return s.valueDeclaration ? s.valueDeclaration.kind : 134; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; @@ -15014,7 +15446,7 @@ var ts; if (!(flags & (32 | 64))) { return; } - var enclosingClassDeclaration = ts.getAncestor(node, 202); + var enclosingClassDeclaration = ts.getAncestor(node, 204); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; var declaringClass = getDeclaredTypeOfSymbol(prop.parent); if (flags & 32) { @@ -15044,7 +15476,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { - var type = checkExpressionOrQualifiedName(left); + var type = checkExpression(left); if (isTypeAny(type)) { return type; } @@ -15061,7 +15493,7 @@ var ts; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32) { - if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 135) { + if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 136) { error(right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); } else { @@ -15071,14 +15503,14 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 156 + var left = node.kind === 158 ? node.expression : node.left; - var type = checkExpressionOrQualifiedName(left); + var type = checkExpression(left); if (type !== unknownType && !isTypeAny(type)) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32) { - if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 135) { + if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 136) { return false; } else { @@ -15093,7 +15525,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 159 && node.parent.expression === node) { + if (node.parent.kind === 161 && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -15189,7 +15621,7 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 160) { + if (node.kind === 162) { checkExpression(node.template); } else { @@ -15242,7 +15674,7 @@ var ts; } function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { - if (args[i].kind === 174) { + if (args[i].kind === 176) { return i; } } @@ -15252,11 +15684,11 @@ var ts; var adjustedArgCount; var typeArguments; var callIsIncomplete; - if (node.kind === 160) { + if (node.kind === 162) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 172) { + if (tagExpression.template.kind === 174) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -15271,7 +15703,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 159); + ts.Debug.assert(callExpression.kind === 161); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -15323,10 +15755,10 @@ var ts; } for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg.kind !== 176) { + if (arg.kind !== 178) { var paramType = getTypeAtPosition(signature, i); var argType = void 0; - if (i === 0 && args[i].parent.kind === 160) { + if (i === 0 && args[i].parent.kind === 162) { argType = globalTemplateStringsArrayType; } else { @@ -15366,9 +15798,9 @@ var ts; function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg.kind !== 176) { + if (arg.kind !== 178) { var paramType = getTypeAtPosition(signature, i); - var argType = i === 0 && node.kind === 160 + var argType = i === 0 && node.kind === 162 ? globalTemplateStringsArrayType : arg.kind === 8 && !reportErrors ? getStringLiteralType(arg) @@ -15382,10 +15814,10 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 160) { + if (node.kind === 162) { var template = node.template; args = [template]; - if (template.kind === 172) { + if (template.kind === 174) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); @@ -15396,21 +15828,11 @@ var ts; } return args; } - function getEffectiveTypeArguments(callExpression) { - if (callExpression.expression.kind === 91) { - var containingClass = ts.getAncestor(callExpression, 202); - var baseClassTypeNode = containingClass && ts.getClassExtendsHeritageClauseElement(containingClass); - return baseClassTypeNode && baseClassTypeNode.typeArguments; - } - else { - return callExpression.typeArguments; - } - } function resolveCall(node, signatures, candidatesOutArray) { - var isTaggedTemplate = node.kind === 160; + var isTaggedTemplate = node.kind === 162; var typeArguments; if (!isTaggedTemplate) { - typeArguments = getEffectiveTypeArguments(node); + typeArguments = node.typeArguments; if (node.expression.kind !== 91) { ts.forEach(typeArguments, checkSourceElement); } @@ -15451,8 +15873,8 @@ var ts; checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); } else if (candidateForTypeArgumentError) { - if (!isTaggedTemplate && node.typeArguments) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], true); + if (!isTaggedTemplate && typeArguments) { + checkTypeArguments(candidateForTypeArgumentError, typeArguments, [], true); } else { ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); @@ -15536,7 +15958,9 @@ var ts; if (node.expression.kind === 91) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { - return resolveCall(node, getSignaturesOfType(superType, 1), candidatesOutArray); + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getAncestor(node, 204)); + var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + return resolveCall(node, baseConstructors, candidatesOutArray); } return resolveUntypedCall(node); } @@ -15617,13 +16041,13 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 158) { + if (node.kind === 160) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 159) { + else if (node.kind === 161) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 160) { + else if (node.kind === 162) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } else { @@ -15638,12 +16062,12 @@ var ts; if (node.expression.kind === 91) { return voidType; } - if (node.kind === 159) { + if (node.kind === 161) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 136 && - declaration.kind !== 140 && - declaration.kind !== 144) { + declaration.kind !== 137 && + declaration.kind !== 141 && + declaration.kind !== 146) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } @@ -15690,7 +16114,7 @@ var ts; return unknownType; } var type; - if (func.body.kind !== 180) { + if (func.body.kind !== 182) { type = checkExpressionCached(func.body, contextualMapper); } else { @@ -15767,7 +16191,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 196); + return (body.statements.length === 1) && (body.statements[0].kind === 198); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!produceDiagnostics) { @@ -15776,7 +16200,7 @@ var ts; if (returnType === voidType || isTypeAny(returnType)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 180) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 182) { return; } var bodyBlock = func.body; @@ -15789,10 +16213,10 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 135 || ts.isObjectLiteralMethod(node)); - var hasGrammarError = checkGrammarDeclarationNameInStrictMode(node) || checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 163) { - checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node); + ts.Debug.assert(node.kind !== 136 || ts.isObjectLiteralMethod(node)); + var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); + if (!hasGrammarError && node.kind === 165) { + checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { return anyFunctionType; @@ -15818,14 +16242,14 @@ var ts; checkSignatureDeclaration(node); } } - if (produceDiagnostics && node.kind !== 135 && node.kind !== 134) { + if (produceDiagnostics && node.kind !== 136 && node.kind !== 135) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 135 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 || ts.isObjectLiteralMethod(node)); if (node.type && !node.asteriskToken) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); } @@ -15833,7 +16257,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 180) { + if (node.body.kind === 182) { checkSourceElement(node.body); } else { @@ -15863,13 +16287,13 @@ var ts; var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 156: { + case 158: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; } - case 157: + case 159: return true; - case 162: + case 164: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -15878,11 +16302,11 @@ var ts; function isConstVariableReference(n) { switch (n.kind) { case 65: - case 156: { + case 158: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 8192) !== 0; } - case 157: { + case 159: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 8) { @@ -15892,7 +16316,7 @@ var ts; } return false; } - case 162: + case 164: return isConstVariableReference(n.expression); default: return false; @@ -15909,10 +16333,7 @@ var ts; return true; } function checkDeleteExpression(node) { - if (node.parserContextFlags & 1 && node.expression.kind === 65) { - grammarErrorOnNode(node.expression, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); - } - var operandType = checkExpression(node.expression); + checkExpression(node.expression); return booleanType; } function checkTypeOfExpression(node) { @@ -15924,9 +16345,6 @@ var ts; return undefinedType; } function checkPrefixUnaryExpression(node) { - if ((node.operator === 38 || node.operator === 39)) { - checkGrammarEvalOrArgumentsInStrictMode(node, node.operand); - } var operandType = checkExpression(node.operand); switch (node.operator) { case 33: @@ -15949,7 +16367,6 @@ var ts; return unknownType; } function checkPostfixUnaryExpression(node) { - checkGrammarEvalOrArgumentsInStrictMode(node, node.operand); var operandType = checkExpression(node.operand); var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { @@ -16017,7 +16434,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 225 || p.kind === 226) { + if (p.kind === 227 || p.kind === 228) { var name_12 = p.name; var type = isTypeAny(sourceType) ? sourceType @@ -16042,8 +16459,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 176) { - if (e.kind !== 174) { + if (e.kind !== 178) { + if (e.kind !== 176) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -16068,7 +16485,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 170 && restExpression.operatorToken.kind === 53) { + if (restExpression.kind === 172 && restExpression.operatorToken.kind === 53) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -16081,14 +16498,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 170 && target.operatorToken.kind === 53) { + if (target.kind === 172 && target.operatorToken.kind === 53) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 155) { + if (target.kind === 157) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 154) { + if (target.kind === 156) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -16101,11 +16518,8 @@ var ts; return sourceType; } function checkBinaryExpression(node, contextualMapper) { - if (ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) { - checkGrammarEvalOrArgumentsInStrictMode(node, node.left); - } var operator = node.operatorToken.kind; - if (operator === 53 && (node.left.kind === 155 || node.left.kind === 154)) { + if (operator === 53 && (node.left.kind === 157 || node.left.kind === 156)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); @@ -16251,7 +16665,7 @@ var ts; if (ts.isFunctionLike(parent) && current === parent.body) { return false; } - else if (current.kind === 202 || current.kind === 175) { + else if (current.kind === 204 || current.kind === 177) { return true; } current = parent; @@ -16312,14 +16726,14 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 128) { + if (node.name.kind === 129) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 128) { + if (node.name.kind === 129) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -16341,12 +16755,8 @@ var ts; return type; } function checkExpression(node, contextualMapper) { - checkGrammarIdentifierInStrictMode(node); - return checkExpressionOrQualifiedName(node, contextualMapper); - } - function checkExpressionOrQualifiedName(node, contextualMapper) { var type; - if (node.kind == 127) { + if (node.kind === 128) { type = checkQualifiedName(node); } else { @@ -16354,9 +16764,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 156 && node.parent.expression === node) || - (node.parent.kind === 157 && node.parent.expression === node) || - ((node.kind === 65 || node.kind === 127) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 158 && node.parent.expression === node) || + (node.parent.kind === 159 && node.parent.expression === node) || + ((node.kind === 65 || node.kind === 128) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -16382,60 +16792,59 @@ var ts; return booleanType; case 7: return checkNumericLiteral(node); - case 172: + case 174: return checkTemplateExpression(node); case 8: case 10: return stringType; case 9: return globalRegExpType; - case 154: - return checkArrayLiteral(node, contextualMapper); - case 155: - return checkObjectLiteral(node, contextualMapper); case 156: - return checkPropertyAccessExpression(node); + return checkArrayLiteral(node, contextualMapper); case 157: - return checkIndexedAccess(node); + return checkObjectLiteral(node, contextualMapper); case 158: + return checkPropertyAccessExpression(node); case 159: - return checkCallExpression(node); + return checkIndexedAccess(node); case 160: - return checkTaggedTemplateExpression(node); case 161: - return checkTypeAssertion(node); + return checkCallExpression(node); case 162: - return checkExpression(node.expression, contextualMapper); - case 175: - return checkClassExpression(node); + return checkTaggedTemplateExpression(node); case 163: + return checkTypeAssertion(node); case 164: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 166: - return checkTypeOfExpression(node); + return checkExpression(node.expression, contextualMapper); + case 177: + return checkClassExpression(node); case 165: - return checkDeleteExpression(node); - case 167: - return checkVoidExpression(node); + case 166: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case 168: - return checkPrefixUnaryExpression(node); + return checkTypeOfExpression(node); + case 167: + return checkDeleteExpression(node); case 169: - return checkPostfixUnaryExpression(node); + return checkVoidExpression(node); case 170: - return checkBinaryExpression(node, contextualMapper); + return checkPrefixUnaryExpression(node); case 171: - return checkConditionalExpression(node, contextualMapper); - case 174: - return checkSpreadElementExpression(node, contextualMapper); - case 176: - return undefinedType; + return checkPostfixUnaryExpression(node); + case 172: + return checkBinaryExpression(node, contextualMapper); case 173: + return checkConditionalExpression(node, contextualMapper); + case 176: + return checkSpreadElementExpression(node, contextualMapper); + case 178: + return undefinedType; + case 175: return checkYieldExpression(node); } return unknownType; } function checkTypeParameter(node) { - checkGrammarDeclarationNameInStrictMode(node); if (node.expression) { grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); } @@ -16450,14 +16859,12 @@ var ts; // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the // Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code // or if its FunctionBody is strict code(11.1.5). - // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a - // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEvalOrArgumentsInStrictMode(node, node.name); + checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (node.flags & 112) { func = ts.getContainingFunction(node); - if (!(func.kind === 136 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 137 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -16472,32 +16879,106 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 135 || - node.kind === 201 || - node.kind === 163; + return node.kind === 136 || + node.kind === 203 || + node.kind === 165; + } + function getTypePredicateParameterIndex(parameterList, parameter) { + if (parameterList) { + for (var i = 0; i < parameterList.length; i++) { + var param = parameterList[i]; + if (param.name.kind === 65 && + param.name.text === parameter.text) { + return i; + } + } + } + return -1; + } + function isInLegalTypePredicatePosition(node) { + switch (node.parent.kind) { + case 166: + case 140: + case 203: + case 165: + case 145: + case 136: + case 135: + return node === node.parent.type; + } + return false; } function checkSignatureDeclaration(node) { - if (node.kind === 141) { + if (node.kind === 142) { checkGrammarIndexSignature(node); } - else if (node.kind === 143 || node.kind === 201 || node.kind === 144 || - node.kind === 139 || node.kind === 136 || - node.kind === 140) { + else if (node.kind === 145 || node.kind === 203 || node.kind === 146 || + node.kind === 140 || node.kind === 137 || + node.kind === 141) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - checkSourceElement(node.type); + if (node.type.kind === 143) { + var typePredicate = getSignatureFromDeclaration(node).typePredicate; + var typePredicateNode = node.type; + if (isInLegalTypePredicatePosition(typePredicateNode)) { + if (typePredicate.parameterIndex >= 0) { + if (node.parameters[typePredicate.parameterIndex].dotDotDotToken) { + error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); + } + else { + checkTypeAssignableTo(typePredicate.type, getTypeAtLocation(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); + } + } + else if (typePredicateNode.parameterName) { + var hasReportedError = false; + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var param = _a[_i]; + if (hasReportedError) { + break; + } + if (param.name.kind === 153 || + param.name.kind === 154) { + (function checkBindingPattern(pattern) { + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.name.kind === 65 && + element.name.text === typePredicate.parameterName) { + error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); + hasReportedError = true; + break; + } + else if (element.name.kind === 154 || + element.name.kind === 153) { + checkBindingPattern(element.name); + } + } + })(param.name); + } + } + if (!hasReportedError) { + error(typePredicateNode.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName); + } + } + } + else { + error(typePredicateNode, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + } + } + else { + checkSourceElement(node.type); + } } if (produceDiagnostics) { checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 140: + case 141: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 139: + case 140: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -16519,7 +17000,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 203) { + if (node.kind === 205) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -16534,7 +17015,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 122: + case 123: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -16542,7 +17023,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 120: + case 121: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -16579,17 +17060,17 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 158 && n.expression.kind === 91; + return n.kind === 160 && n.expression.kind === 91; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 163: - case 201: - case 164: - case 155: return false; + case 165: + case 203: + case 166: + case 157: return false; default: return ts.forEachChild(n, containsSuperCall); } } @@ -16597,12 +17078,12 @@ var ts; if (n.kind === 93) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 163 && n.kind !== 201) { + else if (n.kind !== 165 && n.kind !== 203) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 133 && + return n.kind === 134 && !(n.flags & 128) && !!n.initializer; } @@ -16612,7 +17093,7 @@ var ts; ts.forEach(node.parameters, function (p) { return p.flags & (16 | 32 | 64); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 183 || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 185 || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -16628,13 +17109,13 @@ var ts; function checkAccessorDeclaration(node) { if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 137) { + if (node.kind === 138) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 137 ? 138 : 137; + var otherKind = node.kind === 138 ? 139 : 138; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112) !== (otherAccessor.flags & 112))) { @@ -16656,26 +17137,26 @@ var ts; function checkMissingDeclaration(node) { checkDecorators(node); } + function checkTypeArgumentConstraints(typeParameters, typeArguments) { + var result = true; + for (var i = 0; i < typeParameters.length; i++) { + var constraint = getConstraintOfTypeParameter(typeParameters[i]); + if (constraint) { + var typeArgument = typeArguments[i]; + result = result && checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, typeArgument, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + } + } + return result; + } function checkTypeReferenceNode(node) { - checkGrammarTypeReferenceInStrictMode(node.typeName); - return checkTypeReferenceOrExpressionWithTypeArguments(node); - } - function checkExpressionWithTypeArguments(node) { - checkGrammarExpressionWithTypeArgumentsInStrictMode(node.expression); - return checkTypeReferenceOrExpressionWithTypeArguments(node); - } - function checkTypeReferenceOrExpressionWithTypeArguments(node) { checkGrammarTypeArguments(node, node.typeArguments); - var type = getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); + var type = getTypeFromTypeReference(node); if (type !== unknownType && node.typeArguments) { - var len = node.typeArguments.length; - for (var i = 0; i < len; i++) { - checkSourceElement(node.typeArguments[i]); - var constraint = getConstraintOfTypeParameter(type.target.typeParameters[i]); - if (produceDiagnostics && constraint) { - var typeArgument = type.typeArguments[i]; - checkTypeAssignableTo(typeArgument, constraint, node, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); - } + ts.forEach(node.typeArguments, checkSourceElement); + if (produceDiagnostics) { + var symbol = getNodeLinks(node).resolvedSymbol; + var typeParameters = symbol.flags & 524288 ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; + checkTypeArgumentConstraints(typeParameters, node.typeArguments); } } } @@ -16719,9 +17200,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 203) { - ts.Debug.assert(signatureDeclarationNode.kind === 139 || signatureDeclarationNode.kind === 140); - var signatureKind = signatureDeclarationNode.kind === 139 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 205) { + ts.Debug.assert(signatureDeclarationNode.kind === 140 || signatureDeclarationNode.kind === 141); + var signatureKind = signatureDeclarationNode.kind === 140 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -16739,7 +17220,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 203 && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 205 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; } @@ -16812,7 +17293,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - ts.Debug.assert(node.kind === 135 || node.kind === 134); + ts.Debug.assert(node.kind === 136 || node.kind === 135); ts.Debug.assert((node.flags & 128) !== (subsequentNode.flags & 128)); var diagnostic = node.flags & 128 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -16839,11 +17320,11 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 203 || node.parent.kind === 146 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 205 || node.parent.kind === 148 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 201 || node.kind === 135 || node.kind === 134 || node.kind === 136) { + if (node.kind === 203 || node.kind === 136 || node.kind === 135 || node.kind === 137) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -16940,16 +17421,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 203: + case 205: return 2097152; - case 206: + case 208: return d.name.kind === 8 || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 202: - case 205: + case 204: + case 207: return 2097152 | 1048576; - case 209: + case 211: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -16963,54 +17444,54 @@ var ts; var expression = node.expression; var exprType = checkExpression(expression); switch (node.parent.kind) { - case 202: + case 204: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); var classDecoratorType = instantiateSingleCallFunctionType(getGlobalClassDecoratorType(), [classConstructorType]); checkTypeAssignableTo(exprType, classDecoratorType, node); break; - case 133: + case 134: checkTypeAssignableTo(exprType, getGlobalPropertyDecoratorType(), node); break; - case 135: - case 137: + case 136: case 138: + case 139: var methodType = getTypeOfNode(node.parent); var methodDecoratorType = instantiateSingleCallFunctionType(getGlobalMethodDecoratorType(), [methodType]); checkTypeAssignableTo(exprType, methodDecoratorType, node); break; - case 130: + case 131: checkTypeAssignableTo(exprType, getGlobalParameterDecoratorType(), node); break; } } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 142) { + if (node && node.kind === 144) { var type = getTypeFromTypeNode(node); var shouldCheckIfUnknownType = type === unknownType && compilerOptions.isolatedModules; if (!type || (!shouldCheckIfUnknownType && type.flags & (2097279 | 132 | 258))) { return; } if (shouldCheckIfUnknownType || type.symbol.valueDeclaration) { - checkExpressionOrQualifiedName(node.typeName); + checkExpression(node.typeName); } } } function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 133: + case 134: checkTypeNodeAsExpression(node.type); break; - case 130: + case 131: checkTypeNodeAsExpression(node.type); break; - case 135: - checkTypeNodeAsExpression(node.type); - break; - case 137: + case 136: checkTypeNodeAsExpression(node.type); break; case 138: + checkTypeNodeAsExpression(node.type); + break; + case 139: checkTypeNodeAsExpression(getSetAccessorTypeAnnotationNode(node)); break; } @@ -17033,43 +17514,40 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 202: + case 204: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 135: + case 136: checkParameterTypeAnnotationsAsExpressions(node); + case 139: case 138: - case 137: - case 133: - case 130: + case 134: + case 131: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 130) { + if (node.kind === 131) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); } function checkFunctionDeclaration(node) { if (produceDiagnostics) { - checkFunctionLikeDeclaration(node) || - checkGrammarFunctionName(node.name) || - checkGrammarForGenerator(node); + checkFunctionLikeDeclaration(node) || checkGrammarForGenerator(node); checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); } } function checkFunctionLikeDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSignatureDeclaration(node); - if (node.name && node.name.kind === 128) { + if (node.name && node.name.kind === 129) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -17099,11 +17577,11 @@ var ts; } } function checkBlock(node) { - if (node.kind === 180) { + if (node.kind === 182) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 207) { + if (ts.isFunctionBlock(node) || node.kind === 209) { checkFunctionExpressionBodies(node); } } @@ -17121,19 +17599,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 133 || - node.kind === 132 || + if (node.kind === 134 || + node.kind === 133 || + node.kind === 136 || node.kind === 135 || - node.kind === 134 || - node.kind === 137 || - node.kind === 138) { + node.kind === 138 || + node.kind === 139) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 130 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 131 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -17163,7 +17641,7 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; } - var enclosingClass = ts.getAncestor(node, 202); + var enclosingClass = ts.getAncestor(node, 204); if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { return; } @@ -17181,11 +17659,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 206 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 208 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 228 && ts.isExternalModule(parent)) { + if (parent.kind === 230 && ts.isExternalModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -17196,7 +17674,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 12288) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 199 && !node.initializer) { + if (node.kind === 201 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -17206,15 +17684,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 12288) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 200); - var container = varDeclList.parent.kind === 181 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 202); + var container = varDeclList.parent.kind === 183 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 180 && ts.isFunctionLike(container.parent) || - container.kind === 207 || - container.kind === 206 || - container.kind === 228); + (container.kind === 182 && ts.isFunctionLike(container.parent) || + container.kind === 209 || + container.kind === 208 || + container.kind === 230); if (!namesShareScope) { var name_13 = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_13, name_13); @@ -17224,7 +17702,7 @@ var ts; } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 130) { + if (ts.getRootDeclaration(node).kind !== 131) { return; } var func = ts.getContainingFunction(node); @@ -17233,7 +17711,7 @@ var ts; if (n.kind === 65) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 130) { + if (referencedSymbol.valueDeclaration.kind === 131) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -17251,10 +17729,9 @@ var ts; } } function checkVariableLikeDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 128) { + if (node.name.kind === 129) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -17263,7 +17740,7 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 130 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 131 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -17291,9 +17768,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 133 && node.kind !== 132) { + if (node.kind !== 134 && node.kind !== 133) { checkExportsOnMergedDeclarations(node); - if (node.kind === 199 || node.kind === 153) { + if (node.kind === 201 || node.kind === 155) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -17322,7 +17799,7 @@ var ts; } function inBlockOrObjectLiteralExpression(node) { while (node) { - if (node.kind === 180 || node.kind === 155) { + if (node.kind === 182 || node.kind === 157) { return true; } node = node.parent; @@ -17350,12 +17827,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind == 200) { + if (node.initializer && node.initializer.kind === 202) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 200) { + if (node.initializer.kind === 202) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -17370,13 +17847,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 200) { + if (node.initializer.kind === 202) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 154 || varExpr.kind === 155) { + if (varExpr.kind === 156 || varExpr.kind === 157) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -17391,7 +17868,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 200) { + if (node.initializer.kind === 202) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -17401,7 +17878,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 154 || varExpr.kind === 155) { + if (varExpr.kind === 156 || varExpr.kind === 157) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { @@ -17563,7 +18040,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 137 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 138))); + return !!(node.kind === 138 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 139))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -17575,31 +18052,28 @@ var ts; if (node.expression) { var func = ts.getContainingFunction(node); if (func) { - var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); + var signature = getSignatureFromDeclaration(func); + var returnType = getReturnTypeOfSignature(signature); var exprType = checkExpressionCached(node.expression); if (func.asteriskToken) { return; } - if (func.kind === 138) { + if (func.kind === 139) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 136) { + else if (func.kind === 137) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } - else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func)) { + else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { checkTypeAssignableTo(exprType, returnType, node.expression, undefined); } } } } function checkWithStatement(node) { - if (!checkGrammarStatementInAmbientContext(node)) { - if (node.parserContextFlags & 1) { - grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); - } - } + checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); } @@ -17609,7 +18083,7 @@ var ts; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 222 && !hasDuplicateDefaultClause) { + if (clause.kind === 224 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -17621,7 +18095,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 221) { + if (produceDiagnostics && clause.kind === 223) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { @@ -17638,7 +18112,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 195 && current.label.text === node.label.text) { + if (current.kind === 197 && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -17682,7 +18156,6 @@ var ts; grammarErrorOnNode(localSymbol.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); } } - checkGrammarEvalOrArgumentsInStrictMode(node, catchClause.variableDeclaration.name); } } checkBlock(catchClause.block); @@ -17702,7 +18175,7 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1); }); - if (type.flags & 1024 && type.symbol.valueDeclaration.kind === 202) { + if (type.flags & 1024 && type.symbol.valueDeclaration.kind === 204) { var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -17733,7 +18206,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 128 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 129 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -17783,7 +18256,6 @@ var ts; return unknownType; } function checkClassDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node); if (!node.name && !(node.flags & 256)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } @@ -17801,35 +18273,38 @@ var ts; var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - if (!ts.isSupportedExpressionWithTypeArguments(baseTypeNode)) { - error(baseTypeNode.expression, ts.Diagnostics.Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses); - } emitExtends = emitExtends || !ts.isInAmbientContext(node); - checkExpressionWithTypeArguments(baseTypeNode); - } - var baseTypes = getBaseTypes(type); - if (baseTypes.length) { - if (produceDiagnostics) { + var baseTypes = getBaseTypes(type); + if (baseTypes.length && produceDiagnostics) { var baseType = baseTypes[0]; + var staticBaseType = getBaseConstructorTypeOfClass(type); + if (baseTypeNode.typeArguments) { + ts.forEach(baseTypeNode.typeArguments, checkSourceElement); + for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { + var constructor = _a[_i]; + if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { + break; + } + } + } checkTypeAssignableTo(type, baseType, node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); - var staticBaseType = getTypeOfSymbol(baseType.symbol); - checkTypeAssignableTo(staticType, getTypeWithoutConstructors(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseType.symbol !== resolveEntityName(baseTypeNode.expression, 107455)) { - error(baseTypeNode, ts.Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType)); + checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32)) { + var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); + if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType; })) { + error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); + } } checkKindsOfPropertyMemberOverrides(type, baseType); } } - if (baseTypes.length || (baseTypeNode && compilerOptions.isolatedModules)) { - checkExpressionOrQualifiedName(baseTypeNode.expression); - } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { ts.forEach(implementedTypeNodes, function (typeRefNode) { if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } - checkExpressionWithTypeArguments(typeRefNode); + checkTypeReferenceNode(typeRefNode); if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { @@ -17911,7 +18386,7 @@ var ts; } } function isAccessor(kind) { - return kind === 137 || kind === 138; + return kind === 138 || kind === 139; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -17971,13 +18446,13 @@ var ts; return ok; } function checkInterfaceDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); checkTypeParameters(node.typeParameters); if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 203); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 205); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -17997,7 +18472,7 @@ var ts; if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) { error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments); } - checkExpressionWithTypeArguments(heritageElement); + checkTypeReferenceNode(heritageElement); }); ts.forEach(node.members, checkSourceElement); if (produceDiagnostics) { @@ -18018,7 +18493,7 @@ var ts; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 128 && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 129 && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; @@ -18054,7 +18529,7 @@ var ts; return evalConstant(initializer); function evalConstant(e) { switch (e.kind) { - case 168: + case 170: var value = evalConstant(e.operand); if (value === undefined) { return undefined; @@ -18065,7 +18540,7 @@ var ts; case 47: return ~value; } return undefined; - case 170: + case 172: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -18090,11 +18565,11 @@ var ts; return undefined; case 7: return +e.text; - case 162: + case 164: return evalConstant(e.expression); case 65: - case 157: - case 156: + case 159: + case 158: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType; @@ -18105,7 +18580,7 @@ var ts; } else { var expression; - if (e.kind === 157) { + if (e.kind === 159) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 8) { return undefined; @@ -18122,7 +18597,7 @@ var ts; if (current.kind === 65) { break; } - else if (current.kind === 156) { + else if (current.kind === 158) { current = current.expression; } else { @@ -18157,7 +18632,7 @@ var ts; if (!produceDiagnostics) { return; } - checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -18179,7 +18654,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 205) { + if (declaration.kind !== 207) { return false; } var enumDeclaration = declaration; @@ -18202,8 +18677,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 202 || - (declaration.kind === 201 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 204 || + (declaration.kind === 203 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -18225,7 +18700,14 @@ var ts; } function checkModuleDeclaration(node) { if (produceDiagnostics) { - if (!checkGrammarDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { + var isAmbientExternalModule = node.name.kind === 8; + var contextErrorMessage = isAmbientExternalModule + ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file + : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; + if (checkGrammarModuleElementContext(node, contextErrorMessage)) { + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { if (!ts.isInAmbientContext(node) && node.name.kind === 8) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } @@ -18247,13 +18729,13 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 202); + var mergedClass = ts.getDeclarationOfKind(symbol, 204); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 2048; } } - if (node.name.kind === 8) { + if (isAmbientExternalModule) { if (!isGlobalSourceFile(node.parent)) { error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules); } @@ -18266,10 +18748,10 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 127) { + if (node.kind === 128) { node = node.left; } - else if (node.kind === 156) { + else if (node.kind === 158) { node = node.expression; } else { @@ -18285,9 +18767,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 207 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 228 && !inAmbientExternalModule) { - error(moduleName, node.kind === 216 ? + var inAmbientExternalModule = node.parent.kind === 209 && node.parent.parent.name.kind === 8; + if (node.parent.kind !== 230 && !inAmbientExternalModule) { + error(moduleName, node.kind === 218 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -18306,7 +18788,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 218 ? + var message = node.kind === 220 ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -18319,7 +18801,10 @@ var ts; checkAliasSymbol(node); } function checkImportDeclaration(node) { - if (!checkGrammarImportDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -18329,7 +18814,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 212) { + if (importClause.namedBindings.kind === 214) { checkImportBinding(importClause.namedBindings); } else { @@ -18340,7 +18825,10 @@ var ts; } } function checkImportEqualsDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node); + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { + return; + } + checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); if (node.flags & 1) { @@ -18368,14 +18856,17 @@ var ts; } } function checkExportDeclaration(node) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { + return; + } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 207 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 228 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 209 && node.parent.parent.name.kind === 8; + if (node.parent.kind !== 230 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -18387,6 +18878,11 @@ var ts; } } } + function checkGrammarModuleElementContext(node, errorMessage) { + if (node.parent.kind !== 230 && node.parent.kind !== 209 && node.parent.kind !== 208) { + return grammarErrorOnFirstToken(node, errorMessage); + } + } function checkExportSpecifier(node) { checkAliasSymbol(node); if (!node.parent.parent.moduleSpecifier) { @@ -18394,8 +18890,11 @@ var ts; } } function checkExportAssignment(node) { - var container = node.parent.kind === 228 ? node.parent : node.parent.parent; - if (container.kind === 206 && container.name.kind === 65) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { + return; + } + var container = node.parent.kind === 230 ? node.parent : node.parent.parent; + if (container.kind === 208 && container.name.kind === 65) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -18419,10 +18918,10 @@ var ts; } } function getModuleStatements(node) { - if (node.kind === 228) { + if (node.kind === 230) { return node.statements; } - if (node.kind === 206 && node.body.kind === 207) { + if (node.kind === 208 && node.body.kind === 209) { return node.body.statements; } return emptyArray; @@ -18447,170 +18946,175 @@ var ts; links.exportsChecked = true; } } + function checkTypePredicate(node) { + if (!isInLegalTypePredicatePosition(node)) { + error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + } + } function checkSourceElement(node) { if (!node) return; switch (node.kind) { - case 129: - return checkTypeParameter(node); case 130: + return checkTypeParameter(node); + case 131: return checkParameter(node); + case 134: case 133: - case 132: return checkPropertyDeclaration(node); - case 143: - case 144: - case 139: + case 145: + case 146: case 140: - return checkSignatureDeclaration(node); case 141: return checkSignatureDeclaration(node); - case 135: - case 134: - return checkMethodDeclaration(node); - case 136: - return checkConstructorDeclaration(node); - case 137: - case 138: - return checkAccessorDeclaration(node); case 142: + return checkSignatureDeclaration(node); + case 136: + case 135: + return checkMethodDeclaration(node); + case 137: + return checkConstructorDeclaration(node); + case 138: + case 139: + return checkAccessorDeclaration(node); + case 144: return checkTypeReferenceNode(node); - case 145: - return checkTypeQuery(node); - case 146: - return checkTypeLiteral(node); + case 143: + return checkTypePredicate(node); case 147: - return checkArrayType(node); + return checkTypeQuery(node); case 148: - return checkTupleType(node); + return checkTypeLiteral(node); case 149: - return checkUnionType(node); + return checkArrayType(node); case 150: + return checkTupleType(node); + case 151: + return checkUnionType(node); + case 152: return checkSourceElement(node.type); - case 201: - return checkFunctionDeclaration(node); - case 180: - case 207: - return checkBlock(node); - case 181: - return checkVariableStatement(node); - case 183: - return checkExpressionStatement(node); - case 184: - return checkIfStatement(node); - case 185: - return checkDoStatement(node); - case 186: - return checkWhileStatement(node); - case 187: - return checkForStatement(node); - case 188: - return checkForInStatement(node); - case 189: - return checkForOfStatement(node); - case 190: - case 191: - return checkBreakOrContinueStatement(node); - case 192: - return checkReturnStatement(node); - case 193: - return checkWithStatement(node); - case 194: - return checkSwitchStatement(node); - case 195: - return checkLabeledStatement(node); - case 196: - return checkThrowStatement(node); - case 197: - return checkTryStatement(node); - case 199: - return checkVariableDeclaration(node); - case 153: - return checkBindingElement(node); - case 202: - return checkClassDeclaration(node); case 203: - return checkInterfaceDeclaration(node); - case 204: - return checkTypeAliasDeclaration(node); - case 205: - return checkEnumDeclaration(node); - case 206: - return checkModuleDeclaration(node); - case 210: - return checkImportDeclaration(node); - case 209: - return checkImportEqualsDeclaration(node); - case 216: - return checkExportDeclaration(node); - case 215: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); case 182: - checkGrammarStatementInAmbientContext(node); - return; + case 209: + return checkBlock(node); + case 183: + return checkVariableStatement(node); + case 185: + return checkExpressionStatement(node); + case 186: + return checkIfStatement(node); + case 187: + return checkDoStatement(node); + case 188: + return checkWhileStatement(node); + case 189: + return checkForStatement(node); + case 190: + return checkForInStatement(node); + case 191: + return checkForOfStatement(node); + case 192: + case 193: + return checkBreakOrContinueStatement(node); + case 194: + return checkReturnStatement(node); + case 195: + return checkWithStatement(node); + case 196: + return checkSwitchStatement(node); + case 197: + return checkLabeledStatement(node); case 198: + return checkThrowStatement(node); + case 199: + return checkTryStatement(node); + case 201: + return checkVariableDeclaration(node); + case 155: + return checkBindingElement(node); + case 204: + return checkClassDeclaration(node); + case 205: + return checkInterfaceDeclaration(node); + case 206: + return checkTypeAliasDeclaration(node); + case 207: + return checkEnumDeclaration(node); + case 208: + return checkModuleDeclaration(node); + case 212: + return checkImportDeclaration(node); + case 211: + return checkImportEqualsDeclaration(node); + case 218: + return checkExportDeclaration(node); + case 217: + return checkExportAssignment(node); + case 184: checkGrammarStatementInAmbientContext(node); return; - case 219: + case 200: + checkGrammarStatementInAmbientContext(node); + return; + case 221: return checkMissingDeclaration(node); } } function checkFunctionExpressionBodies(node) { switch (node.kind) { - case 163: - case 164: + case 165: + case 166: ts.forEach(node.parameters, checkFunctionExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; + case 136: case 135: - case 134: ts.forEach(node.decorators, checkFunctionExpressionBodies); ts.forEach(node.parameters, checkFunctionExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 136: case 137: case 138: - case 201: + case 139: + case 203: ts.forEach(node.parameters, checkFunctionExpressionBodies); break; - case 193: + case 195: checkFunctionExpressionBodies(node.expression); break; - case 131: - case 130: - case 133: case 132: - case 151: - case 152: + case 131: + case 134: + case 133: case 153: case 154: case 155: - case 225: case 156: case 157: + case 227: case 158: case 159: case 160: - case 172: - case 178: case 161: case 162: - case 166: - case 167: - case 165: - case 168: - case 169: - case 170: - case 171: case 174: case 180: - case 207: - case 181: + case 163: + case 164: + case 168: + case 169: + case 167: + case 170: + case 171: + case 172: + case 173: + case 176: + case 182: + case 209: case 183: - case 184: case 185: case 186: case 187: @@ -18619,21 +19123,23 @@ var ts; case 190: case 191: case 192: + case 193: case 194: - case 208: - case 221: - case 222: - case 195: case 196: - case 197: + case 210: + case 223: case 224: + case 197: + case 198: case 199: - case 200: + case 226: + case 201: case 202: - case 205: - case 227: - case 215: - case 228: + case 204: + case 207: + case 229: + case 217: + case 230: ts.forEachChild(node, checkFunctionExpressionBodies); break; } @@ -18646,6 +19152,9 @@ var ts; function checkSourceFileWorker(node) { var links = getNodeLinks(node); if (!(links.flags & 1)) { + if (node.isDefaultLib && compilerOptions.skipDefaultLibCheck) { + return; + } checkGrammarSourceFile(node); emitExtends = false; emitDecorate = false; @@ -18693,7 +19202,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 193 && node.parent.statement === node) { + if (node.parent.kind === 195 && node.parent.statement === node) { return true; } node = node.parent; @@ -18715,23 +19224,23 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 228: + case 230: if (!ts.isExternalModule(location)) { break; } - case 206: + case 208: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 205: + case 207: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 202: - case 203: + case 204: + case 205: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 163: + case 165: if (location.name) { copySymbol(location.symbol, meaning); } @@ -18767,22 +19276,22 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 228: + case 230: if (!ts.isExternalModule(location)) break; - case 206: + case 208: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 205: + case 207: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 202: - case 203: + case 204: + case 205: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 163: + case 165: if (location.name) { copySymbol(location.symbol, meaning); } @@ -18795,42 +19304,42 @@ var ts; return symbolsToArray(symbols); } function isTypeDeclarationName(name) { - return name.kind == 65 && + return name.kind === 65 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 129: - case 202: - case 203: + case 130: case 204: case 205: + case 206: + case 207: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 127) { + while (node.parent && node.parent.kind === 128) { node = node.parent; } - return node.parent && node.parent.kind === 142; + return node.parent && node.parent.kind === 144; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 156) { + while (node.parent && node.parent.kind === 158) { node = node.parent; } - return node.parent && node.parent.kind === 177; + return node.parent && node.parent.kind === 179; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 127) { + while (nodeOnRightSide.parent.kind === 128) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 209) { + if (nodeOnRightSide.parent.kind === 211) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 215) { + if (nodeOnRightSide.parent.kind === 217) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -18842,10 +19351,10 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 215) { + if (entityName.parent.kind === 217) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 156) { + if (entityName.kind !== 158) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -18854,7 +19363,7 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 177 ? 793056 : 1536; + var meaning = entityName.parent.kind === 179 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } @@ -18866,14 +19375,14 @@ var ts; var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 156) { + else if (entityName.kind === 158) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 127) { + else if (entityName.kind === 128) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -18882,7 +19391,7 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 142 ? 793056 : 1536; + var meaning = entityName.parent.kind === 144 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } @@ -18896,14 +19405,14 @@ var ts; return getSymbolOfNode(node.parent); } if (node.kind === 65 && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 215 + return node.parent.kind === 217 ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } switch (node.kind) { case 65: - case 156: - case 127: + case 158: + case 128: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 93: case 91: @@ -18911,7 +19420,7 @@ var ts; return type.symbol; case 114: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 136) { + if (constructorDeclaration && constructorDeclaration.kind === 137) { return constructorDeclaration.parent.symbol; } return undefined; @@ -18919,12 +19428,12 @@ var ts; var moduleName; if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 210 || node.parent.kind === 216) && + ((node.parent.kind === 212 || node.parent.kind === 218) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } case 7: - if (node.parent.kind == 157 && node.parent.argumentExpression === node) { + if (node.parent.kind === 159 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -18938,7 +19447,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 226) { + if (location && location.kind === 228) { return resolveEntityName(location.name, 107455); } return undefined; @@ -18953,6 +19462,9 @@ var ts; if (ts.isExpression(node)) { return getTypeOfExpression(node); } + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(node)) { + return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; + } if (isTypeDeclaration(node)) { var symbol = getSymbolOfNode(node); return getDeclaredTypeOfSymbol(symbol); @@ -19011,81 +19523,81 @@ var ts; } return [symbol]; } - function isExternalModuleSymbol(symbol) { - return symbol.flags & 512 && symbol.declarations.length === 1 && symbol.declarations[0].kind === 228; - } - function getAliasNameSubstitution(symbol, getGeneratedNameForNode) { - if (languageVersion >= 2) { - return undefined; - } - var node = getDeclarationOfAliasSymbol(symbol); - if (node) { - if (node.kind === 211) { - var defaultKeyword; - if (languageVersion === 0) { - defaultKeyword = "[\"default\"]"; - } - else { - defaultKeyword = ".default"; - } - return getGeneratedNameForNode(node.parent) + defaultKeyword; - } - if (node.kind === 214) { - var moduleName = getGeneratedNameForNode(node.parent.parent.parent); - var propertyName = node.propertyName || node.name; - return moduleName + "." + ts.unescapeIdentifier(propertyName.text); - } - } - } - function getExportNameSubstitution(symbol, location, getGeneratedNameForNode) { - if (isExternalModuleSymbol(symbol.parent)) { - if (languageVersion >= 2 || compilerOptions.module === 4) { - return undefined; - } - return "exports." + ts.unescapeIdentifier(symbol.name); - } - var node = location; - var containerSymbol = getParentOfSymbol(symbol); - while (node) { - if ((node.kind === 206 || node.kind === 205) && getSymbolOfNode(node) === containerSymbol) { - return getGeneratedNameForNode(node) + "." + ts.unescapeIdentifier(symbol.name); - } - node = node.parent; - } - } - function getExpressionNameSubstitution(node, getGeneratedNameForNode) { - var symbol = getNodeLinks(node).resolvedSymbol || (ts.isDeclarationName(node) ? getSymbolOfNode(node.parent) : undefined); + function getReferencedExportContainer(node) { + var symbol = getReferencedValueSymbol(node); if (symbol) { - if (symbol.parent) { - return getExportNameSubstitution(symbol, node.parent, getGeneratedNameForNode); + if (symbol.flags & 1048576) { + var exportSymbol = getMergedSymbol(symbol.exportSymbol); + if (exportSymbol.flags & 944) { + return undefined; + } + symbol = exportSymbol; } - var exportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); - if (symbol !== exportSymbol && !(exportSymbol.flags & 944)) { - return getExportNameSubstitution(exportSymbol, node.parent, getGeneratedNameForNode); - } - if (symbol.flags & 8388608) { - return getAliasNameSubstitution(symbol, getGeneratedNameForNode); + var parentSymbol = getParentOfSymbol(symbol); + if (parentSymbol) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 230) { + return parentSymbol.valueDeclaration; + } + for (var n = node.parent; n; n = n.parent) { + if ((n.kind === 208 || n.kind === 207) && getSymbolOfNode(n) === parentSymbol) { + return n; + } + } } } } + function getReferencedImportDeclaration(node) { + var symbol = getReferencedValueSymbol(node); + return symbol && symbol.flags & 8388608 ? getDeclarationOfAliasSymbol(symbol) : undefined; + } + function isStatementWithLocals(node) { + switch (node.kind) { + case 182: + case 210: + case 189: + case 190: + case 191: + return true; + } + return false; + } + function isNestedRedeclarationSymbol(symbol) { + if (symbol.flags & 418) { + var links = getSymbolLinks(symbol); + if (links.isNestedRedeclaration === undefined) { + var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); + links.isNestedRedeclaration = isStatementWithLocals(container) && + !!resolveName(container.parent, symbol.name, 107455, undefined, undefined); + } + return links.isNestedRedeclaration; + } + return false; + } + function getReferencedNestedRedeclaration(node) { + var symbol = getReferencedValueSymbol(node); + return symbol && isNestedRedeclarationSymbol(symbol) ? symbol.valueDeclaration : undefined; + } + function isNestedRedeclaration(node) { + return isNestedRedeclarationSymbol(getSymbolOfNode(node)); + } function isValueAliasDeclaration(node) { switch (node.kind) { - case 209: case 211: - case 212: + case 213: case 214: - case 218: - return isAliasResolvedToValue(getSymbolOfNode(node)); case 216: + case 220: + return isAliasResolvedToValue(getSymbolOfNode(node)); + case 218: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 215: + case 217: return node.expression && node.expression.kind === 65 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 228 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 230 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -19130,7 +19642,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 227) { + if (node.kind === 229) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -19141,10 +19653,9 @@ var ts; } return undefined; } - function serializeEntityName(node, getGeneratedNameForNode, fallbackPath) { + function serializeEntityName(node, fallbackPath) { if (node.kind === 65) { - var substitution = getExpressionNameSubstitution(node, getGeneratedNameForNode); - var text = substitution || node.text; + var text = node.text; if (fallbackPath) { fallbackPath.push(text); } @@ -19153,14 +19664,14 @@ var ts; } } else { - var left = serializeEntityName(node.left, getGeneratedNameForNode, fallbackPath); - var right = serializeEntityName(node.right, getGeneratedNameForNode, fallbackPath); + var left = serializeEntityName(node.left, fallbackPath); + var right = serializeEntityName(node.right, fallbackPath); if (!fallbackPath) { return left + "." + right; } } } - function serializeTypeReferenceNode(node, getGeneratedNameForNode) { + function serializeTypeReferenceNode(node) { var type = getTypeFromTypeNode(node); if (type.flags & 16) { return "void 0"; @@ -19182,42 +19693,42 @@ var ts; } else if (type === unknownType) { var fallbackPath = []; - serializeEntityName(node.typeName, getGeneratedNameForNode, fallbackPath); + serializeEntityName(node.typeName, fallbackPath); return fallbackPath; } else if (type.symbol && type.symbol.valueDeclaration) { - return serializeEntityName(node.typeName, getGeneratedNameForNode); + return serializeEntityName(node.typeName); } else if (typeHasCallOrConstructSignatures(type)) { return "Function"; } return "Object"; } - function serializeTypeNode(node, getGeneratedNameForNode) { + function serializeTypeNode(node) { if (node) { switch (node.kind) { case 99: return "void 0"; - case 150: - return serializeTypeNode(node.type, getGeneratedNameForNode); - case 143: - case 144: + case 152: + return serializeTypeNode(node.type); + case 145: + case 146: return "Function"; - case 147: - case 148: + case 149: + case 150: return "Array"; case 113: return "Boolean"; - case 122: + case 123: case 8: return "String"; - case 120: + case 121: return "Number"; - case 142: - return serializeTypeReferenceNode(node, getGeneratedNameForNode); - case 145: - case 146: - case 149: + case 144: + return serializeTypeReferenceNode(node); + case 147: + case 148: + case 151: case 112: break; default: @@ -19227,23 +19738,23 @@ var ts; } return "Object"; } - function serializeTypeOfNode(node, getGeneratedNameForNode) { + function serializeTypeOfNode(node) { switch (node.kind) { - case 202: return "Function"; - case 133: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 130: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 137: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 138: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node), getGeneratedNameForNode); + case 204: return "Function"; + case 134: return serializeTypeNode(node.type); + case 131: return serializeTypeNode(node.type); + case 138: return serializeTypeNode(node.type); + case 139: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node)); } if (ts.isFunctionLike(node)) { return "Function"; } return "void 0"; } - function serializeParameterTypesOfNode(node, getGeneratedNameForNode) { + function serializeParameterTypesOfNode(node) { if (node) { var valueDeclaration; - if (node.kind === 202) { + if (node.kind === 204) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -19258,19 +19769,19 @@ var ts; for (var i = 0; i < parameterCount; i++) { if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 147) { + if (parameterType.kind === 149) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 142 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 144 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { parameterType = undefined; } - result[i] = serializeTypeNode(parameterType, getGeneratedNameForNode); + result[i] = serializeTypeNode(parameterType); } else { - result[i] = serializeTypeOfNode(parameters[i], getGeneratedNameForNode); + result[i] = serializeTypeOfNode(parameters[i]); } } return result; @@ -19279,9 +19790,9 @@ var ts; } return emptyArray; } - function serializeReturnTypeOfNode(node, getGeneratedNameForNode) { + function serializeReturnTypeOfNode(node) { if (node && ts.isFunctionLike(node)) { - return serializeTypeNode(node.type, getGeneratedNameForNode); + return serializeTypeNode(node.type); } return "void 0"; } @@ -19303,25 +19814,24 @@ var ts; function hasGlobalName(name) { return ts.hasProperty(globals, name); } - function resolvesToSomeValue(location, name) { - ts.Debug.assert(!ts.nodeIsSynthesized(location), "resolvesToSomeValue called with a synthesized location"); - return !!resolveName(location, name, 107455, undefined, undefined); + function getReferencedValueSymbol(reference) { + return getNodeLinks(reference).resolvedSymbol || + resolveName(reference, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); } function getReferencedValueDeclaration(reference) { ts.Debug.assert(!ts.nodeIsSynthesized(reference)); - var symbol = getNodeLinks(reference).resolvedSymbol || - resolveName(reference, reference.text, 107455 | 8388608, undefined, undefined); + var symbol = getReferencedValueSymbol(reference); return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 153 || (n.parent.kind === 199 && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 155 || (n.parent.kind === 201 && n.parent.name === n); var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, 107455 | 8388608, undefined, undefined); var isLetOrConst = symbol && (symbol.flags & 2) && - symbol.valueDeclaration.parent.kind !== 224; + symbol.valueDeclaration.parent.kind !== 226; if (isLetOrConst) { getSymbolLinks(symbol); return symbol.id; @@ -19341,7 +19851,10 @@ var ts; } function createResolver() { return { - getExpressionNameSubstitution: getExpressionNameSubstitution, + getReferencedExportContainer: getReferencedExportContainer, + getReferencedImportDeclaration: getReferencedImportDeclaration, + getReferencedNestedRedeclaration: getReferencedNestedRedeclaration, + isNestedRedeclaration: isNestedRedeclaration, isValueAliasDeclaration: isValueAliasDeclaration, hasGlobalName: hasGlobalName, isReferencedAliasDeclaration: isReferencedAliasDeclaration, @@ -19355,7 +19868,6 @@ var ts; isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, getConstantValue: getConstantValue, - resolvesToSomeValue: resolvesToSomeValue, collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, @@ -19406,105 +19918,6 @@ var ts; } anyArrayType = createArrayType(anyType); } - function isReservedWordInStrictMode(node) { - return (node.parserContextFlags & 1) && - (102 <= node.originalKeywordKind && node.originalKeywordKind <= 110); - } - function reportStrictModeGrammarErrorInClassDeclaration(identifier, message, arg0, arg1, arg2) { - if (ts.getAncestor(identifier, 202) || ts.getAncestor(identifier, 175)) { - return grammarErrorOnNode(identifier, message, arg0); - } - return false; - } - function checkGrammarImportDeclarationNameInStrictMode(node) { - if (node.importClause) { - var impotClause = node.importClause; - if (impotClause.namedBindings) { - var nameBindings = impotClause.namedBindings; - if (nameBindings.kind === 212) { - var name_15 = nameBindings.name; - if (isReservedWordInStrictMode(name_15)) { - var nameText = ts.declarationNameToString(name_15); - return grammarErrorOnNode(name_15, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - } - } - else if (nameBindings.kind === 213) { - var reportError = false; - for (var _i = 0, _a = nameBindings.elements; _i < _a.length; _i++) { - var element = _a[_i]; - var name_16 = element.name; - if (isReservedWordInStrictMode(name_16)) { - var nameText = ts.declarationNameToString(name_16); - reportError = reportError || grammarErrorOnNode(name_16, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - } - } - return reportError; - } - } - } - return false; - } - function checkGrammarDeclarationNameInStrictMode(node) { - var name = node.name; - if (name && name.kind === 65 && isReservedWordInStrictMode(name)) { - var nameText = ts.declarationNameToString(name); - switch (node.kind) { - case 130: - case 199: - case 201: - case 129: - case 153: - case 203: - case 204: - case 205: - return checkGrammarIdentifierInStrictMode(name); - case 202: - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText); - case 206: - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - case 209: - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - } - } - return false; - } - function checkGrammarTypeReferenceInStrictMode(typeName) { - if (typeName.kind === 65) { - checkGrammarTypeNameInStrictMode(typeName); - } - else if (typeName.kind === 127) { - checkGrammarTypeNameInStrictMode(typeName.right); - checkGrammarTypeReferenceInStrictMode(typeName.left); - } - } - function checkGrammarExpressionWithTypeArgumentsInStrictMode(expression) { - if (expression && expression.kind === 65) { - return checkGrammarIdentifierInStrictMode(expression); - } - else if (expression && expression.kind === 156) { - checkGrammarExpressionWithTypeArgumentsInStrictMode(expression.expression); - } - } - function checkGrammarIdentifierInStrictMode(node, nameText) { - if (node && node.kind === 65 && isReservedWordInStrictMode(node)) { - if (!nameText) { - nameText = ts.declarationNameToString(node); - } - var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) || - grammarErrorOnNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - return errorReport; - } - return false; - } - function checkGrammarTypeNameInStrictMode(node) { - if (node && node.kind === 65 && isReservedWordInStrictMode(node)) { - var nameText = ts.declarationNameToString(node); - var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) || - grammarErrorOnNode(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode, nameText); - return errorReport; - } - return false; - } function checkGrammarDecorators(node) { if (!node.decorators) { return false; @@ -19515,7 +19928,7 @@ var ts; else if (languageVersion < 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); } - else if (node.kind === 137 || node.kind === 138) { + else if (node.kind === 138 || node.kind === 139) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -19525,33 +19938,33 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 137: case 138: - case 136: - case 133: - case 132: - case 135: + case 139: + case 137: case 134: - case 141: - case 206: - case 210: - case 209: - case 216: - case 215: - case 130: + case 133: + case 136: + case 135: + case 142: + case 208: + case 212: + case 211: + case 218: + case 217: + case 131: break; - case 202: - case 203: - case 181: - case 201: case 204: - if (node.modifiers && node.parent.kind !== 207 && node.parent.kind !== 228) { + case 205: + case 183: + case 203: + case 206: + if (node.modifiers && node.parent.kind !== 209 && node.parent.kind !== 230) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 205: + case 207: if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 70) && - node.parent.kind !== 207 && node.parent.kind !== 228) { + node.parent.kind !== 209 && node.parent.kind !== 230) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -19587,7 +20000,7 @@ var ts; else if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (node.parent.kind === 207 || node.parent.kind === 228) { + else if (node.parent.kind === 209 || node.parent.kind === 230) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } flags |= ts.modifierToFlag(modifier.kind); @@ -19596,10 +20009,10 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (node.parent.kind === 207 || node.parent.kind === 228) { + else if (node.parent.kind === 209 || node.parent.kind === 230) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 130) { + else if (node.kind === 131) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } flags |= 128; @@ -19612,10 +20025,10 @@ var ts; else if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (node.parent.kind === 202) { + else if (node.parent.kind === 204) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 130) { + else if (node.kind === 131) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; @@ -19624,13 +20037,13 @@ var ts; if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (node.parent.kind === 202) { + else if (node.parent.kind === 204) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 130) { + else if (node.kind === 131) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 207) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 209) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -19638,7 +20051,7 @@ var ts; break; } } - if (node.kind === 136) { + if (node.kind === 137) { if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -19649,10 +20062,10 @@ var ts; return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } } - else if ((node.kind === 210 || node.kind === 209) && flags & 2) { + else if ((node.kind === 212 || node.kind === 211) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 130 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 131 && (flags & 112) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } } @@ -19715,7 +20128,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 164) { + if (node.kind === 166) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -19750,7 +20163,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 122 && parameter.type.kind !== 120) { + if (parameter.type.kind !== 123 && parameter.type.kind !== 121) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -19782,7 +20195,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < arguments.length; _i++) { var arg = arguments[_i]; - if (arg.kind === 176) { + if (arg.kind === 178) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -19853,19 +20266,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 128) { + if (node.kind !== 129) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 170 && computedPropertyName.expression.operatorToken.kind === 23) { + if (computedPropertyName.expression.kind === 172 && computedPropertyName.expression.operatorToken.kind === 23) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 201 || - node.kind === 163 || - node.kind === 135); + ts.Debug.assert(node.kind === 203 || + node.kind === 165 || + node.kind === 136); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -19877,9 +20290,6 @@ var ts; } } } - function checkGrammarFunctionName(name) { - return checkGrammarEvalOrArgumentsInStrictMode(name, name); - } function checkGrammarForInvalidQuestionMark(node, questionToken, message) { if (questionToken) { return grammarErrorOnNode(questionToken, message); @@ -19891,55 +20301,52 @@ var ts; var GetAccessor = 2; var SetAccesor = 4; var GetOrSetAccessor = GetAccessor | SetAccesor; - var inStrictMode = (node.parserContextFlags & 1) !== 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_17 = prop.name; - if (prop.kind === 176 || - name_17.kind === 128) { - checkGrammarComputedPropertyName(name_17); + var name_15 = prop.name; + if (prop.kind === 178 || + name_15.kind === 129) { + checkGrammarComputedPropertyName(name_15); continue; } var currentKind = void 0; - if (prop.kind === 225 || prop.kind === 226) { + if (prop.kind === 227 || prop.kind === 228) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_17.kind === 7) { - checkGrammarNumericLiteral(name_17); + if (name_15.kind === 7) { + checkGrammarNumericLiteral(name_15); } currentKind = Property; } - else if (prop.kind === 135) { + else if (prop.kind === 136) { currentKind = Property; } - else if (prop.kind === 137) { + else if (prop.kind === 138) { currentKind = GetAccessor; } - else if (prop.kind === 138) { + else if (prop.kind === 139) { currentKind = SetAccesor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, name_17.text)) { - seen[name_17.text] = currentKind; + if (!ts.hasProperty(seen, name_15.text)) { + seen[name_15.text] = currentKind; } else { - var existingKind = seen[name_17.text]; + var existingKind = seen[name_15.text]; if (currentKind === Property && existingKind === Property) { - if (inStrictMode) { - grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); - } + continue; } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_17.text] = currentKind | existingKind; + seen[name_15.text] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_15, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_15, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -19948,24 +20355,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 200) { + if (forInOrOfStatement.initializer.kind === 202) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 188 + var diagnostic = forInOrOfStatement.kind === 190 ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 188 + var diagnostic = forInOrOfStatement.kind === 190 ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 188 + var diagnostic = forInOrOfStatement.kind === 190 ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -19988,10 +20395,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 137 && accessor.parameters.length) { + else if (kind === 138 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 138) { + else if (kind === 139) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -20016,7 +20423,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 128 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 129 && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -20026,7 +20433,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 155) { + if (node.parent.kind === 157) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -20034,7 +20441,7 @@ var ts; return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } - if (node.parent.kind === 202) { + if (node.parent.kind === 204) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -20045,22 +20452,22 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 203) { + else if (node.parent.kind === 205) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 146) { + else if (node.parent.kind === 148) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { + case 189: + case 190: + case 191: case 187: case 188: - case 189: - case 185: - case 186: return true; - case 195: + case 197: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -20072,9 +20479,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 195: + case 197: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 190 + var isMisplacedContinueLabel = node.kind === 192 && !isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -20082,8 +20489,8 @@ var ts; return false; } break; - case 194: - if (node.kind === 191 && !node.label) { + case 196: + if (node.kind === 193 && !node.label) { return false; } break; @@ -20096,13 +20503,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 191 + var message = node.kind === 193 ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 191 + var message = node.kind === 193 ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -20114,17 +20521,16 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 152 || node.name.kind === 151) { + if (node.name.kind === 154 || node.name.kind === 153) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } } - return checkGrammarEvalOrArgumentsInStrictMode(node, node.name); } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 188 && node.parent.parent.kind !== 189) { + if (node.parent.parent.kind !== 190 && node.parent.parent.kind !== 191) { if (ts.isInAmbientContext(node)) { if (node.initializer) { var equalsTokenLength = "=".length; @@ -20141,8 +20547,7 @@ var ts; } } var checkLetConstNames = languageVersion >= 2 && (ts.isLet(node) || ts.isConst(node)); - return (checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name)) || - checkGrammarEvalOrArgumentsInStrictMode(node, node.name); + return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { if (name.kind === 65) { @@ -20154,7 +20559,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 176) { + if (element.kind !== 178) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -20171,15 +20576,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 184: - case 185: case 186: - case 193: case 187: case 188: - case 189: - return false; case 195: + case 189: + case 190: + case 191: + return false; + case 197: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -20195,7 +20600,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 168) { + if (expression.kind === 170) { var unaryExpression = expression; if (unaryExpression.operator === 33 || unaryExpression.operator === 34) { expression = unaryExpression.operand; @@ -20214,7 +20619,7 @@ var ts; var inAmbientContext = ts.isInAmbientContext(enumDecl); for (var _i = 0, _a = enumDecl.members; _i < _a.length; _i++) { var node = _a[_i]; - if (node.name.kind === 128) { + if (node.name.kind === 129) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -20256,23 +20661,6 @@ var ts; return true; } } - function checkGrammarEvalOrArgumentsInStrictMode(contextNode, name) { - if (name && name.kind === 65) { - var identifier = name; - if (contextNode && (contextNode.parserContextFlags & 1) && isEvalOrArgumentsIdentifier(identifier)) { - var nameText = ts.declarationNameToString(identifier); - var reportErrorInClassDeclaration = reportStrictModeGrammarErrorInClassDeclaration(identifier, ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText); - if (!reportErrorInClassDeclaration) { - return grammarErrorOnNode(identifier, ts.Diagnostics.Invalid_use_of_0_in_strict_mode, nameText); - } - return reportErrorInClassDeclaration; - } - } - } - function isEvalOrArgumentsIdentifier(node) { - return node.kind === 65 && - (node.text === "eval" || node.text === "arguments"); - } function checkGrammarConstructorTypeParameters(node) { if (node.typeParameters) { return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); @@ -20284,18 +20672,18 @@ var ts; } } function checkGrammarProperty(node) { - if (node.parent.kind === 202) { + if (node.parent.kind === 204) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 203) { + else if (node.parent.kind === 205) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 146) { + else if (node.parent.kind === 148) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -20305,11 +20693,11 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 203 || - node.kind === 210 || - node.kind === 209 || - node.kind === 216 || - node.kind === 215 || + if (node.kind === 205 || + node.kind === 212 || + node.kind === 211 || + node.kind === 218 || + node.kind === 217 || (node.flags & 2) || (node.flags & (1 | 256))) { return false; @@ -20319,7 +20707,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 181) { + if (ts.isDeclaration(decl) || decl.kind === 183) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -20338,7 +20726,7 @@ var ts; if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 180 || node.parent.kind === 207 || node.parent.kind === 228) { + if (node.parent.kind === 182 || node.parent.kind === 209 || node.parent.kind === 230) { var links_1 = getNodeLinks(node.parent); if (!links_1.hasReportedStatementInAmbientContext) { return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -20349,13 +20737,8 @@ var ts; } } function checkGrammarNumericLiteral(node) { - if (node.flags & 16384) { - if (node.parserContextFlags & 1) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode); - } - else if (languageVersion >= 1) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); - } + if (node.flags & 16384 && languageVersion >= 1) { + return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { @@ -20366,8 +20749,6 @@ var ts; return true; } } - initializeTypeChecker(); - return checker; } ts.createTypeChecker = createTypeChecker; })(ts || (ts = {})); @@ -20419,7 +20800,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 210); + ts.Debug.assert(aliasEmitInfo.node.kind === 212); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -20492,10 +20873,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 199) { + if (declaration.kind === 201) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 213 || declaration.kind === 214 || declaration.kind === 211) { + else if (declaration.kind === 215 || declaration.kind === 216 || declaration.kind === 213) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -20506,7 +20887,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 210) { + if (moduleElementEmitInfo.node.kind === 212) { moduleElementEmitInfo.isVisible = true; } else { @@ -20514,12 +20895,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 206) { + if (nodeToCheck.kind === 208) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 206) { + if (nodeToCheck.kind === 208) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -20607,39 +20988,39 @@ var ts; function emitType(type) { switch (type.kind) { case 112: - case 122: - case 120: - case 113: case 123: + case 121: + case 113: + case 124: case 99: case 8: return writeTextOfNode(currentSourceFile, type); - case 177: + case 179: return emitExpressionWithTypeArguments(type); - case 142: - return emitTypeReference(type); - case 145: - return emitTypeQuery(type); - case 147: - return emitArrayType(type); - case 148: - return emitTupleType(type); - case 149: - return emitUnionType(type); - case 150: - return emitParenType(type); - case 143: case 144: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); + case 147: + return emitTypeQuery(type); + case 149: + return emitArrayType(type); + case 150: + return emitTupleType(type); + case 151: + return emitUnionType(type); + case 152: + return emitParenType(type); + case 145: case 146: + return emitSignatureDeclarationWithJsDocComments(type); + case 148: return emitTypeLiteral(type); case 65: return emitEntityName(type); - case 127: + case 128: return emitEntityName(type); } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 209 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 211 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); function writeEntityName(entityName) { @@ -20647,8 +21028,8 @@ var ts; writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 127 ? entityName.left : entityName.expression; - var right = entityName.kind === 127 ? entityName.right : entityName.name; + var left = entityName.kind === 128 ? entityName.left : entityName.expression; + var right = entityName.kind === 128 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); @@ -20657,7 +21038,7 @@ var ts; } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 65 || node.expression.kind === 156); + ts.Debug.assert(node.expression.kind === 65 || node.expression.kind === 158); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -20718,9 +21099,9 @@ var ts; } var count = 0; while (true) { - var name_18 = baseName + "_" + (++count); - if (!ts.hasProperty(currentSourceFile.identifiers, name_18)) { - return name_18; + var name_16 = baseName + "_" + (++count); + if (!ts.hasProperty(currentSourceFile.identifiers, name_16)) { + return name_16; } } } @@ -20761,10 +21142,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 209 || - (node.parent.kind === 228 && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 211 || + (node.parent.kind === 230 && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 228) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 230) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -20773,7 +21154,7 @@ var ts; }); } else { - if (node.kind === 210) { + if (node.kind === 212) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -20791,23 +21172,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 201: - return writeFunctionDeclaration(node); - case 181: - return writeVariableStatement(node); case 203: - return writeInterfaceDeclaration(node); - case 202: - return writeClassDeclaration(node); - case 204: - return writeTypeAliasDeclaration(node); + return writeFunctionDeclaration(node); + case 183: + return writeVariableStatement(node); case 205: - return writeEnumDeclaration(node); + return writeInterfaceDeclaration(node); + case 204: + return writeClassDeclaration(node); case 206: + return writeTypeAliasDeclaration(node); + case 207: + return writeEnumDeclaration(node); + case 208: return writeModuleDeclaration(node); - case 209: + case 211: return writeImportEqualsDeclaration(node); - case 210: + case 212: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -20821,7 +21202,7 @@ var ts; if (node.flags & 256) { write("default "); } - else if (node.kind !== 203) { + else if (node.kind !== 205) { write("declare "); } } @@ -20865,7 +21246,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 212) { + if (namedBindings.kind === 214) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -20891,7 +21272,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 212) { + if (node.importClause.namedBindings.kind === 214) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -20940,9 +21321,14 @@ var ts; function writeModuleDeclaration(node) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - write("module "); + if (node.flags & 32768) { + write("namespace "); + } + else { + write("module "); + } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 207) { + while (node.body.kind !== 209) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -21003,7 +21389,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 135 && (node.parent.flags & 32); + return node.parent.kind === 136 && (node.parent.flags & 32); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -21013,15 +21399,15 @@ var ts; writeTextOfNode(currentSourceFile, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 143 || - node.parent.kind === 144 || - (node.parent.parent && node.parent.parent.kind === 146)) { - ts.Debug.assert(node.parent.kind === 135 || - node.parent.kind === 134 || - node.parent.kind === 143 || - node.parent.kind === 144 || - node.parent.kind === 139 || - node.parent.kind === 140); + if (node.parent.kind === 145 || + node.parent.kind === 146 || + (node.parent.parent && node.parent.parent.kind === 148)) { + ts.Debug.assert(node.parent.kind === 136 || + node.parent.kind === 135 || + node.parent.kind === 145 || + node.parent.kind === 146 || + node.parent.kind === 140 || + node.parent.kind === 141); emitType(node.constraint); } else { @@ -21031,31 +21417,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 202: + case 204: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 203: + case 205: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 140: + case 141: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 139: + case 140: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 136: case 135: - case 134: if (node.parent.flags & 128) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 202) { + else if (node.parent.parent.kind === 204) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 201: + case 203: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -21085,7 +21471,7 @@ var ts; } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 202) { + if (node.parent.parent.kind === 204) { diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; @@ -21162,16 +21548,16 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 199 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 201 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 133 || node.kind === 132) && ts.hasQuestionToken(node)) { + if ((node.kind === 134 || node.kind === 133) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 133 || node.kind === 132) && node.parent.kind === 146) { + if ((node.kind === 134 || node.kind === 133) && node.parent.kind === 148) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32)) { @@ -21180,14 +21566,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 199) { + if (node.kind === 201) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 133 || node.kind === 132) { + else if (node.kind === 134 || node.kind === 133) { if (node.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -21195,7 +21581,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 202) { + else if (node.parent.kind === 204) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -21221,7 +21607,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 176) { + if (element.kind !== 178) { elements.push(element); } } @@ -21287,7 +21673,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 137 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 138 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -21300,7 +21686,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 137 + return accessor.kind === 138 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -21309,7 +21695,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 138) { + if (accessorWithTypeAnnotation.kind === 139) { if (accessorWithTypeAnnotation.parent.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -21355,17 +21741,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 201) { + if (node.kind === 203) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 135) { + else if (node.kind === 136) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 201) { + if (node.kind === 203) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 136) { + else if (node.kind === 137) { write("constructor"); } else { @@ -21382,11 +21768,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 140 || node.kind === 144) { + if (node.kind === 141 || node.kind === 146) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 141) { + if (node.kind === 142) { write("["); } else { @@ -21395,20 +21781,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 141) { + if (node.kind === 142) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 143 || node.kind === 144; - if (isFunctionTypeOrConstructorType || node.parent.kind === 146) { + var isFunctionTypeOrConstructorType = node.kind === 145 || node.kind === 146; + if (isFunctionTypeOrConstructorType || node.parent.kind === 148) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 136 && !(node.flags & 32)) { + else if (node.kind !== 137 && !(node.flags & 32)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -21419,23 +21805,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 140: + case 141: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 139: + case 140: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 141: + case 142: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; + case 136: case 135: - case 134: if (node.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -21443,7 +21829,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 202) { + else if (node.parent.kind === 204) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -21456,7 +21842,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 201: + case 203: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -21488,9 +21874,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 143 || - node.parent.kind === 144 || - node.parent.parent.kind === 146) { + if (node.parent.kind === 145 || + node.parent.kind === 146 || + node.parent.parent.kind === 148) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32)) { @@ -21506,22 +21892,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 136: + case 137: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 140: + case 141: return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 139: + case 140: return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + case 136: case 135: - case 134: if (node.parent.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -21529,7 +21915,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 202) { + else if (node.parent.parent.kind === 204) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -21541,7 +21927,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 201: + case 203: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -21552,12 +21938,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 151) { + if (bindingPattern.kind === 153) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 152) { + else if (bindingPattern.kind === 154) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -21576,10 +21962,10 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 176) { + if (bindingElement.kind === 178) { write(" "); } - else if (bindingElement.kind === 153) { + else if (bindingElement.kind === 155) { if (bindingElement.propertyName) { writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); @@ -21602,39 +21988,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 201: - case 206: - case 209: case 203: - case 202: - case 204: + case 208: + case 211: case 205: + case 204: + case 206: + case 207: return emitModuleElement(node, isModuleElementVisible(node)); - case 181: + case 183: return emitModuleElement(node, isVariableStatementVisible(node)); - case 210: + case 212: return emitModuleElement(node, !node.importClause); - case 216: + case 218: return emitExportDeclaration(node); + case 137: case 136: case 135: - case 134: return writeFunctionDeclaration(node); - case 140: - case 139: case 141: + case 140: + case 142: return emitSignatureDeclarationWithJsDocComments(node); - case 137: case 138: + case 139: return emitAccessorDeclaration(node); + case 134: case 133: - case 132: return emitPropertyDeclaration(node); - case 227: + case 229: return emitEnumMemberDeclaration(node); - case 215: + case 217: return emitExportAssignment(node); - case 228: + case 230: return emitSourceFile(node); } } @@ -21680,7 +22066,7 @@ var ts; } ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; function emitFiles(resolver, host, targetSourceFile) { - var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n __.prototype = b.prototype;\n d.prototype = new __();\n};"; + var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; @@ -21744,7 +22130,6 @@ var ts; var exportFunctionForFile; var generatedNameSet = {}; var nodeToGeneratedName = []; - var blockScopedVariableToGeneratedName; var computedPropertyNamesToGeneratedNames; var extendsEmitted = false; var decorateEmitted = false; @@ -21804,9 +22189,9 @@ var ts; var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_19 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_19)) { - return name_19; + var name_17 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); + if (isUniqueName(name_17)) { + return name_17; } } } @@ -21824,72 +22209,39 @@ var ts; i++; } } - function assignGeneratedName(node, name) { - nodeToGeneratedName[ts.getNodeId(node)] = ts.unescapeIdentifier(name); - } - function generateNameForFunctionOrClassDeclaration(node) { - if (!node.name) { - assignGeneratedName(node, makeUniqueName("default")); - } - } function generateNameForModuleOrEnum(node) { - if (node.name.kind === 65) { - var name_20 = node.name.text; - assignGeneratedName(node, isUniqueLocalName(name_20, node) ? name_20 : makeUniqueName(name_20)); - } + var name = node.name.text; + return isUniqueLocalName(name, node) ? name : makeUniqueName(name); } function generateNameForImportOrExportDeclaration(node) { var expr = ts.getExternalModuleName(node); var baseName = expr.kind === 8 ? ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; - assignGeneratedName(node, makeUniqueName(baseName)); + return makeUniqueName(baseName); } - function generateNameForImportDeclaration(node) { - if (node.importClause) { - generateNameForImportOrExportDeclaration(node); - } - } - function generateNameForExportDeclaration(node) { - if (node.moduleSpecifier) { - generateNameForImportOrExportDeclaration(node); - } - } - function generateNameForExportAssignment(node) { - if (node.expression && node.expression.kind !== 65) { - assignGeneratedName(node, makeUniqueName("default")); - } + function generateNameForExportDefault() { + return makeUniqueName("default"); } function generateNameForNode(node) { switch (node.kind) { - case 201: - case 202: - case 175: - generateNameForFunctionOrClassDeclaration(node); - break; - case 206: - generateNameForModuleOrEnum(node); - generateNameForNode(node.body); - break; - case 205: - generateNameForModuleOrEnum(node); - break; - case 210: - generateNameForImportDeclaration(node); - break; - case 216: - generateNameForExportDeclaration(node); - break; - case 215: - generateNameForExportAssignment(node); - break; + case 65: + return makeUniqueName(node.text); + case 208: + case 207: + return generateNameForModuleOrEnum(node); + case 212: + case 218: + return generateNameForImportOrExportDeclaration(node); + case 203: + case 204: + case 177: + case 217: + return generateNameForExportDefault(); } } function getGeneratedNameForNode(node) { - var nodeId = ts.getNodeId(node); - if (!nodeToGeneratedName[nodeId]) { - generateNameForNode(node); - } - return nodeToGeneratedName[nodeId]; + var id = ts.getNodeId(node); + return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); } function initializeEmitterWithSourceMaps() { var sourceMapDir; @@ -21913,7 +22265,7 @@ var ts; return; } var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; - if (lastEncodedSourceMapSpan.emittedLine == lastRecordedSourceMapSpan.emittedLine) { + if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { if (sourceMapData.sourceMapMappings) { sourceMapData.sourceMapMappings += ","; } @@ -21966,8 +22318,8 @@ var ts; var emittedLine = writer.getLine(); var emittedColumn = writer.getColumn(); if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine != emittedLine || - lastRecordedSourceMapSpan.emittedColumn != emittedColumn || + lastRecordedSourceMapSpan.emittedLine !== emittedLine || + lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { @@ -22021,8 +22373,8 @@ var ts; if (scopeName) { var parentIndex = getSourceMapNameIndex(); if (parentIndex !== -1) { - var name_21 = node.name; - if (!name_21 || name_21.kind !== 128) { + var name_18 = node.name; + if (!name_18 || name_18.kind !== 129) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -22039,19 +22391,19 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 201 || - node.kind === 163 || + else if (node.kind === 203 || + node.kind === 165 || + node.kind === 136 || node.kind === 135 || - node.kind === 134 || - node.kind === 137 || node.kind === 138 || - node.kind === 206 || - node.kind === 202 || - node.kind === 205) { + node.kind === 139 || + node.kind === 208 || + node.kind === 204 || + node.kind === 207) { if (node.name) { - var name_22 = node.name; - scopeName = name_22.kind === 128 - ? ts.getTextOfNode(name_22) + var name_19 = node.name; + scopeName = name_19.kind === 129 + ? ts.getTextOfNode(name_19) : node.name.text; } recordScopeNameStart(scopeName); @@ -22144,19 +22496,19 @@ var ts; else { sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); } - function emitNodeWithSourceMap(node, allowGeneratedIdentifiers) { + function emitNodeWithSourceMap(node) { if (node) { if (ts.nodeIsSynthesized(node)) { - return emitNodeWithoutSourceMap(node, false); + return emitNodeWithoutSourceMap(node); } - if (node.kind != 228) { + if (node.kind !== 230) { recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers); + emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); } else { recordNewSourceFileStart(node); - emitNodeWithoutSourceMap(node, false); + emitNodeWithoutSourceMap(node); } } } @@ -22394,10 +22746,10 @@ var ts; emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); - if (node.template.kind === 172) { + if (node.template.kind === 174) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 170 + var needsParens = templateSpan.expression.kind === 172 && templateSpan.expression.operatorToken.kind === 23; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -22421,7 +22773,7 @@ var ts; } for (var i = 0, n = node.templateSpans.length; i < n; i++) { var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 162 + var needsParens = templateSpan.expression.kind !== 164 && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; if (i > 0 || headEmitted) { write(" + "); @@ -22454,11 +22806,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 158: - case 159: - return parent.expression === template; case 160: + case 161: + return parent.expression === template; case 162: + case 164: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1; @@ -22466,7 +22818,7 @@ var ts; } function comparePrecedenceToBinaryPlus(expression) { switch (expression.kind) { - case 170: + case 172: switch (expression.operatorToken.kind) { case 35: case 36: @@ -22478,8 +22830,8 @@ var ts; default: return -1; } + case 175: case 173: - case 171: return -1; default: return 1; @@ -22491,11 +22843,11 @@ var ts; emit(span.literal); } function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 153); + ts.Debug.assert(node.kind !== 155); if (node.kind === 8) { emitLiteral(node); } - else if (node.kind === 128) { + else if (node.kind === 129) { if (ts.nodeIsDecorated(node.parent)) { if (!computedPropertyNamesToGeneratedNames) { computedPropertyNamesToGeneratedNames = []; @@ -22523,75 +22875,122 @@ var ts; write("\""); } } - function isNotExpressionIdentifier(node) { + function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 130: - case 199: - case 153: - case 133: + case 156: + case 172: + case 160: + case 223: + case 129: + case 173: case 132: - case 225: - case 226: + case 167: + case 187: + case 159: + case 217: + case 185: + case 179: + case 189: + case 190: + case 191: + case 186: + case 161: + case 164: + case 171: + case 170: + case 194: + case 228: + case 176: + case 196: + case 162: + case 180: + case 198: + case 163: + case 168: + case 169: + case 188: + case 195: + case 175: + return true; + case 155: + case 229: + case 131: case 227: - case 135: case 134: case 201: - case 137: - case 138: - case 163: - case 202: - case 203: - case 205: - case 206: - case 209: + return parent.initializer === node; + case 158: + return parent.expression === node; + case 166: + case 165: + return parent.body === node; case 211: - case 212: - return parent.name === node; - case 214: - case 218: - return parent.name === node || parent.propertyName === node; - case 191: - case 190: - case 215: - return false; - case 195: - return node.parent.label === node; + return parent.moduleReference === node; + case 128: + return parent.left === node; } + return false; } function emitExpressionIdentifier(node) { - var substitution = resolver.getExpressionNameSubstitution(node, getGeneratedNameForNode); - if (substitution) { - write(substitution); + var container = resolver.getReferencedExportContainer(node); + if (container) { + if (container.kind === 230) { + if (languageVersion < 2 && compilerOptions.module !== 4) { + write("exports."); + } + } + else { + write(getGeneratedNameForNode(container)); + write("."); + } } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function getGeneratedNameForIdentifier(node) { - if (ts.nodeIsSynthesized(node) || !blockScopedVariableToGeneratedName) { - return undefined; - } - var variableId = resolver.getBlockScopedVariableId(node); - if (variableId === undefined) { - return undefined; - } - return blockScopedVariableToGeneratedName[variableId]; - } - function emitIdentifier(node, allowGeneratedIdentifiers) { - if (allowGeneratedIdentifiers) { - var generatedName = getGeneratedNameForIdentifier(node); - if (generatedName) { - write(generatedName); + else if (languageVersion < 2) { + var declaration = resolver.getReferencedImportDeclaration(node); + if (declaration) { + if (declaration.kind === 213) { + write(getGeneratedNameForNode(declaration.parent)); + write(languageVersion === 0 ? '["default"]' : ".default"); + return; + } + else if (declaration.kind === 216) { + write(getGeneratedNameForNode(declaration.parent.parent.parent)); + write("."); + writeTextOfNode(currentSourceFile, declaration.propertyName || declaration.name); + return; + } + } + declaration = resolver.getReferencedNestedRedeclaration(node); + if (declaration) { + write(getGeneratedNameForNode(declaration.name)); return; } } + writeTextOfNode(currentSourceFile, node); + } + function isNameOfNestedRedeclaration(node) { + if (languageVersion < 2) { + var parent_7 = node.parent; + switch (parent_7.kind) { + case 155: + case 204: + case 207: + case 201: + return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); + } + } + return false; + } + function emitIdentifier(node) { if (!node.parent) { write(node.text); } - else if (!isNotExpressionIdentifier(node)) { + else if (isExpressionIdentifier(node)) { emitExpressionIdentifier(node); } + else if (isNameOfNestedRedeclaration(node)) { + write(getGeneratedNameForNode(node)); + } else { writeTextOfNode(currentSourceFile, node); } @@ -22632,7 +23031,7 @@ var ts; } function emitBindingElement(node) { if (node.propertyName) { - emit(node.propertyName, false); + emit(node.propertyName); write(": "); } if (node.dotDotDotToken) { @@ -22663,11 +23062,11 @@ var ts; function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { case 65: - case 154: case 156: - case 157: case 158: - case 162: + case 159: + case 160: + case 164: return false; } return true; @@ -22684,17 +23083,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 174) { + if (e.kind === 176) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 154) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 156) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 174) { + while (i < length && elements[i].kind !== 176) { i++; } write("["); @@ -22717,7 +23116,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 174; + return node.kind === 176; } function emitArrayLiteral(node) { var elements = node.elements; @@ -22778,7 +23177,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 137 || property.kind === 138) { + if (property.kind === 138 || property.kind === 139) { var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { continue; @@ -22829,13 +23228,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 225) { + if (property.kind === 227) { emit(property.initializer); } - else if (property.kind === 226) { + else if (property.kind === 228) { emitExpressionIdentifier(property.name); } - else if (property.kind === 135) { + else if (property.kind === 136) { emitFunctionDeclaration(property); } else { @@ -22867,7 +23266,7 @@ var ts; var numProperties = properties.length; var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 128) { + if (properties[i].name.kind === 129) { numInitialNonComputedProperties = i; break; } @@ -22881,35 +23280,35 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(170, startsOnNewLine); + var result = ts.createSynthesizedNode(172, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(156); + var result = ts.createSynthesizedNode(158); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(20); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(157); + var result = ts.createSynthesizedNode(159); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; } function parenthesizeForAccess(expr) { - while (expr.kind === 161) { + while (expr.kind === 163) { expr = expr.expression; } if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 159 && + expr.kind !== 161 && expr.kind !== 7) { return expr; } - var node = ts.createSynthesizedNode(162); + var node = ts.createSynthesizedNode(164); node.expression = expr; return node; } @@ -22922,32 +23321,26 @@ var ts; if (languageVersion >= 2 && node.asteriskToken) { write("*"); } - emit(node.name, false); + emit(node.name); if (languageVersion < 2) { write(": function "); } emitSignatureAndBody(node); } function emitPropertyAssignment(node) { - emit(node.name, false); + emit(node.name); write(": "); emit(node.initializer); } + function isNamespaceExportReference(node) { + var container = resolver.getReferencedExportContainer(node); + return container && container.kind !== 230; + } function emitShorthandPropertyAssignment(node) { - emit(node.name, false); - if (languageVersion < 2) { + writeTextOfNode(currentSourceFile, node.name); + if (languageVersion < 2 || isNamespaceExportReference(node.name)) { write(": "); - var generatedName = getGeneratedNameForIdentifier(node.name); - if (generatedName) { - write(generatedName); - } - else { - emitExpressionIdentifier(node.name); - } - } - else if (resolver.getExpressionNameSubstitution(node.name, getGeneratedNameForNode)) { - write(": "); - emitExpressionIdentifier(node.name); + emit(node.name); } } function tryEmitConstantValue(node) { @@ -22958,7 +23351,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 156 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 158 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -22988,7 +23381,7 @@ var ts; var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); write("."); var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); - emit(node.name, false); + emit(node.name); decreaseIndentIf(indentedBeforeDot, indentedAfterDot); } function emitQualifiedName(node) { @@ -23006,10 +23399,10 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 174; }); + return ts.forEach(elements, function (e) { return e.kind === 176; }); } function skipParentheses(node) { - while (node.kind === 162 || node.kind === 161) { + while (node.kind === 164 || node.kind === 163) { node = node.expression; } return node; @@ -23030,12 +23423,12 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 156) { + if (expr.kind === 158) { target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 157) { + else if (expr.kind === 159) { target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); @@ -23076,7 +23469,7 @@ var ts; } else { emit(node.expression); - superCall = node.expression.kind === 156 && node.expression.expression.kind === 91; + superCall = node.expression.kind === 158 && node.expression.expression.kind === 91; } if (superCall && languageVersion < 2) { write(".call("); @@ -23127,20 +23520,20 @@ var ts; } } function emitParenExpression(node) { - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 164) { - if (node.expression.kind === 161) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 166) { + if (node.expression.kind === 163) { var operand = node.expression.expression; - while (operand.kind == 161) { + while (operand.kind === 163) { operand = operand.expression; } - if (operand.kind !== 168 && - operand.kind !== 167 && - operand.kind !== 166 && - operand.kind !== 165 && + if (operand.kind !== 170 && operand.kind !== 169 && - operand.kind !== 159 && - !(operand.kind === 158 && node.parent.kind === 159) && - !(operand.kind === 163 && node.parent.kind === 158)) { + operand.kind !== 168 && + operand.kind !== 167 && + operand.kind !== 171 && + operand.kind !== 161 && + !(operand.kind === 160 && node.parent.kind === 161) && + !(operand.kind === 165 && node.parent.kind === 160)) { emit(operand); return; } @@ -23169,7 +23562,7 @@ var ts; if (!isCurrentFileSystemExternalModule() || node.kind !== 65 || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 199 || node.parent.kind === 153); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 201 || node.parent.kind === 155); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -23183,7 +23576,7 @@ var ts; write("\", "); } write(ts.tokenToString(node.operator)); - if (node.operand.kind === 168) { + if (node.operand.kind === 170) { var operand = node.operand; if (node.operator === 33 && (operand.operator === 33 || operand.operator === 38)) { write(" "); @@ -23226,10 +23619,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 228) { + if (current.kind === 230) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 207) { + else if (ts.isFunctionLike(current) || current.kind === 209) { return false; } else { @@ -23239,8 +23632,8 @@ var ts; } function emitBinaryExpression(node) { if (languageVersion < 2 && node.operatorToken.kind === 53 && - (node.left.kind === 155 || node.left.kind === 154)) { - emitDestructuring(node, node.parent.kind === 183); + (node.left.kind === 157 || node.left.kind === 156)) { + emitDestructuring(node, node.parent.kind === 185); } else { var exportChanged = node.operatorToken.kind >= 53 && @@ -23287,7 +23680,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 180) { + if (node && node.kind === 182) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -23302,12 +23695,12 @@ var ts; emitToken(14, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 207) { - ts.Debug.assert(node.parent.kind === 206); + if (node.kind === 209) { + ts.Debug.assert(node.parent.kind === 208); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 207) { + if (node.kind === 209) { emitTempDeclarations(true); } decreaseIndent(); @@ -23316,7 +23709,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 180) { + if (node.kind === 182) { write(" "); emit(node); } @@ -23328,7 +23721,7 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 164); + emitParenthesizedIf(node.expression, node.expression.kind === 166); write(";"); } function emitIfStatement(node) { @@ -23341,7 +23734,7 @@ var ts; if (node.elseStatement) { writeLine(); emitToken(76, node.thenStatement.end); - if (node.elseStatement.kind === 184) { + if (node.elseStatement.kind === 186) { write(" "); emit(node.elseStatement); } @@ -23353,7 +23746,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 180) { + if (node.statement.kind === 182) { write(" "); } else { @@ -23422,7 +23815,7 @@ var ts; var endPos = emitToken(82, node.pos); write(" "); endPos = emitToken(16, endPos); - if (node.initializer && node.initializer.kind === 200) { + if (node.initializer && node.initializer.kind === 202) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -23443,13 +23836,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 189) { + if (languageVersion < 2 && node.kind === 191) { return emitDownLevelForOfStatement(node); } var endPos = emitToken(82, node.pos); write(" "); endPos = emitToken(16, endPos); - if (node.initializer.kind === 200) { + if (node.initializer.kind === 202) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -23459,7 +23852,7 @@ var ts; else { emit(node.initializer); } - if (node.kind === 188) { + if (node.kind === 190) { write(" in "); } else { @@ -23527,7 +23920,7 @@ var ts; increaseIndent(); var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 200) { + if (node.initializer.kind === 202) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -23549,7 +23942,7 @@ var ts; } else { var assignmentExpression = createBinaryExpression(node.initializer, 53, rhsIterationValue, false); - if (node.initializer.kind === 154 || node.initializer.kind === 155) { + if (node.initializer.kind === 156 || node.initializer.kind === 157) { emitDestructuring(assignmentExpression, true, undefined); } else { @@ -23558,7 +23951,7 @@ var ts; } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 180) { + if (node.statement.kind === 182) { emitLines(node.statement.statements); } else { @@ -23570,7 +23963,7 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 191 ? 66 : 71, node.pos); + emitToken(node.kind === 193 ? 66 : 71, node.pos); emitOptional(" ", node.label); write(";"); } @@ -23615,7 +24008,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 221) { + if (node.kind === 223) { write("case "); emit(node.expression); write(":"); @@ -23670,7 +24063,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 206); + } while (node && node.kind !== 208); return node; } function emitContainingModuleName(node) { @@ -23695,7 +24088,7 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(7); zero.text = "0"; - var result = ts.createSynthesizedNode(167); + var result = ts.createSynthesizedNode(169); result.expression = zero; return result; } @@ -23764,15 +24157,15 @@ var ts; function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; var canDefineTempVariablesInPlace = false; - if (root.kind === 199) { + if (root.kind === 201) { var isExported = ts.getCombinedNodeFlags(root) & 1; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 130) { + else if (root.kind === 131) { canDefineTempVariablesInPlace = true; } - if (root.kind === 170) { + if (root.kind === 172) { emitAssignmentExpression(root); } else { @@ -23783,8 +24176,7 @@ var ts; if (emitCount++) { write(", "); } - renameNonTopLevelLetAndConst(name); - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 199 || name.parent.kind === 153); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 201 || name.parent.kind === 155); var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(exportFunctionForFile + "(\""); @@ -23816,14 +24208,14 @@ var ts; } function createDefaultValueCheck(value, defaultValue) { value = ensureIdentifier(value); - var equals = ts.createSynthesizedNode(170); + var equals = ts.createSynthesizedNode(172); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(30); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(171); + var cond = ts.createSynthesizedNode(173); cond.condition = condition; cond.questionToken = ts.createSynthesizedNode(50); cond.whenTrue = whenTrue; @@ -23837,13 +24229,15 @@ var ts; return node; } function createPropertyAccessForDestructuringProperty(object, propName) { - if (propName.kind !== 65) { - return createElementAccessExpression(object, propName); + var syntheticName = ts.createSynthesizedNode(propName.kind); + syntheticName.text = propName.text; + if (syntheticName.kind !== 65) { + return createElementAccessExpression(object, syntheticName); } - return createPropertyAccessExpression(object, propName); + return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(158); + var call = ts.createSynthesizedNode(160); var sliceIdentifier = ts.createSynthesizedNode(65); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); @@ -23858,8 +24252,8 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 225 || p.kind === 226) { - var propName = (p.name); + if (p.kind === 227 || p.kind === 228) { + var propName = p.name; emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } } @@ -23871,8 +24265,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 176) { - if (e.kind !== 174) { + if (e.kind !== 178) { + if (e.kind !== 176) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -23882,14 +24276,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 170 && target.operatorToken.kind === 53) { + if (target.kind === 172 && target.operatorToken.kind === 53) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 155) { + if (target.kind === 157) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 154) { + else if (target.kind === 156) { emitArrayLiteralAssignment(target, value); } else { @@ -23903,14 +24297,14 @@ var ts; emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 162) { + if (root.parent.kind !== 164) { write("("); } value = ensureIdentifier(value); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 162) { + if (root.parent.kind !== 164) { write(")"); } } @@ -23930,11 +24324,11 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 151) { + if (pattern.kind === 153) { var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 176) { + else if (element.kind !== 178) { if (!element.dotDotDotToken) { emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); } @@ -23960,14 +24354,13 @@ var ts; } } else { - renameNonTopLevelLetAndConst(node.name); var initializer = node.initializer; if (!initializer && languageVersion < 2) { var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 256) && (getCombinedFlagsForIdentifier(node.name) & 4096); if (isUninitializedLet && - node.parent.parent.kind !== 188 && - node.parent.parent.kind !== 189) { + node.parent.parent.kind !== 190 && + node.parent.parent.kind !== 191) { initializer = createVoidZero(); } } @@ -23985,7 +24378,7 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 176) { + if (node.kind === 178) { return; } var name = node.name; @@ -23997,48 +24390,15 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 199 && node.parent.kind !== 153)) { + if (!node.parent || (node.parent.kind !== 201 && node.parent.kind !== 155)) { return 0; } return ts.getCombinedNodeFlags(node.parent); } - function renameNonTopLevelLetAndConst(node) { - if (languageVersion >= 2 || - ts.nodeIsSynthesized(node) || - node.kind !== 65 || - (node.parent.kind !== 199 && node.parent.kind !== 153)) { - return; - } - var combinedFlags = getCombinedFlagsForIdentifier(node); - if (((combinedFlags & 12288) === 0) || combinedFlags & 1) { - return; - } - var list = ts.getAncestor(node, 200); - if (list.parent.kind === 181) { - var isSourceFileLevelBinding = list.parent.parent.kind === 228; - var isModuleLevelBinding = list.parent.parent.kind === 207; - var isFunctionLevelBinding = list.parent.parent.kind === 180 && ts.isFunctionLike(list.parent.parent.parent); - if (isSourceFileLevelBinding || isModuleLevelBinding || isFunctionLevelBinding) { - return; - } - } - var blockScopeContainer = ts.getEnclosingBlockScopeContainer(node); - var parent = blockScopeContainer.kind === 228 - ? blockScopeContainer - : blockScopeContainer.parent; - if (resolver.resolvesToSomeValue(parent, node.text)) { - var variableId = resolver.getBlockScopedVariableId(node); - if (!blockScopedVariableToGeneratedName) { - blockScopedVariableToGeneratedName = []; - } - var generatedName = makeUniqueName(node.text); - blockScopedVariableToGeneratedName[variableId] = generatedName; - } - } function isES6ExportedDeclaration(node) { return !!(node.flags & 1) && languageVersion >= 2 && - node.parent.kind === 228; + node.parent.kind === 230; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -24083,12 +24443,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2) { if (ts.isBindingPattern(node.name)) { - var name_23 = createTempVariable(0); + var name_20 = createTempVariable(0); if (!tempParameters) { tempParameters = []; } - tempParameters.push(name_23); - emit(name_23); + tempParameters.push(name_20); + emit(name_20); } else { emit(node.name); @@ -24176,12 +24536,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 137 ? "get " : "set "); - emit(node.name, false); + write(node.kind === 138 ? "get " : "set "); + emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 164 && languageVersion >= 2; + return node.kind === 166 && languageVersion >= 2; } function emitDeclarationName(node) { if (node.name) { @@ -24192,10 +24552,10 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 163) { + if (node.kind === 165) { return !!node.name; } - if (node.kind === 201) { + if (node.kind === 203) { return !!node.name || languageVersion < 2; } } @@ -24203,7 +24563,7 @@ var ts; if (ts.nodeIsMissing(node.body)) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 135 && node.kind !== 134) { + if (node.kind !== 136 && node.kind !== 135) { emitLeadingComments(node); } if (!shouldEmitAsArrowFunction(node)) { @@ -24223,10 +24583,10 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 && node.kind === 201 && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 && node.kind === 203 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 135 && node.kind !== 134) { + if (node.kind !== 136 && node.kind !== 135) { emitTrailingComments(node); } } @@ -24273,7 +24633,7 @@ var ts; if (!node.body) { write(" { }"); } - else if (node.body.kind === 180) { + else if (node.body.kind === 182) { emitBlockFunctionBody(node, node.body); } else { @@ -24298,10 +24658,10 @@ var ts; } write(" "); var current = body; - while (current.kind === 161) { + while (current.kind === 163) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 155); + emitParenthesizedIf(body, current.kind === 157); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -24373,9 +24733,9 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 183) { + if (statement && statement.kind === 185) { var expr = statement.expression; - if (expr && expr.kind === 158) { + if (expr && expr.kind === 160) { var func = expr.expression; if (func && func.kind === 91) { return statement; @@ -24406,7 +24766,7 @@ var ts; emitNodeWithoutSourceMap(memberName); write("]"); } - else if (memberName.kind === 128) { + else if (memberName.kind === 129) { emitComputedPropertyName(memberName); } else { @@ -24418,7 +24778,7 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 133 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { + if (member.kind === 134 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { properties.push(member); } } @@ -24458,11 +24818,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 179) { + if (member.kind === 181) { writeLine(); write(";"); } - else if (member.kind === 135 || node.kind === 134) { + else if (member.kind === 136 || node.kind === 135) { if (!member.body) { return emitOnlyPinnedOrTripleSlashComments(member); } @@ -24481,7 +24841,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 137 || member.kind === 138) { + else if (member.kind === 138 || member.kind === 139) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -24531,22 +24891,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 135 || node.kind === 134) && !member.body) { + if ((member.kind === 136 || node.kind === 135) && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - else if (member.kind === 135 || - member.kind === 137 || - member.kind === 138) { + else if (member.kind === 136 || + member.kind === 138 || + member.kind === 139) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128) { write("static "); } - if (member.kind === 137) { + if (member.kind === 138) { write("get "); } - else if (member.kind === 138) { + else if (member.kind === 139) { write("set "); } if (member.asteriskToken) { @@ -24557,7 +24917,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 179) { + else if (member.kind === 181) { writeLine(); write(";"); } @@ -24578,10 +24938,10 @@ var ts; function emitConstructorWorker(node, baseTypeElement) { var hasInstancePropertyWithInitializer = false; ts.forEach(node.members, function (member) { - if (member.kind === 136 && !member.body) { + if (member.kind === 137 && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - if (member.kind === 133 && member.initializer && (member.flags & 128) === 0) { + if (member.kind === 134 && member.initializer && (member.flags & 128) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -24681,7 +25041,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 202) { + if (node.kind === 204) { if (thisNodeIsDecorated) { if (isES6ExportedDeclaration(node) && !(node.flags & 256)) { write("export "); @@ -24698,7 +25058,7 @@ var ts; } } var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 175; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 177; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0); @@ -24765,7 +25125,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 202) { + if (node.kind === 204) { if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); } @@ -24823,11 +25183,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 202) { + if (node.kind === 204) { write(";"); } emitEnd(node); - if (node.kind === 202) { + if (node.kind === 204) { emitExportMemberAssignment(node); } if (languageVersion < 2 && node.parent === currentSourceFile && node.name) { @@ -24901,13 +25261,13 @@ var ts; } else { decorators = member.decorators; - if (member.kind === 135) { + if (member.kind === 136) { functionLikeMember = member; } } writeLine(); emitStart(member); - if (member.kind !== 133) { + if (member.kind !== 134) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -24937,7 +25297,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 133) { + if (member.kind !== 134) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -24976,26 +25336,26 @@ var ts; } function shouldEmitTypeMetadata(node) { switch (node.kind) { - case 135: - case 137: + case 136: case 138: - case 133: + case 139: + case 134: return true; } return false; } function shouldEmitReturnTypeMetadata(node) { switch (node.kind) { - case 135: + case 136: return true; } return false; } function shouldEmitParamTypesMetadata(node) { switch (node.kind) { - case 202: - case 135: - case 138: + case 204: + case 136: + case 139: return true; } return false; @@ -25004,7 +25364,7 @@ var ts; var argumentsWritten = 0; if (compilerOptions.emitDecoratorMetadata) { if (shouldEmitTypeMetadata(node)) { - var serializedType = resolver.serializeTypeOfNode(node, getGeneratedNameForNode); + var serializedType = resolver.serializeTypeOfNode(node); if (serializedType) { if (writeComma) { write(", "); @@ -25017,7 +25377,7 @@ var ts; } } if (shouldEmitParamTypesMetadata(node)) { - var serializedTypes = resolver.serializeParameterTypesOfNode(node, getGeneratedNameForNode); + var serializedTypes = resolver.serializeParameterTypesOfNode(node); if (serializedTypes) { if (writeComma || argumentsWritten) { write(", "); @@ -25035,7 +25395,7 @@ var ts; } } if (shouldEmitReturnTypeMetadata(node)) { - var serializedType = resolver.serializeReturnTypeOfNode(node, getGeneratedNameForNode); + var serializedType = resolver.serializeReturnTypeOfNode(node); if (serializedType) { if (writeComma || argumentsWritten) { write(", "); @@ -25165,7 +25525,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 206) { + if (moduleDeclaration.body.kind === 208) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -25200,7 +25560,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 207) { + if (node.body.kind === 209) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -25257,16 +25617,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 209) { + if (node.kind === 211) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 212) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 214) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 210 && node.importClause && !!node.importClause.name; + return node.kind === 212 && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -25293,7 +25653,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 212) { + if (node.importClause.namedBindings.kind === 214) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -25319,7 +25679,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 209 && (node.flags & 1) !== 0; + var isExportedImport = node.kind === 211 && (node.flags & 1) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2) { emitLeadingComments(node); @@ -25331,7 +25691,7 @@ var ts; write(" = "); } else { - var isNakedImport = 210 && !node.importClause; + var isNakedImport = 212 && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -25487,8 +25847,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 201 && - expression.kind !== 202) { + if (expression.kind !== 203 && + expression.kind !== 204) { write(";"); } emitEnd(node); @@ -25524,18 +25884,18 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 210: + case 212: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { externalImports.push(node); } break; - case 209: - if (node.moduleReference.kind === 220 && resolver.isReferencedAliasDeclaration(node)) { + case 211: + if (node.moduleReference.kind === 222 && resolver.isReferencedAliasDeclaration(node)) { externalImports.push(node); } break; - case 216: + case 218: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -25548,12 +25908,12 @@ var ts; else { for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; - var name_24 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_24] || (exportSpecifiers[name_24] = [])).push(specifier); + var name_21 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_21] || (exportSpecifiers[name_21] = [])).push(specifier); } } break; - case 215: + case 217: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -25573,13 +25933,16 @@ var ts; write("}"); } } - function getLocalNameForExternalImport(importNode) { - var namespaceDeclaration = getNamespaceDeclarationNode(importNode); - if (namespaceDeclaration && !isDefaultImport(importNode)) { + function getLocalNameForExternalImport(node) { + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - else { - return getGeneratedNameForNode(importNode); + if (node.kind === 212 && node.importClause) { + return getGeneratedNameForNode(node); + } + if (node.kind === 218 && node.moduleSpecifier) { + return getGeneratedNameForNode(node); } } function getExternalModuleNameText(importNode) { @@ -25597,8 +25960,8 @@ var ts; var started = false; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; - var skipNode = importNode.kind === 216 || - (importNode.kind === 210 && !importNode.importClause); + var skipNode = importNode.kind === 218 || + (importNode.kind === 212 && !importNode.importClause); if (skipNode) { continue; } @@ -25623,7 +25986,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 216 && externalImport.exportClause) { + if (externalImport.kind === 218 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -25652,7 +26015,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 216) { + if (externalImport.kind !== 218) { continue; } var exportDecl = externalImport; @@ -25722,11 +26085,11 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_25 = local.kind === 65 + var name_22 = local.kind === 65 ? local : local.name; - if (name_25) { - var text = ts.unescapeIdentifier(name_25.text); + if (name_22) { + var text = ts.unescapeIdentifier(name_22.text); if (ts.hasProperty(seen, text)) { continue; } @@ -25737,7 +26100,7 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 202 || local.kind === 206 || local.kind === 205) { + if (local.kind === 204 || local.kind === 208 || local.kind === 207) { emitDeclarationName(local); } else { @@ -25771,21 +26134,21 @@ var ts; if (node.flags & 2) { return; } - if (node.kind === 201) { + if (node.kind === 203) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 202) { + if (node.kind === 204) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 205) { + if (node.kind === 207) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -25794,7 +26157,7 @@ var ts; } return; } - if (node.kind === 206) { + if (node.kind === 208) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -25803,17 +26166,17 @@ var ts; } return; } - if (node.kind === 199 || node.kind === 153) { + if (node.kind === 201 || node.kind === 155) { if (shouldHoistVariable(node, false)) { - var name_26 = node.name; - if (name_26.kind === 65) { + var name_23 = node.name; + if (name_23.kind === 65) { if (!hoistedVars) { hoistedVars = []; } - hoistedVars.push(name_26); + hoistedVars.push(name_23); } else { - ts.forEachChild(name_26, visit); + ts.forEachChild(name_23, visit); } } return; @@ -25832,7 +26195,7 @@ var ts; return false; } return (ts.getCombinedNodeFlags(node) & 12288) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 228; + ts.getEnclosingBlockScopeContainer(node).kind === 230; } function isCurrentFileSystemExternalModule() { return compilerOptions.module === 4 && ts.isExternalModule(currentSourceFile); @@ -25849,10 +26212,10 @@ var ts; emitSetters(exportStarFunction); writeLine(); emitExecute(node, startIndex); - emitTempDeclarations(true); decreaseIndent(); writeLine(); write("}"); + emitTempDeclarations(true); } function emitSetters(exportStarFunction) { write("setters:["); @@ -25867,27 +26230,27 @@ var ts; var parameterName = "_" + importVariableName; write("function (" + parameterName + ") {"); switch (importNode.kind) { - case 210: + case 212: if (!importNode.importClause) { break; } - case 209: + case 211: ts.Debug.assert(importVariableName !== ""); increaseIndent(); writeLine(); write(importVariableName + " = " + parameterName + ";"); writeLine(); - var defaultName = importNode.kind === 210 + var defaultName = importNode.kind === 212 ? importNode.importClause.name : importNode.name; if (defaultName) { emitExportMemberAssignments(defaultName); writeLine(); } - if (importNode.kind === 210 && + if (importNode.kind === 212 && importNode.importClause.namedBindings) { var namedBindings = importNode.importClause.namedBindings; - if (namedBindings.kind === 212) { + if (namedBindings.kind === 214) { emitExportMemberAssignments(namedBindings.name); writeLine(); } @@ -25901,7 +26264,7 @@ var ts; } decreaseIndent(); break; - case 216: + case 218: ts.Debug.assert(importVariableName !== ""); increaseIndent(); if (importNode.exportClause) { @@ -25935,10 +26298,10 @@ var ts; for (var i = startIndex; i < node.statements.length; ++i) { var statement = node.statements[i]; switch (statement.kind) { - case 216: - case 210: - case 209: - case 201: + case 218: + case 212: + case 211: + case 203: continue; } writeLine(); @@ -25952,7 +26315,11 @@ var ts; collectExternalModuleInfo(node); ts.Debug.assert(!exportFunctionForFile); exportFunctionForFile = makeUniqueName("exports"); - write("System.register(["); + write("System.register("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + write("["); for (var i = 0; i < externalImports.length; ++i) { var text = getExternalModuleNameText(externalImports[i]); if (i !== 0) { @@ -26025,8 +26392,8 @@ var ts; collectExternalModuleInfo(node); writeLine(); write("define("); - if (node.amdModuleName) { - write("\"" + node.amdModuleName + "\", "); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); } emitAMDDependencies(node, true); write(") {"); @@ -26155,7 +26522,7 @@ var ts; } emitLeadingComments(node.endOfFileToken); } - function emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers) { + function emitNodeWithoutSourceMap(node) { if (!node) { return; } @@ -26166,48 +26533,47 @@ var ts; if (emitComments) { emitLeadingComments(node); } - emitJavaScriptWorker(node, allowGeneratedIdentifiers); + emitJavaScriptWorker(node); if (emitComments) { emitTrailingComments(node); } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 203: - case 201: - case 210: - case 209: - case 204: - case 215: - return false; - case 181: - return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 206: - return shouldEmitModuleDeclaration(node); case 205: + case 203: + case 212: + case 211: + case 206: + case 217: + return false; + case 183: + return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); + case 208: + return shouldEmitModuleDeclaration(node); + case 207: return shouldEmitEnumDeclaration(node); } - if (node.kind !== 180 && + if (node.kind !== 182 && node.parent && - node.parent.kind === 164 && + node.parent.kind === 166 && node.parent.body === node && compilerOptions.target <= 1) { return false; } return true; } - function emitJavaScriptWorker(node, allowGeneratedIdentifiers) { - if (allowGeneratedIdentifiers === void 0) { allowGeneratedIdentifiers = true; } + function emitJavaScriptWorker(node) { switch (node.kind) { case 65: - return emitIdentifier(node, allowGeneratedIdentifiers); - case 130: + return emitIdentifier(node); + case 131: return emitParameter(node); + case 136: case 135: - case 134: return emitMethod(node); - case 137: case 138: + case 139: return emitAccessor(node); case 93: return emitThis(node); @@ -26227,131 +26593,131 @@ var ts; case 12: case 13: return emitLiteral(node); - case 172: - return emitTemplateExpression(node); - case 178: - return emitTemplateSpan(node); - case 127: - return emitQualifiedName(node); - case 151: - return emitObjectBindingPattern(node); - case 152: - return emitArrayBindingPattern(node); - case 153: - return emitBindingElement(node); - case 154: - return emitArrayLiteral(node); - case 155: - return emitObjectLiteral(node); - case 225: - return emitPropertyAssignment(node); - case 226: - return emitShorthandPropertyAssignment(node); - case 128: - return emitComputedPropertyName(node); - case 156: - return emitPropertyAccess(node); - case 157: - return emitIndexedAccess(node); - case 158: - return emitCallExpression(node); - case 159: - return emitNewExpression(node); - case 160: - return emitTaggedTemplateExpression(node); - case 161: - return emit(node.expression); - case 162: - return emitParenExpression(node); - case 201: - case 163: - case 164: - return emitFunctionDeclaration(node); - case 165: - return emitDeleteExpression(node); - case 166: - return emitTypeOfExpression(node); - case 167: - return emitVoidExpression(node); - case 168: - return emitPrefixUnaryExpression(node); - case 169: - return emitPostfixUnaryExpression(node); - case 170: - return emitBinaryExpression(node); - case 171: - return emitConditionalExpression(node); case 174: - return emitSpreadElementExpression(node); - case 173: - return emitYieldExpression(node); - case 176: - return; + return emitTemplateExpression(node); case 180: - case 207: - return emitBlock(node); - case 181: - return emitVariableStatement(node); - case 182: - return write(";"); - case 183: - return emitExpressionStatement(node); - case 184: - return emitIfStatement(node); - case 185: - return emitDoStatement(node); - case 186: - return emitWhileStatement(node); - case 187: - return emitForStatement(node); - case 189: - case 188: - return emitForInOrForOfStatement(node); - case 190: - case 191: - return emitBreakOrContinueStatement(node); - case 192: - return emitReturnStatement(node); - case 193: - return emitWithStatement(node); - case 194: - return emitSwitchStatement(node); - case 221: - case 222: - return emitCaseOrDefaultClause(node); - case 195: - return emitLabelledStatement(node); - case 196: - return emitThrowStatement(node); - case 197: - return emitTryStatement(node); - case 224: - return emitCatchClause(node); - case 198: - return emitDebuggerStatement(node); - case 199: - return emitVariableDeclaration(node); - case 175: - return emitClassExpression(node); - case 202: - return emitClassDeclaration(node); - case 203: - return emitInterfaceDeclaration(node); - case 205: - return emitEnumDeclaration(node); + return emitTemplateSpan(node); + case 128: + return emitQualifiedName(node); + case 153: + return emitObjectBindingPattern(node); + case 154: + return emitArrayBindingPattern(node); + case 155: + return emitBindingElement(node); + case 156: + return emitArrayLiteral(node); + case 157: + return emitObjectLiteral(node); case 227: - return emitEnumMember(node); - case 206: - return emitModuleDeclaration(node); - case 210: - return emitImportDeclaration(node); - case 209: - return emitImportEqualsDeclaration(node); - case 216: - return emitExportDeclaration(node); - case 215: - return emitExportAssignment(node); + return emitPropertyAssignment(node); case 228: + return emitShorthandPropertyAssignment(node); + case 129: + return emitComputedPropertyName(node); + case 158: + return emitPropertyAccess(node); + case 159: + return emitIndexedAccess(node); + case 160: + return emitCallExpression(node); + case 161: + return emitNewExpression(node); + case 162: + return emitTaggedTemplateExpression(node); + case 163: + return emit(node.expression); + case 164: + return emitParenExpression(node); + case 203: + case 165: + case 166: + return emitFunctionDeclaration(node); + case 167: + return emitDeleteExpression(node); + case 168: + return emitTypeOfExpression(node); + case 169: + return emitVoidExpression(node); + case 170: + return emitPrefixUnaryExpression(node); + case 171: + return emitPostfixUnaryExpression(node); + case 172: + return emitBinaryExpression(node); + case 173: + return emitConditionalExpression(node); + case 176: + return emitSpreadElementExpression(node); + case 175: + return emitYieldExpression(node); + case 178: + return; + case 182: + case 209: + return emitBlock(node); + case 183: + return emitVariableStatement(node); + case 184: + return write(";"); + case 185: + return emitExpressionStatement(node); + case 186: + return emitIfStatement(node); + case 187: + return emitDoStatement(node); + case 188: + return emitWhileStatement(node); + case 189: + return emitForStatement(node); + case 191: + case 190: + return emitForInOrForOfStatement(node); + case 192: + case 193: + return emitBreakOrContinueStatement(node); + case 194: + return emitReturnStatement(node); + case 195: + return emitWithStatement(node); + case 196: + return emitSwitchStatement(node); + case 223: + case 224: + return emitCaseOrDefaultClause(node); + case 197: + return emitLabelledStatement(node); + case 198: + return emitThrowStatement(node); + case 199: + return emitTryStatement(node); + case 226: + return emitCatchClause(node); + case 200: + return emitDebuggerStatement(node); + case 201: + return emitVariableDeclaration(node); + case 177: + return emitClassExpression(node); + case 204: + return emitClassDeclaration(node); + case 205: + return emitInterfaceDeclaration(node); + case 207: + return emitEnumDeclaration(node); + case 229: + return emitEnumMember(node); + case 208: + return emitModuleDeclaration(node); + case 212: + return emitImportDeclaration(node); + case 211: + return emitImportEqualsDeclaration(node); + case 218: + return emitExportDeclaration(node); + case 217: + return emitExportAssignment(node); + case 230: return emitSourceFileNode(node); } } @@ -26379,7 +26745,7 @@ var ts; } function getLeadingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 228 || node.pos !== node.parent.pos) { + if (node.parent.kind === 230 || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { return getLeadingCommentsWithoutDetachedComments(); } @@ -26391,7 +26757,7 @@ var ts; } function getTrailingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 228 || node.end !== node.parent.end) { + if (node.parent.kind === 230 || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } @@ -26569,7 +26935,7 @@ var ts; } ts.createCompilerHost = createCompilerHost; function getPreEmitDiagnostics(program, sourceFile) { - var diagnostics = program.getSyntacticDiagnostics(sourceFile).concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics(sourceFile)); + var diagnostics = program.getOptionsDiagnostics().concat(program.getSyntacticDiagnostics(sourceFile), program.getGlobalDiagnostics(), program.getSemanticDiagnostics(sourceFile)); if (program.getCompilerOptions().declaration) { diagnostics.concat(program.getDeclarationDiagnostics(sourceFile)); } @@ -26602,16 +26968,17 @@ var ts; function createProgram(rootNames, options, host) { var program; var files = []; - var filesByName = {}; var diagnostics = ts.createDiagnosticCollection(); - var seenNoDefaultLib = options.noLib; var commonSourceDirectory; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; + var classifiableNames; + var skipDefaultLib = options.noLib; var start = new Date().getTime(); host = host || createCompilerHost(options); + var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); }); ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - if (!seenNoDefaultLib) { + if (!skipDefaultLib) { processRootFile(host.getDefaultLibFileName(options), true); } verifyCompilerOptions(); @@ -26621,11 +26988,12 @@ var ts; getSourceFiles: function () { return files; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, + getOptionsDiagnostics: getOptionsDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, getSemanticDiagnostics: getSemanticDiagnostics, getDeclarationDiagnostics: getDeclarationDiagnostics, - getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics, getTypeChecker: getTypeChecker, + getClassifiableNames: getClassifiableNames, getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker, getCommonSourceDirectory: function () { return commonSourceDirectory; }, emit: emit, @@ -26636,6 +27004,17 @@ var ts; getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); } }; return program; + function getClassifiableNames() { + if (!classifiableNames) { + getTypeChecker(); + classifiableNames = {}; + for (var _i = 0; _i < files.length; _i++) { + var sourceFile = files[_i]; + ts.copyMap(sourceFile.classifiableNames, classifiableNames); + } + } + return classifiableNames; + } function getEmitHost(writeFileCallback) { return { getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, @@ -26665,8 +27044,7 @@ var ts; return emitResult; } function getSourceFile(fileName) { - fileName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - return ts.hasProperty(filesByName, fileName) ? filesByName[fileName] : undefined; + return filesByName.get(fileName); } function getDiagnosticsHelper(sourceFile, getDiagnostics) { if (sourceFile) { @@ -26705,16 +27083,14 @@ var ts; return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); } } - function getCompilerOptionsDiagnostics() { + function getOptionsDiagnostics() { var allDiagnostics = []; ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function getGlobalDiagnostics() { - var typeChecker = getDiagnosticsProducingTypeChecker(); var allDiagnostics = []; - ts.addRange(allDiagnostics, typeChecker.getGlobalDiagnostics()); - ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); + ts.addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function hasExtension(fileName) { @@ -26748,14 +27124,17 @@ var ts; } } else { - if (options.allowNonTsExtensions && !findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd)) { - diagnostic = ts.Diagnostics.File_0_not_found; - diagnosticArgument = [fileName]; - } - else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, isDefaultLib, refFile, refPos, refEnd); })) { - diagnostic = ts.Diagnostics.File_0_not_found; - fileName += ".ts"; - diagnosticArgument = [fileName]; + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd); + if (!nonTsFile) { + if (options.allowNonTsExtensions) { + diagnostic = ts.Diagnostics.File_0_not_found; + diagnosticArgument = [fileName]; + } + else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, isDefaultLib, refFile, refPos, refEnd); })) { + diagnostic = ts.Diagnostics.File_0_not_found; + fileName += ".ts"; + diagnosticArgument = [fileName]; + } } } if (diagnostic) { @@ -26769,16 +27148,16 @@ var ts; } function findSourceFile(fileName, isDefaultLib, refFile, refStart, refLength) { var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - if (ts.hasProperty(filesByName, canonicalName)) { + if (filesByName.contains(canonicalName)) { return getSourceFileFromCache(fileName, canonicalName, false); } else { var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); - if (ts.hasProperty(filesByName, canonicalAbsolutePath)) { + if (filesByName.contains(canonicalAbsolutePath)) { return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); } - var file = filesByName[canonicalName] = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { if (refFile) { diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } @@ -26786,15 +27165,17 @@ var ts; diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } }); + filesByName.set(canonicalName, file); if (file) { - seenNoDefaultLib = seenNoDefaultLib || file.hasNoDefaultLib; - filesByName[canonicalAbsolutePath] = file; + skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; + filesByName.set(canonicalAbsolutePath, file); if (!options.noResolve) { var basePath = ts.getDirectoryPath(fileName); processReferencedFiles(file, basePath); processImportedModules(file, basePath); } if (isDefaultLib) { + file.isDefaultLib = true; files.unshift(file); } else { @@ -26804,7 +27185,7 @@ var ts; return file; } function getSourceFileFromCache(fileName, canonicalName, useAbsolutePath) { - var file = filesByName[canonicalName]; + var file = filesByName.get(canonicalName); if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { @@ -26822,7 +27203,7 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 210 || node.kind === 209 || node.kind === 216) { + if (node.kind === 212 || node.kind === 211 || node.kind === 218) { var moduleNameExpr = ts.getExternalModuleName(node); if (moduleNameExpr && moduleNameExpr.kind === 8) { var moduleNameText = moduleNameExpr.text; @@ -26843,7 +27224,7 @@ var ts; } } } - else if (node.kind === 206 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { + else if (node.kind === 208 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { ts.forEachChild(node.body, function (node) { if (ts.isExternalModuleImportEqualsDeclaration(node) && ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 8) { @@ -27038,98 +27419,98 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 185) { + if (node.parent.kind === 187) { return spanInPreviousNode(node); } - if (node.parent.kind === 187) { + if (node.parent.kind === 189) { return textSpan(node); } - if (node.parent.kind === 170 && node.parent.operatorToken.kind === 23) { + if (node.parent.kind === 172 && node.parent.operatorToken.kind === 23) { return textSpan(node); } - if (node.parent.kind == 164 && node.parent.body == node) { + if (node.parent.kind === 166 && node.parent.body === node) { return textSpan(node); } } switch (node.kind) { - case 181: + case 183: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 199: - case 133: - case 132: - return spanInVariableDeclaration(node); - case 130: - return spanInParameterDeclaration(node); case 201: - case 135: case 134: - case 137: - case 138: + case 133: + return spanInVariableDeclaration(node); + case 131: + return spanInParameterDeclaration(node); + case 203: case 136: - case 163: - case 164: + case 135: + case 138: + case 139: + case 137: + case 165: + case 166: return spanInFunctionDeclaration(node); - case 180: + case 182: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 207: + case 209: return spanInBlock(node); - case 224: + case 226: return spanInBlock(node.block); - case 183: + case 185: return textSpan(node.expression); - case 192: + case 194: return textSpan(node.getChildAt(0), node.expression); + case 188: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 187: + return spanInNode(node.statement); + case 200: + return textSpan(node.getChildAt(0)); case 186: return textSpan(node, ts.findNextToken(node.expression, node)); - case 185: - return spanInNode(node.statement); - case 198: - return textSpan(node.getChildAt(0)); - case 184: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 195: - return spanInNode(node.statement); - case 191: - case 190: - return textSpan(node.getChildAt(0), node.label); - case 187: - return spanInForStatement(node); - case 188: - case 189: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 194: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 221: - case 222: - return spanInNode(node.statements[0]); case 197: - return spanInBlock(node.tryBlock); + return spanInNode(node.statement); + case 193: + case 192: + return textSpan(node.getChildAt(0), node.label); + case 189: + return spanInForStatement(node); + case 190: + case 191: + return textSpan(node, ts.findNextToken(node.expression, node)); case 196: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 223: + case 224: + return spanInNode(node.statements[0]); + case 199: + return spanInBlock(node.tryBlock); + case 198: return textSpan(node, node.expression); - case 215: + case 217: return textSpan(node, node.expression); - case 209: + case 211: return textSpan(node, node.moduleReference); - case 210: + case 212: return textSpan(node, node.moduleSpecifier); - case 216: + case 218: return textSpan(node, node.moduleSpecifier); - case 206: + case 208: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 202: - case 205: - case 227: - case 158: - case 159: - return textSpan(node); - case 193: - return spanInNode(node.statement); - case 203: case 204: + case 207: + case 229: + case 160: + case 161: + return textSpan(node); + case 195: + return spanInNode(node.statement); + case 205: + case 206: return undefined; case 22: case 1: @@ -27156,10 +27537,10 @@ var ts; case 81: return spanInNextNode(node); default: - if (node.parent.kind === 225 && node.parent.name === node) { + if (node.parent.kind === 227 && node.parent.name === node) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 161 && node.parent.type === node) { + if (node.parent.kind === 163 && node.parent.type === node) { return spanInNode(node.parent.expression); } if (ts.isFunctionLike(node.parent) && node.parent.type === node) { @@ -27169,12 +27550,12 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 188 || - variableDeclaration.parent.parent.kind === 189) { + if (variableDeclaration.parent.parent.kind === 190 || + variableDeclaration.parent.parent.kind === 191) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 181; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 187 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 183; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 189 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -27220,7 +27601,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1) || - (functionDeclaration.parent.kind === 202 && functionDeclaration.kind !== 136); + (functionDeclaration.parent.kind === 204 && functionDeclaration.kind !== 137); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -27240,23 +27621,23 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 206: + case 208: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 186: - case 184: case 188: - case 189: + case 186: + case 190: + case 191: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); - case 187: + case 189: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 200) { + if (forStatement.initializer.kind === 202) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -27275,34 +27656,34 @@ var ts; } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 205: + case 207: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 202: + case 204: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 208: + case 210: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 207: + case 209: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 205: - case 202: + case 207: + case 204: return textSpan(node); - case 180: + case 182: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 224: + case 226: return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 208: + case 210: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { @@ -27314,24 +27695,24 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 185) { + if (node.parent.kind === 187) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 163: - case 201: - case 164: - case 135: - case 134: - case 137: - case 138: + case 165: + case 203: + case 166: case 136: - case 186: - case 185: + case 135: + case 138: + case 139: + case 137: + case 188: case 187: + case 189: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -27339,19 +27720,19 @@ var ts; return spanInNode(node.parent); } function spanInColonToken(node) { - if (ts.isFunctionLike(node.parent) || node.parent.kind === 225) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 227) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 161) { + if (node.parent.kind === 163) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 185) { + if (node.parent.kind === 187) { return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } return spanInNode(node.parent); @@ -27429,7 +27810,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 164; + return ts.isFunctionBlock(node) && node.parent.kind !== 166; } var depth = 0; var maxDepth = 20; @@ -27441,26 +27822,26 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 180: + case 182: if (!ts.isFunctionBlock(n)) { - var parent_7 = n.parent; + var parent_8 = n.parent; var openBrace = ts.findChildOfKind(n, 14, sourceFile); var closeBrace = ts.findChildOfKind(n, 15, sourceFile); - if (parent_7.kind === 185 || - parent_7.kind === 188 || - parent_7.kind === 189 || - parent_7.kind === 187 || - parent_7.kind === 184 || - parent_7.kind === 186 || - parent_7.kind === 193 || - parent_7.kind === 224) { - addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); + if (parent_8.kind === 187 || + parent_8.kind === 190 || + parent_8.kind === 191 || + parent_8.kind === 189 || + parent_8.kind === 186 || + parent_8.kind === 188 || + parent_8.kind === 195 || + parent_8.kind === 226) { + addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_7.kind === 197) { - var tryStatement = parent_7; + if (parent_8.kind === 199) { + var tryStatement = parent_8; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -27480,23 +27861,23 @@ var ts; }); break; } - case 207: { + case 209: { var openBrace = ts.findChildOfKind(n, 14, sourceFile); var closeBrace = ts.findChildOfKind(n, 15, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 202: - case 203: + case 204: case 205: - case 155: - case 208: { + case 207: + case 157: + case 210: { var openBrace = ts.findChildOfKind(n, 14, sourceFile); var closeBrace = ts.findChildOfKind(n, 15, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 154: + case 156: var openBracket = ts.findChildOfKind(n, 18, sourceFile); var closeBracket = ts.findChildOfKind(n, 19, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -27522,10 +27903,10 @@ var ts; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_27 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_27); + for (var name_24 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_24); if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_27); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_24); if (!matches) { continue; } @@ -27536,14 +27917,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_27); + matches = patternMatcher.getMatches(containers, name_24); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_27, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_24, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -27580,7 +27961,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 128) { + else if (declaration.name.kind === 129) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -27597,7 +27978,7 @@ var ts; } return true; } - if (expression.kind === 156) { + if (expression.kind === 158) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -27608,7 +27989,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 128) { + if (declaration.name.kind === 129) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -27672,14 +28053,14 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 206: + case 208: do { current = current.parent; - } while (current.kind === 206); - case 202: + } while (current.kind === 208); + case 204: + case 207: case 205: case 203: - case 201: indent++; } current = current.parent; @@ -27690,26 +28071,26 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 181: + case 183: ts.forEach(node.declarationList.declarations, visit); break; - case 151: - case 152: + case 153: + case 154: ts.forEach(node.elements, visit); break; - case 216: + case 218: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 210: + case 212: var importClause = node.importClause; if (importClause) { if (importClause.name) { childNodes.push(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 212) { + if (importClause.namedBindings.kind === 214) { childNodes.push(importClause.namedBindings); } else { @@ -27718,20 +28099,20 @@ var ts; } } break; - case 153: - case 199: + case 155: + case 201: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } - case 202: + case 204: + case 207: case 205: + case 208: case 203: - case 206: - case 201: - case 209: - case 214: - case 218: + case 211: + case 216: + case 220: childNodes.push(node); break; } @@ -27766,17 +28147,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 202: + case 204: + case 207: case 205: - case 203: topLevelNodes.push(node); break; - case 206: + case 208: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 201: + case 203: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -27787,9 +28168,9 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 201) { - if (functionDeclaration.body && functionDeclaration.body.kind === 180) { - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 201 && !isEmpty(s.name.text); })) { + if (functionDeclaration.kind === 203) { + if (functionDeclaration.body && functionDeclaration.body.kind === 182) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 203 && !isEmpty(s.name.text); })) { return true; } if (!ts.isFunctionBlock(functionDeclaration.parent)) { @@ -27842,7 +28223,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 130: + case 131: if (ts.isBindingPattern(node.name)) { break; } @@ -27850,34 +28231,34 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 136: case 135: - case 134: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 137: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); case 138: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 141: - return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 227: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); case 139: - return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 140: - return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 133: - case 132: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); + case 142: + return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); + case 229: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 201: + case 140: + return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); + case 141: + return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); + case 134: + case 133: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 203: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 199: - case 153: + case 201: + case 155: var variableDeclarationNode; - var name_28; - if (node.kind === 153) { - name_28 = node.name; + var name_25; + if (node.kind === 155) { + name_25 = node.name; variableDeclarationNode = node; - while (variableDeclarationNode && variableDeclarationNode.kind !== 199) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 201) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -27885,24 +28266,24 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_28 = node.name; + name_25 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_28), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_28), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_28), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.variableElement); } - case 136: + case 137: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 218: - case 214: - case 209: + case 220: + case 216: case 211: - case 212: + case 213: + case 214: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -27932,17 +28313,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 228: + case 230: return createSourceFileItem(node); - case 202: + case 204: return createClassItem(node); - case 205: + case 207: return createEnumItem(node); - case 203: + case 205: return createIterfaceItem(node); - case 206: + case 208: return createModuleItem(node); - case 201: + case 203: return createFunctionItem(node); } return undefined; @@ -27952,7 +28333,7 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 206) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 208) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -27964,7 +28345,7 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.body && node.body.kind === 180) { + if (node.body && node.body.kind === 182) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -27985,7 +28366,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 136 && member; + return member.kind === 137 && member; }); var nodes = removeDynamicallyNamedProperties(node); if (constructor) { @@ -28006,19 +28387,19 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 128; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 129; }); } function removeDynamicallyNamedProperties(node) { return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 206) { + while (node.body.kind === 208) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 228 + return node.kind === 230 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -28401,7 +28782,7 @@ var ts; var hasTransitionFromUpperToLower = transitionFromUpperToLower(identifier, word, i, wordStart); if (charIsPunctuation(identifier.charCodeAt(i - 1)) || charIsPunctuation(identifier.charCodeAt(i)) || - lastIsDigit != currentIsDigit || + lastIsDigit !== currentIsDigit || hasTransitionFromLowerToUpper || hasTransitionFromUpperToLower) { if (!isAllPunctuation(identifier, wordStart, i)) { @@ -28455,7 +28836,7 @@ var ts; } function transitionFromUpperToLower(identifier, word, index, wordStart) { if (word) { - if (index != wordStart && + if (index !== wordStart && index + 1 < identifier.length) { var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index)); var nextIsLower = isLowerCaseLetter(identifier.charCodeAt(index + 1)); @@ -28509,14 +28890,14 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 158) { + if (argumentInfo.invocation.kind !== 160) { return undefined; } var callExpression = argumentInfo.invocation; var expression = callExpression.expression; var name = expression.kind === 65 ? expression - : expression.kind === 156 + : expression.kind === 158 ? expression.name : undefined; if (!name || !name.text) { @@ -28545,7 +28926,7 @@ var ts; } } function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 158 || node.parent.kind === 159) { + if (node.parent.kind === 160 || node.parent.kind === 161) { var callExpression = node.parent; if (node.kind === 24 || node.kind === 16) { @@ -28576,23 +28957,23 @@ var ts; }; } } - else if (node.kind === 10 && node.parent.kind === 160) { + else if (node.kind === 10 && node.parent.kind === 162) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0); } } - else if (node.kind === 11 && node.parent.parent.kind === 160) { + else if (node.kind === 11 && node.parent.parent.kind === 162) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 172); + ts.Debug.assert(templateExpression.kind === 174); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 178 && node.parent.parent.parent.kind === 160) { + else if (node.parent.kind === 180 && node.parent.parent.parent.kind === 162) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 172); + ts.Debug.assert(templateExpression.kind === 174); if (node.kind === 13 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } @@ -28656,7 +29037,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 172) { + if (template.kind === 174) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -28665,7 +29046,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 228; n = n.parent) { + for (var n = node; n.kind !== 230; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -28846,39 +29227,39 @@ var ts; return false; } switch (n.kind) { - case 202: - case 203: + case 204: case 205: - case 155: - case 151: - case 146: - case 180: case 207: - case 208: + case 157: + case 153: + case 148: + case 182: + case 209: + case 210: return nodeEndsWith(n, 15, sourceFile); - case 224: + case 226: return isCompletedNode(n.block, sourceFile); - case 159: + case 161: if (!n.arguments) { return true; } - case 158: - case 162: - case 150: + case 160: + case 164: + case 152: return nodeEndsWith(n, 17, sourceFile); - case 143: - case 144: + case 145: + case 146: return isCompletedNode(n.type, sourceFile); - case 136: case 137: case 138: - case 201: - case 163: - case 135: - case 134: - case 140: case 139: - case 164: + case 203: + case 165: + case 136: + case 135: + case 141: + case 140: + case 166: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -28886,61 +29267,61 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 17, sourceFile); - case 206: + case 208: return n.body && isCompletedNode(n.body, sourceFile); - case 184: + case 186: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 183: + case 185: return isCompletedNode(n.expression, sourceFile); + case 156: case 154: - case 152: - case 157: - case 128: - case 148: + case 159: + case 129: + case 150: return nodeEndsWith(n, 19, sourceFile); - case 141: + case 142: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 19, sourceFile); - case 221: - case 222: + case 223: + case 224: return false; - case 187: - case 188: case 189: - case 186: + case 190: + case 191: + case 188: return isCompletedNode(n.statement, sourceFile); - case 185: + case 187: var hasWhileKeyword = findChildOfKind(n, 100, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 17, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 145: + case 147: return isCompletedNode(n.exprName, sourceFile); - case 166: - case 165: + case 168: case 167: - case 173: - case 174: + case 169: + case 175: + case 176: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 160: + case 162: return isCompletedNode(n.template, sourceFile); - case 172: + case 174: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 178: + case 180: return ts.nodeIsPresent(n.literal); - case 168: - return isCompletedNode(n.operand, sourceFile); case 170: + return isCompletedNode(n.operand, sourceFile); + case 172: return isCompletedNode(n.right, sourceFile); - case 171: + case 173: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -28983,7 +29364,7 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 251 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 253 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -29089,7 +29470,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 228); + ts.Debug.assert(startNode !== undefined || n.kind === 230); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -29126,17 +29507,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 142 || node.kind === 158) { + if (node.kind === 144 || node.kind === 160) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 202 || node.kind === 203) { + if (ts.isFunctionLike(node) || node.kind === 204 || node.kind === 205) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 && n.kind <= 126; + return n.kind >= 0 && n.kind <= 127; } ts.isToken = isToken; function isWord(kind) { @@ -29189,7 +29570,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 130; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 131; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -29574,7 +29955,7 @@ var ts; if (this.tokensAreOnSameLine === undefined) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(this.currentTokenSpan.pos).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(this.nextTokenSpan.pos).line; - this.tokensAreOnSameLine = (startLine == endLine); + this.tokensAreOnSameLine = (startLine === endLine); } return this.tokensAreOnSameLine; }; @@ -29593,7 +29974,7 @@ var ts; FormattingContext.prototype.NodeIsOnOneLine = function (node) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile)).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; - return startLine == endLine; + return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { var openBrace = ts.findChildOfKind(node, 14, this.sourceFile); @@ -29708,7 +30089,7 @@ var ts; this.customContextChecks = funcs; } RuleOperationContext.prototype.IsAny = function () { - return this == RuleOperationContext.Any; + return this === RuleOperationContext.Any; }; RuleOperationContext.prototype.InContext = function (context) { if (this.IsAny()) { @@ -29789,12 +30170,12 @@ var ts; this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(90, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([17, 75, 76, 67]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2)); this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([96, 81]), 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116, 121]), 65), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116, 122]), 65), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(114, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([117, 119]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69, 115, 77, 78, 79, 116, 102, 85, 103, 117, 118, 106, 108, 121, 109]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([118, 120]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69, 115, 77, 78, 79, 116, 102, 85, 103, 118, 119, 106, 108, 122, 109]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([79, 102])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(8, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(32, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); @@ -29808,7 +30189,7 @@ var ts; this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8)); this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65, 78, 73, 69, 109, 108, 106, 107, 116, 121, 18, 35])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65, 78, 73, 69, 109, 108, 106, 107, 116, 122, 18, 35])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(83, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(35, formatting.Shared.TokenRange.FromTokens([65, 16])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(110, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); @@ -29888,37 +30269,38 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_29 in o) { - if (o[name_29] === rule) { - return name_29; + for (var name_26 in o) { + if (o[name_26] === rule) { + return name_26; } } throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 187; + return context.contextNode.kind === 189; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 170: - case 171: + case 172: + case 173: + case 143: return true; - case 153: - case 204: - case 209: - case 199: - case 130: - case 227: + case 155: + case 206: + case 211: + case 201: + case 131: + case 229: + case 134: case 133: - case 132: return context.currentTokenSpan.kind === 53 || context.nextTokenSpan.kind === 53; - case 188: + case 190: return context.currentTokenSpan.kind === 86 || context.nextTokenSpan.kind === 86; - case 189: - return context.currentTokenSpan.kind === 126 || context.nextTokenSpan.kind === 126; + case 191: + return context.currentTokenSpan.kind === 127 || context.nextTokenSpan.kind === 127; } return false; }; @@ -29926,7 +30308,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 171; + return context.contextNode.kind === 173; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -29967,85 +30349,85 @@ var ts; return true; } switch (node.kind) { - case 180: - case 208: - case 155: - case 207: + case 182: + case 210: + case 157: + case 209: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 201: + case 203: + case 136: case 135: - case 134: - case 137: case 138: case 139: - case 163: - case 136: - case 164: - case 203: + case 140: + case 165: + case 137: + case 166: + case 205: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 201 || context.contextNode.kind === 163; + return context.contextNode.kind === 203 || context.contextNode.kind === 165; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 202: - case 203: + case 204: case 205: - case 146: - case 206: + case 207: + case 148: + case 208: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 202: - case 206: - case 205: - case 180: - case 224: + case 204: + case 208: case 207: - case 194: + case 182: + case 226: + case 209: + case 196: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 184: - case 194: - case 187: - case 188: - case 189: case 186: - case 197: - case 185: - case 193: - case 224: + case 196: + case 189: + case 190: + case 191: + case 188: + case 199: + case 187: + case 195: + case 226: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 155; + return context.contextNode.kind === 157; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 158; + return context.contextNode.kind === 160; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 159; + return context.contextNode.kind === 161; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -30069,38 +30451,38 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 131; + return node.kind === 132; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 200 && + return context.currentTokenParent.kind === 202 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { - return context.formattingRequestKind != 2; + return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 206; + return context.contextNode.kind === 208; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 146; + return context.contextNode.kind === 148; }; Rules.IsTypeArgumentOrParameter = function (token, parent) { if (token.kind !== 24 && token.kind !== 25) { return false; } switch (parent.kind) { - case 142: - case 202: + case 144: + case 204: + case 205: case 203: - case 201: - case 163: - case 164: + case 165: + case 166: + case 136: case 135: - case 134: - case 139: case 140: - case 158: - case 159: + case 141: + case 160: + case 161: return true; default: return false; @@ -30111,10 +30493,10 @@ var ts; Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 99 && context.currentTokenParent.kind === 167; + return context.currentTokenSpan.kind === 99 && context.currentTokenParent.kind === 169; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 173 && context.contextNode.expression !== undefined; + return context.contextNode.kind === 175 && context.contextNode.expression !== undefined; }; return Rules; })(); @@ -30137,7 +30519,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 126 + 1; + this.mapRowLength = 127 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -30155,13 +30537,13 @@ var ts; }; RulesMap.prototype.FillRule = function (rule, rulesBucketConstructionStateList) { var _this = this; - var specificRule = rule.Descriptor.LeftTokenRange != formatting.Shared.TokenRange.Any && - rule.Descriptor.RightTokenRange != formatting.Shared.TokenRange.Any; + var specificRule = rule.Descriptor.LeftTokenRange !== formatting.Shared.TokenRange.Any && + rule.Descriptor.RightTokenRange !== formatting.Shared.TokenRange.Any; rule.Descriptor.LeftTokenRange.GetTokens().forEach(function (left) { rule.Descriptor.RightTokenRange.GetTokens().forEach(function (right) { var rulesBucketIndex = _this.GetRuleBucketIndex(left, right); var rulesBucket = _this.map[rulesBucketIndex]; - if (rulesBucket == undefined) { + if (rulesBucket === undefined) { rulesBucket = _this.map[rulesBucketIndex] = new RulesBucket(); } rulesBucket.AddRule(rule, specificRule, rulesBucketConstructionStateList, rulesBucketIndex); @@ -30213,7 +30595,7 @@ var ts; RulesBucketConstructionState.prototype.IncreaseInsertionIndex = function (maskPosition) { var value = (this.rulesInsertionIndexBitmap >> maskPosition) & Mask; value++; - ts.Debug.assert((value & Mask) == value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules."); + ts.Debug.assert((value & Mask) === value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules."); var temp = this.rulesInsertionIndexBitmap & ~(Mask << maskPosition); temp |= value << maskPosition; this.rulesInsertionIndexBitmap = temp; @@ -30230,7 +30612,7 @@ var ts; }; RulesBucket.prototype.AddRule = function (rule, specificTokens, constructionState, rulesBucketIndex) { var position; - if (rule.Operation.Action == 1) { + if (rule.Operation.Action === 1) { position = specificTokens ? RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny; @@ -30304,7 +30686,7 @@ var ts; return [this.token]; }; TokenSingleValueAccess.prototype.Contains = function (tokenValue) { - return tokenValue == this.token; + return tokenValue === this.token; }; return TokenSingleValueAccess; })(); @@ -30314,7 +30696,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 126; token++) { + for (var token = 0; token <= 127; token++) { result.push(token); } return result; @@ -30356,9 +30738,9 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(66, 126); + TokenRange.Keywords = TokenRange.FromRange(66, 127); TokenRange.BinaryOperators = TokenRange.FromRange(24, 64); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([86, 87, 126]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([86, 87, 127, 117]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([38, 39, 47, 46]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7, 65, 16, 18, 14, 93, 88]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([65, 16, 93, 88]); @@ -30366,7 +30748,7 @@ var ts; TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([65, 16, 93, 88]); TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([65, 17, 19, 88]); TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([65, 120, 122, 113, 123, 99, 112]); + TokenRange.TypeNames = TokenRange.FromTokens([65, 121, 123, 113, 124, 99, 112]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -30544,17 +30926,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 202: - case 203: + case 204: + case 205: return ts.rangeContainsRange(parent.members, node); - case 206: + case 208: var body = parent.body; - return body && body.kind === 180 && ts.rangeContainsRange(body.statements, node); - case 228: - case 180: - case 207: + return body && body.kind === 182 && ts.rangeContainsRange(body.statements, node); + case 230: + case 182: + case 209: return ts.rangeContainsRange(parent.statements, node); - case 224: + case 226: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -30679,9 +31061,9 @@ var ts; if (indentation === -1) { if (isSomeBlock(node.kind)) { if (isSomeBlock(parent.kind) || - parent.kind === 228 || - parent.kind === 221 || - parent.kind === 222) { + parent.kind === 230 || + parent.kind === 223 || + parent.kind === 224) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -30714,18 +31096,18 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 202: return 69; - case 203: return 103; - case 201: return 83; - case 205: return 205; - case 137: return 116; - case 138: return 121; - case 135: + case 204: return 69; + case 205: return 103; + case 203: return 83; + case 207: return 207; + case 138: return 116; + case 139: return 122; + case 136: if (node.asteriskToken) { return 35; } - case 133: - case 130: + case 134: + case 131: return node.name.kind; } } @@ -30832,7 +31214,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 131 ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 132 ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -31122,20 +31504,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 180: - case 207: + case 182: + case 209: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { + case 137: + case 203: + case 165: case 136: - case 201: - case 163: case 135: - case 134: - case 164: + case 166: if (node.typeParameters === list) { return 24; } @@ -31143,8 +31525,8 @@ var ts; return 16; } break; - case 158: - case 159: + case 160: + case 161: if (node.typeArguments === list) { return 24; } @@ -31152,7 +31534,7 @@ var ts; return 16; } break; - case 142: + case 144: if (node.typeArguments === list) { return 24; } @@ -31244,7 +31626,7 @@ var ts; return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 23 && precedingToken.parent.kind !== 170) { + if (precedingToken.kind === 23 && precedingToken.parent.kind !== 172) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -31334,7 +31716,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 228 || !parentAndChildShareLine); + (parent.kind === 230 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -31358,7 +31740,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 184 && parent.elseStatement === child) { + if (parent.kind === 186 && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 76, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -31370,23 +31752,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 142: + case 144: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 155: + case 157: return node.parent.properties; - case 154: + case 156: return node.parent.elements; - case 201: - case 163: - case 164: + case 203: + case 165: + case 166: + case 136: case 135: - case 134: - case 139: - case 140: { + case 140: + case 141: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -31397,8 +31779,8 @@ var ts; } break; } - case 159: - case 158: { + case 161: + case 160: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -31467,28 +31849,28 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 202: - case 203: + case 204: case 205: - case 154: - case 180: case 207: - case 155: - case 146: + case 156: + case 182: + case 209: + case 157: case 148: - case 208: - case 222: - case 221: - case 162: - case 158: - case 159: - case 181: - case 199: - case 215: - case 192: - case 171: - case 152: - case 151: + case 150: + case 210: + case 224: + case 223: + case 164: + case 160: + case 161: + case 183: + case 201: + case 217: + case 194: + case 173: + case 154: + case 153: return true; } return false; @@ -31498,22 +31880,22 @@ var ts; return true; } switch (parent) { - case 185: - case 186: - case 188: - case 189: case 187: - case 184: - case 201: - case 163: - case 135: - case 134: - case 139: - case 164: + case 188: + case 190: + case 191: + case 189: + case 186: + case 203: + case 165: case 136: + case 135: + case 140: + case 166: case 137: case 138: - return child !== 180; + case 139: + return child !== 182; default: return false; } @@ -31526,8 +31908,7 @@ var ts; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; /// /// @@ -31593,7 +31974,7 @@ var ts; return this.getEnd() - this.getStart(sourceFile); }; NodeObject.prototype.getFullWidth = function () { - return this.end - this.getFullStart(); + return this.end - this.pos; }; NodeObject.prototype.getLeadingTriviaWidth = function (sourceFile) { return this.getStart(sourceFile) - this.pos; @@ -31615,7 +31996,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(251, nodes.pos, nodes.end, 1024, this); + var list = createNode(253, nodes.pos, nodes.end, 1024, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -31634,7 +32015,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 127) { + if (this.kind >= 128) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -31679,7 +32060,7 @@ var ts; var children = this.getChildren(); for (var _i = 0; _i < children.length; _i++) { var child = children[_i]; - if (child.kind < 127) { + if (child.kind < 128) { return child; } return child.getFirstToken(sourceFile); @@ -31689,7 +32070,7 @@ var ts; var children = this.getChildren(sourceFile); for (var i = children.length - 1; i >= 0; i--) { var child = children[i]; - if (child.kind < 127) { + if (child.kind < 128) { return child; } return child.getLastToken(sourceFile); @@ -31735,7 +32116,7 @@ var ts; ts.forEach(declarations, function (declaration, indexOfDeclaration) { if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); - if (canUseParsedParamTagComments && declaration.kind === 130) { + if (canUseParsedParamTagComments && declaration.kind === 131) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -31743,13 +32124,13 @@ var ts; } }); } - if (declaration.kind === 206 && declaration.body.kind === 206) { + if (declaration.kind === 208 && declaration.body.kind === 208) { return; } - while (declaration.kind === 206 && declaration.parent.kind === 206) { + while (declaration.kind === 208 && declaration.parent.kind === 208) { declaration = declaration.parent; } - ts.forEach(getJsDocCommentTextRange(declaration.kind === 199 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 201 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { jsDocCommentParts.push.apply(jsDocCommentParts, cleanedJsDocComment); @@ -32054,9 +32435,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 128) { + if (declaration.name.kind === 129) { var expr = declaration.name.expression; - if (expr.kind === 156) { + if (expr.kind === 158) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -32076,9 +32457,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 201: + case 203: + case 136: case 135: - case 134: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -32095,62 +32476,62 @@ var ts; ts.forEachChild(node, visit); } break; - case 202: - case 203: case 204: case 205: case 206: - case 209: - case 218: - case 214: - case 209: - case 211: - case 212: - case 137: - case 138: - case 146: - addDeclaration(node); - case 136: - case 181: - case 200: - case 151: - case 152: case 207: + case 208: + case 211: + case 220: + case 216: + case 211: + case 213: + case 214: + case 138: + case 139: + case 148: + addDeclaration(node); + case 137: + case 183: + case 202: + case 153: + case 154: + case 209: ts.forEachChild(node, visit); break; - case 180: + case 182: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 130: + case 131: if (!(node.flags & 112)) { break; } - case 199: - case 153: + case 201: + case 155: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 227: + case 229: + case 134: case 133: - case 132: addDeclaration(node); break; - case 216: + case 218: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 210: + case 212: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 212) { + if (importClause.namedBindings.kind === 214) { addDeclaration(importClause.namedBindings); } else { @@ -32290,14 +32671,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 163) { + if (declaration.kind === 165) { return true; } - if (declaration.kind !== 199 && declaration.kind !== 201) { + if (declaration.kind !== 201 && declaration.kind !== 203) { return false; } - for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { - if (parent_8.kind === 228 || parent_8.kind === 207) { + for (var parent_9 = declaration.parent; !ts.isFunctionBlock(parent_9); parent_9 = parent_9.parent) { + if (parent_9.kind === 230 || parent_9.kind === 209) { return false; } } @@ -32336,8 +32717,7 @@ var ts; var HostCache = (function () { function HostCache(host, getCanonicalFileName) { this.host = host; - this.getCanonicalFileName = getCanonicalFileName; - this.fileNameToEntry = {}; + this.fileNameToEntry = ts.createFileMap(getCanonicalFileName); var rootFileNames = host.getScriptFileNames(); for (var _i = 0; _i < rootFileNames.length; _i++) { var fileName = rootFileNames[_i]; @@ -32348,9 +32728,6 @@ var ts; HostCache.prototype.compilationSettings = function () { return this._compilationSettings; }; - HostCache.prototype.normalizeFileName = function (fileName) { - return this.getCanonicalFileName(ts.normalizeSlashes(fileName)); - }; HostCache.prototype.createEntry = function (fileName) { var entry; var scriptSnapshot = this.host.getScriptSnapshot(fileName); @@ -32361,13 +32738,14 @@ var ts; scriptSnapshot: scriptSnapshot }; } - return this.fileNameToEntry[this.normalizeFileName(fileName)] = entry; + this.fileNameToEntry.set(fileName, entry); + return entry; }; HostCache.prototype.getEntry = function (fileName) { - return ts.lookUp(this.fileNameToEntry, this.normalizeFileName(fileName)); + return this.fileNameToEntry.get(fileName); }; HostCache.prototype.contains = function (fileName) { - return ts.hasProperty(this.fileNameToEntry, this.normalizeFileName(fileName)); + return this.fileNameToEntry.contains(fileName); }; HostCache.prototype.getOrCreateEntry = function (fileName) { if (this.contains(fileName)) { @@ -32376,12 +32754,10 @@ var ts; return this.createEntry(fileName); }; HostCache.prototype.getRootFileNames = function () { - var _this = this; var fileNames = []; - ts.forEachKey(this.fileNameToEntry, function (key) { - var entry = _this.getEntry(key); - if (entry) { - fileNames.push(entry.hostFileName); + this.fileNameToEntry.forEachValue(function (value) { + if (value) { + fileNames.push(value.hostFileName); } }); return fileNames; @@ -32428,7 +32804,7 @@ var ts; sourceFile.version = version; sourceFile.scriptSnapshot = scriptSnapshot; } - function transpile(input, compilerOptions, fileName, diagnostics) { + function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { var options = compilerOptions ? ts.clone(compilerOptions) : getDefaultCompilerOptions(); options.isolatedModules = true; options.allowNonTsExtensions = true; @@ -32436,8 +32812,8 @@ var ts; options.noResolve = true; var inputFileName = fileName || "module.ts"; var sourceFile = ts.createSourceFile(inputFileName, input, options.target); - if (diagnostics && sourceFile.parseDiagnostics) { - diagnostics.push.apply(diagnostics, sourceFile.parseDiagnostics); + if (moduleName) { + sourceFile.moduleName = moduleName; } var newLine = ts.getNewLineCharacter(options); var outputText; @@ -32454,9 +32830,8 @@ var ts; getNewLine: function () { return newLine; } }; var program = ts.createProgram([inputFileName], options, compilerHost); - if (diagnostics) { - diagnostics.push.apply(diagnostics, program.getCompilerOptionsDiagnostics()); - } + ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile)); + ts.addRange(diagnostics, program.getOptionsDiagnostics()); program.emit(); ts.Debug.assert(outputText !== undefined, "Output generation failed"); return outputText; @@ -32503,8 +32878,14 @@ var ts; return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, true); } ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; - function createDocumentRegistry() { + function createGetCanonicalFileName(useCaseSensitivefileNames) { + return useCaseSensitivefileNames + ? (function (fileName) { return fileName; }) + : (function (fileName) { return fileName.toLowerCase(); }); + } + function createDocumentRegistry(useCaseSensitiveFileNames) { var buckets = {}; + var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); function getKeyFromCompilationSettings(settings) { return "_" + settings.target; } @@ -32512,7 +32893,7 @@ var ts; var key = getKeyFromCompilationSettings(settings); var bucket = ts.lookUp(buckets, key); if (!bucket && createIfMissing) { - buckets[key] = bucket = {}; + buckets[key] = bucket = ts.createFileMap(getCanonicalFileName); } return bucket; } @@ -32521,7 +32902,7 @@ var ts; var entries = ts.lookUp(buckets, name); var sourceFiles = []; for (var i in entries) { - var entry = entries[i]; + var entry = entries.get(i); sourceFiles.push({ name: i, refCount: entry.languageServiceRefCount, @@ -32544,15 +32925,16 @@ var ts; } function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { var bucket = getBucketForCompilationSettings(compilationSettings, true); - var entry = ts.lookUp(bucket, fileName); + var entry = bucket.get(fileName); if (!entry) { ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, false); - bucket[fileName] = entry = { + entry = { sourceFile: sourceFile, languageServiceRefCount: 0, owners: [] }; + bucket.set(fileName, entry); } else { if (entry.sourceFile.version !== version) { @@ -32567,11 +32949,11 @@ var ts; function releaseDocument(fileName, compilationSettings) { var bucket = getBucketForCompilationSettings(compilationSettings, false); ts.Debug.assert(bucket !== undefined); - var entry = ts.lookUp(bucket, fileName); + var entry = bucket.get(fileName); entry.languageServiceRefCount--; ts.Debug.assert(entry.languageServiceRefCount >= 0); if (entry.languageServiceRefCount === 0) { - delete bucket[fileName]; + bucket.remove(fileName); } } return { @@ -32623,7 +33005,7 @@ var ts; else { if (token === 65) { token = scanner.scan(); - if (token === 125) { + if (token === 126) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -32632,7 +33014,7 @@ var ts; } else if (token === 53) { token = scanner.scan(); - if (token === 119) { + if (token === 120) { token = scanner.scan(); if (token === 16) { token = scanner.scan(); @@ -32657,7 +33039,7 @@ var ts; } if (token === 15) { token = scanner.scan(); - if (token === 125) { + if (token === 126) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -32671,7 +33053,7 @@ var ts; token = scanner.scan(); if (token === 65) { token = scanner.scan(); - if (token === 125) { + if (token === 126) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -32691,7 +33073,7 @@ var ts; } if (token === 15) { token = scanner.scan(); - if (token === 125) { + if (token === 126) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -32701,7 +33083,7 @@ var ts; } else if (token === 35) { token = scanner.scan(); - if (token === 125) { + if (token === 126) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -32722,7 +33104,7 @@ var ts; ts.preProcessFile = preProcessFile; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 195 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 197 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -32731,16 +33113,16 @@ var ts; } function isJumpStatementTarget(node) { return node.kind === 65 && - (node.parent.kind === 191 || node.parent.kind === 190) && + (node.parent.kind === 193 || node.parent.kind === 192) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { return node.kind === 65 && - node.parent.kind === 195 && + node.parent.kind === 197 && node.parent.label === node; } function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 195; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 197; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -32751,25 +33133,25 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 127 && node.parent.right === node; + return node.parent.kind === 128 && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 156 && node.parent.name === node; + return node && node.parent && node.parent.kind === 158 && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 158 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 160 && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 159 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 161 && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 206 && node.parent.name === node; + return node.parent.kind === 208 && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { return node.kind === 65 && @@ -32777,22 +33159,22 @@ var ts; } function isNameOfPropertyAssignment(node) { return (node.kind === 65 || node.kind === 8 || node.kind === 7) && - (node.parent.kind === 225 || node.parent.kind === 226) && node.parent.name === node; + (node.parent.kind === 227 || node.parent.kind === 228) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 8 || node.kind === 7) { switch (node.parent.kind) { - case 133: - case 132: - case 225: - case 227: - case 135: case 134: - case 137: + case 133: + case 227: + case 229: + case 136: + case 135: case 138: - case 206: + case 139: + case 208: return node.parent.name === node; - case 157: + case 159: return node.parent.argumentExpression === node; } } @@ -32830,7 +33212,7 @@ var ts; } } var keywordCompletions = []; - for (var i = 66; i <= 126; i++) { + for (var i = 66; i <= 127; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -32845,17 +33227,17 @@ var ts; return undefined; } switch (node.kind) { - case 228: + case 230: + case 136: case 135: - case 134: - case 201: - case 163: - case 137: - case 138: - case 202: case 203: + case 165: + case 138: + case 139: + case 204: case 205: - case 206: + case 207: + case 208: return node; } } @@ -32863,38 +33245,38 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 206: return ScriptElementKind.moduleElement; - case 202: return ScriptElementKind.classElement; - case 203: return ScriptElementKind.interfaceElement; - case 204: return ScriptElementKind.typeElement; - case 205: return ScriptElementKind.enumElement; - case 199: + case 208: return ScriptElementKind.moduleElement; + case 204: return ScriptElementKind.classElement; + case 205: return ScriptElementKind.interfaceElement; + case 206: return ScriptElementKind.typeElement; + case 207: return ScriptElementKind.enumElement; + case 201: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 201: return ScriptElementKind.functionElement; - case 137: return ScriptElementKind.memberGetAccessorElement; - case 138: return ScriptElementKind.memberSetAccessorElement; + case 203: return ScriptElementKind.functionElement; + case 138: return ScriptElementKind.memberGetAccessorElement; + case 139: return ScriptElementKind.memberSetAccessorElement; + case 136: case 135: - case 134: return ScriptElementKind.memberFunctionElement; + case 134: case 133: - case 132: return ScriptElementKind.memberVariableElement; - case 141: return ScriptElementKind.indexSignatureElement; - case 140: return ScriptElementKind.constructSignatureElement; - case 139: return ScriptElementKind.callSignatureElement; - case 136: return ScriptElementKind.constructorImplementationElement; - case 129: return ScriptElementKind.typeParameterElement; - case 227: return ScriptElementKind.variableElement; - case 130: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 209: - case 214: + case 142: return ScriptElementKind.indexSignatureElement; + case 141: return ScriptElementKind.constructSignatureElement; + case 140: return ScriptElementKind.callSignatureElement; + case 137: return ScriptElementKind.constructorImplementationElement; + case 130: return ScriptElementKind.typeParameterElement; + case 229: return ScriptElementKind.variableElement; + case 131: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; case 211: - case 218: - case 212: + case 216: + case 213: + case 220: + case 214: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -32916,9 +33298,7 @@ var ts; host.log(message); } } - function getCanonicalFileName(fileName) { - return useCaseSensitivefileNames ? fileName : fileName.toLowerCase(); - } + var getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames); function getValidSourceFile(fileName) { fileName = ts.normalizeSlashes(fileName); var sourceFile = program.getSourceFile(getCanonicalFileName(fileName)); @@ -33048,44 +33428,44 @@ var ts; return false; } switch (node.kind) { - case 209: + case 211: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 215: + case 217: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 202: + case 204: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 223: + case 225: var heritageClause = node; if (heritageClause.token === 102) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 203: + case 205: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 206: + case 208: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 204: + case 206: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 135: - case 134: case 136: + case 135: case 137: case 138: - case 163: - case 201: - case 164: - case 201: + case 139: + case 165: + case 203: + case 166: + case 203: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -33093,20 +33473,20 @@ var ts; return true; } break; - case 181: + case 183: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 199: + case 201: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 158: - case 159: + case 160: + case 161: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -33114,7 +33494,7 @@ var ts; return true; } break; - case 130: + case 131: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -33130,17 +33510,17 @@ var ts; return true; } break; - case 133: + case 134: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 205: + case 207: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 161: + case 163: var typeAssertionExpression = node; diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return true; - case 131: + case 132: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -33184,7 +33564,7 @@ var ts; } function getCompilerOptionsDiagnostics() { synchronizeHostData(); - return program.getGlobalDiagnostics(); + return program.getOptionsDiagnostics().concat(program.getGlobalDiagnostics()); } function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks) { var displayName = symbol.getName(); @@ -33257,11 +33637,11 @@ var ts; } var node = currentToken; var isRightOfDot = false; - if (contextToken && contextToken.kind === 20 && contextToken.parent.kind === 156) { + if (contextToken && contextToken.kind === 20 && contextToken.parent.kind === 158) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (contextToken && contextToken.kind === 20 && contextToken.parent.kind === 127) { + else if (contextToken && contextToken.kind === 20 && contextToken.parent.kind === 128) { node = contextToken.parent.left; isRightOfDot = true; } @@ -33284,7 +33664,7 @@ var ts; function getTypeScriptMemberSymbols() { isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 65 || node.kind === 127 || node.kind === 156) { + if (node.kind === 65 || node.kind === 128 || node.kind === 158) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeChecker.getAliasedSymbol(symbol); @@ -33332,11 +33712,11 @@ var ts; symbols = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties); } } - else if (ts.getAncestor(contextToken, 211)) { + else if (ts.getAncestor(contextToken, 213)) { isMemberCompletion = true; isNewIdentifierLocation = true; if (showCompletionsInImportsClause(contextToken)) { - var importDeclaration = ts.getAncestor(contextToken, 210); + var importDeclaration = ts.getAncestor(contextToken, 212); ts.Debug.assert(importDeclaration !== undefined); var exports_2; if (importDeclaration.moduleSpecifier) { @@ -33381,7 +33761,7 @@ var ts; function showCompletionsInImportsClause(node) { if (node) { if (node.kind === 14 || node.kind === 23) { - return node.parent.kind === 213; + return node.parent.kind === 215; } } return false; @@ -33391,38 +33771,38 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23: - return containingNodeKind === 158 - || containingNodeKind === 136 - || containingNodeKind === 159 - || containingNodeKind === 154 - || containingNodeKind === 170 - || containingNodeKind === 143; + return containingNodeKind === 160 + || containingNodeKind === 137 + || containingNodeKind === 161 + || containingNodeKind === 156 + || containingNodeKind === 172 + || containingNodeKind === 145; case 16: - return containingNodeKind === 158 - || containingNodeKind === 136 - || containingNodeKind === 159 - || containingNodeKind === 162 - || containingNodeKind === 150; + return containingNodeKind === 160 + || containingNodeKind === 137 + || containingNodeKind === 161 + || containingNodeKind === 164 + || containingNodeKind === 152; case 18: - return containingNodeKind === 154; - case 117: + return containingNodeKind === 156; case 118: + case 119: return true; case 20: - return containingNodeKind === 206; + return containingNodeKind === 208; case 14: - return containingNodeKind === 202; + return containingNodeKind === 204; case 53: - return containingNodeKind === 199 - || containingNodeKind === 170; + return containingNodeKind === 201 + || containingNodeKind === 172; case 11: - return containingNodeKind === 172; + return containingNodeKind === 174; case 12: - return containingNodeKind === 178; + return containingNodeKind === 180; case 108: case 106: case 107: - return containingNodeKind === 133; + return containingNodeKind === 134; } switch (previousToken.getText()) { case "public": @@ -33452,12 +33832,12 @@ var ts; function getContainingObjectLiteralApplicableForCompletion(previousToken) { // The locations in an object literal expression that are applicable for completion are property name definition locations. if (previousToken) { - var parent_9 = previousToken.parent; + var parent_10 = previousToken.parent; switch (previousToken.kind) { case 14: case 23: - if (parent_9 && parent_9.kind === 155) { - return parent_9; + if (parent_10 && parent_10.kind === 157) { + return parent_10; } break; } @@ -33466,16 +33846,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 163: - case 164: - case 201: + case 165: + case 166: + case 203: + case 136: case 135: - case 134: - case 137: case 138: case 139: case 140: case 141: + case 142: return true; } return false; @@ -33485,63 +33865,63 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23: - return containingNodeKind === 199 || - containingNodeKind === 200 || - containingNodeKind === 181 || - containingNodeKind === 205 || - isFunction(containingNodeKind) || + return containingNodeKind === 201 || containingNodeKind === 202 || - containingNodeKind === 201 || + containingNodeKind === 183 || + containingNodeKind === 207 || + isFunction(containingNodeKind) || + containingNodeKind === 204 || containingNodeKind === 203 || - containingNodeKind === 152 || - containingNodeKind === 151; + containingNodeKind === 205 || + containingNodeKind === 154 || + containingNodeKind === 153; case 20: - return containingNodeKind === 152; + return containingNodeKind === 154; case 51: - return containingNodeKind === 153; + return containingNodeKind === 155; case 18: - return containingNodeKind === 152; + return containingNodeKind === 154; case 16: - return containingNodeKind === 224 || + return containingNodeKind === 226 || isFunction(containingNodeKind); case 14: - return containingNodeKind === 205 || - containingNodeKind === 203 || - containingNodeKind === 146 || - containingNodeKind === 151; + return containingNodeKind === 207 || + containingNodeKind === 205 || + containingNodeKind === 148 || + containingNodeKind === 153; case 22: - return containingNodeKind === 132 && + return containingNodeKind === 133 && previousToken.parent && previousToken.parent.parent && - (previousToken.parent.parent.kind === 203 || - previousToken.parent.parent.kind === 146); + (previousToken.parent.parent.kind === 205 || + previousToken.parent.parent.kind === 148); case 24: - return containingNodeKind === 202 || - containingNodeKind === 201 || + return containingNodeKind === 204 || containingNodeKind === 203 || + containingNodeKind === 205 || isFunction(containingNodeKind); case 109: - return containingNodeKind === 133; + return containingNodeKind === 134; case 21: - return containingNodeKind === 130 || - containingNodeKind === 136 || + return containingNodeKind === 131 || + containingNodeKind === 137 || (previousToken.parent && previousToken.parent.parent && - previousToken.parent.parent.kind === 152); + previousToken.parent.parent.kind === 154); case 108: case 106: case 107: - return containingNodeKind === 130; + return containingNodeKind === 131; case 69: case 77: case 103: case 83: case 98: case 116: - case 121: + case 122: case 85: case 104: case 70: case 110: - case 124: + case 125: return true; } switch (previousToken.getText()) { @@ -33572,7 +33952,7 @@ var ts; return exports; } if (importDeclaration.importClause.namedBindings && - importDeclaration.importClause.namedBindings.kind === 213) { + importDeclaration.importClause.namedBindings.kind === 215) { ts.forEach(importDeclaration.importClause.namedBindings.elements, function (el) { var name = el.propertyName || el.name; exisingImports[name.text] = true; @@ -33589,7 +33969,7 @@ var ts; } var existingMemberNames = {}; ts.forEach(existingMembers, function (m) { - if (m.kind !== 225 && m.kind !== 226) { + if (m.kind !== 227 && m.kind !== 228) { return; } if (m.getStart() <= position && position <= m.getEnd()) { @@ -33635,10 +34015,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameTable = getNameTable(sourceFile); - for (var name_30 in nameTable) { - if (!allNames[name_30]) { - allNames[name_30] = name_30; - var displayName = getCompletionEntryDisplayName(name_30, target, true); + for (var name_27 in nameTable) { + if (!allNames[name_27]) { + allNames[name_27] = name_27; + var displayName = getCompletionEntryDisplayName(name_27, target, true); if (displayName) { var entry = { name: displayName, @@ -33814,14 +34194,14 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 156) { + if (location.parent && location.parent.kind === 158) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } var callExpression; - if (location.kind === 158 || location.kind === 159) { + if (location.kind === 160 || location.kind === 161) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -33833,7 +34213,7 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 159 || callExpression.expression.kind === 91; + var useConstructSignatures = callExpression.kind === 161 || callExpression.expression.kind === 91; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -33881,21 +34261,21 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 114 && location.parent.kind === 136)) { + (location.kind === 114 && location.parent.kind === 137)) { var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 136 ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 137 ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 136) { + if (functionDeclaration.kind === 137) { symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 139 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 140 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -33918,7 +34298,7 @@ var ts; } if (symbolFlags & 524288) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(124)); + displayParts.push(ts.keywordPart(125)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); @@ -33938,9 +34318,9 @@ var ts; } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 206); + var declaration = ts.getDeclarationOfKind(symbol, 208); var isNamespace = declaration && declaration.name && declaration.name.kind === 65; - displayParts.push(ts.keywordPart(isNamespace ? 118 : 117)); + displayParts.push(ts.keywordPart(isNamespace ? 119 : 118)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -33959,13 +34339,13 @@ var ts; writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 129).parent; + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 130).parent; var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 140) { + if (signatureDeclaration.kind === 141) { displayParts.push(ts.keywordPart(88)); displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 139 && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 140 && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); @@ -33974,7 +34354,7 @@ var ts; if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 227) { + if (declaration.kind === 229) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -33990,13 +34370,13 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 209) { + if (declaration.kind === 211) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); displayParts.push(ts.operatorPart(53)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(119)); + displayParts.push(ts.keywordPart(120)); displayParts.push(ts.punctuationPart(16)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(17)); @@ -34120,8 +34500,8 @@ var ts; if (!symbol) { switch (node.kind) { case 65: - case 156: - case 127: + case 158: + case 128: case 93: case 91: var type = typeChecker.getTypeAtLocation(node); @@ -34175,7 +34555,7 @@ var ts; if (isNewExpressionTarget(location) || location.kind === 114) { if (symbol.flags & 32) { var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 202); + ts.Debug.assert(classDeclaration && classDeclaration.kind === 204); return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); } } @@ -34191,8 +34571,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 136) || - (!selectConstructors && (d.kind === 201 || d.kind === 135 || d.kind === 134))) { + if ((selectConstructors && d.kind === 137) || + (!selectConstructors && (d.kind === 203 || d.kind === 136 || d.kind === 135))) { declarations.push(d); if (d.body) definition = d; @@ -34247,7 +34627,7 @@ var ts; symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 226) { + if (node.parent.kind === 228) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -34280,7 +34660,7 @@ var ts; var result = []; ts.forEach(type.types, function (t) { if (t.symbol) { - result.push.apply(result, getDefinitionFromSymbol(t.symbol, node)); + ts.addRange(result, getDefinitionFromSymbol(t.symbol, node)); } }); return result; @@ -34371,74 +34751,74 @@ var ts; switch (node.kind) { case 84: case 76: - if (hasKind(node.parent, 184)) { + if (hasKind(node.parent, 186)) { return getIfElseOccurrences(node.parent); } break; case 90: - if (hasKind(node.parent, 192)) { + if (hasKind(node.parent, 194)) { return getReturnOccurrences(node.parent); } break; case 94: - if (hasKind(node.parent, 196)) { + if (hasKind(node.parent, 198)) { return getThrowOccurrences(node.parent); } break; case 68: - if (hasKind(parent(parent(node)), 197)) { + if (hasKind(parent(parent(node)), 199)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 96: case 81: - if (hasKind(parent(node), 197)) { + if (hasKind(parent(node), 199)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 92: - if (hasKind(node.parent, 194)) { + if (hasKind(node.parent, 196)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 67: case 73: - if (hasKind(parent(parent(parent(node))), 194)) { + if (hasKind(parent(parent(parent(node))), 196)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 66: case 71: - if (hasKind(node.parent, 191) || hasKind(node.parent, 190)) { + if (hasKind(node.parent, 193) || hasKind(node.parent, 192)) { return getBreakOrContinueStatementOccurences(node.parent); } break; case 82: - if (hasKind(node.parent, 187) || - hasKind(node.parent, 188) || - hasKind(node.parent, 189)) { + if (hasKind(node.parent, 189) || + hasKind(node.parent, 190) || + hasKind(node.parent, 191)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 100: case 75: - if (hasKind(node.parent, 186) || hasKind(node.parent, 185)) { + if (hasKind(node.parent, 188) || hasKind(node.parent, 187)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 114: - if (hasKind(node.parent, 136)) { + if (hasKind(node.parent, 137)) { return getConstructorOccurrences(node.parent); } break; case 116: - case 121: - if (hasKind(node.parent, 137) || hasKind(node.parent, 138)) { + case 122: + if (hasKind(node.parent, 138) || hasKind(node.parent, 139)) { return getGetAndSetOccurrences(node.parent); } default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 181)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 183)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -34450,10 +34830,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 196) { + if (node.kind === 198) { statementAccumulator.push(node); } - else if (node.kind === 197) { + else if (node.kind === 199) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -34474,17 +34854,17 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_10 = child.parent; - if (ts.isFunctionBlock(parent_10) || parent_10.kind === 228) { - return parent_10; + var parent_11 = child.parent; + if (ts.isFunctionBlock(parent_11) || parent_11.kind === 230) { + return parent_11; } - if (parent_10.kind === 197) { - var tryStatement = parent_10; + if (parent_11.kind === 199) { + var tryStatement = parent_11; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_10; + child = parent_11; } return undefined; } @@ -34493,7 +34873,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 191 || node.kind === 190) { + if (node.kind === 193 || node.kind === 192) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -34507,23 +34887,23 @@ var ts; return actualOwner && actualOwner === owner; } function getBreakOrContinueOwner(statement) { - for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { - switch (node_1.kind) { - case 194: - if (statement.kind === 190) { + for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { + switch (node_2.kind) { + case 196: + if (statement.kind === 192) { continue; } - case 187: - case 188: case 189: - case 186: - case 185: - if (!statement.label || isLabeledBy(node_1, statement.label.text)) { - return node_1; + case 190: + case 191: + case 188: + case 187: + if (!statement.label || isLabeledBy(node_2, statement.label.text)) { + return node_2; } break; default: - if (ts.isFunctionLike(node_1)) { + if (ts.isFunctionLike(node_2)) { return undefined; } break; @@ -34534,18 +34914,18 @@ var ts; function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 202 || - (declaration.kind === 130 && hasKind(container, 136)))) { + if (!(container.kind === 204 || + (declaration.kind === 131 && hasKind(container, 137)))) { return undefined; } } else if (modifier === 109) { - if (container.kind !== 202) { + if (container.kind !== 204) { return undefined; } } else if (modifier === 78 || modifier === 115) { - if (!(container.kind === 207 || container.kind === 228)) { + if (!(container.kind === 209 || container.kind === 230)) { return undefined; } } @@ -34556,18 +34936,18 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 207: - case 228: + case 209: + case 230: nodes = container.statements; break; - case 136: + case 137: nodes = container.parameters.concat(container.parent.members); break; - case 202: + case 204: nodes = container.members; if (modifierFlag & 112) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 136 && member; + return member.kind === 137 && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -34615,13 +34995,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 137); tryPushAccessorKeyword(accessorDeclaration.symbol, 138); + tryPushAccessorKeyword(accessorDeclaration.symbol, 139); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 116, 121); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 116, 122); }); } } } @@ -34638,7 +35018,7 @@ var ts; function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 82, 100, 75)) { - if (loopNode.kind === 185) { + if (loopNode.kind === 187) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 100)) { @@ -34659,13 +35039,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { + case 189: + case 190: + case 191: case 187: case 188: - case 189: - case 185: - case 186: return getLoopBreakContinueOccurrences(owner); - case 194: + case 196: return getSwitchCaseDefaultOccurrences(owner); } } @@ -34715,7 +35095,7 @@ var ts; } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 180))) { + if (!(func && hasKind(func.body, 182))) { return undefined; } var keywords = []; @@ -34729,7 +35109,7 @@ var ts; } function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 184) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 186) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { @@ -34740,7 +35120,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 184)) { + if (!hasKind(ifStatement.elseStatement, 186)) { break; } ifStatement = ifStatement.elseStatement; @@ -34898,16 +35278,16 @@ var ts; } function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 214 || location.parent.kind === 218) && + (location.parent.kind === 216 || location.parent.kind === 220) && location.parent.propertyName === location; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 214 || declaration.kind === 218; + return declaration.kind === 216 || declaration.kind === 220; }); } function getDeclaredName(symbol, location) { - var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 163 ? d : undefined; }); + var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 165 ? d : undefined; }); var name; if (functionExpression && functionExpression.name) { name = functionExpression.name.text; @@ -34922,7 +35302,7 @@ var ts; if (isImportOrExportSpecifierName(location)) { return location.getText(); } - var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 163 ? d : undefined; }); + var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 165 ? d : undefined; }); var name = functionExpression && functionExpression.name ? functionExpression.name.text : symbol.name; @@ -34940,7 +35320,7 @@ var ts; if (symbol.flags & (4 | 8192)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 202); + return ts.getAncestor(privateDeclaration, 204); } } if (symbol.flags & 8388608) { @@ -34961,7 +35341,7 @@ var ts; if (scope && scope !== container) { return undefined; } - if (container.kind === 228 && !ts.isExternalModule(container)) { + if (container.kind === 230 && !ts.isExternalModule(container)) { return undefined; } scope = container; @@ -35120,13 +35500,13 @@ var ts; } var staticFlag = 128; switch (searchSpaceNode.kind) { - case 133: - case 132: - case 135: case 134: + case 133: case 136: + case 135: case 137: case 138: + case 139: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; @@ -35154,32 +35534,32 @@ var ts; var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); var staticFlag = 128; switch (searchSpaceNode.kind) { + case 136: case 135: - case 134: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } + case 134: case 133: - case 132: - case 136: case 137: case 138: + case 139: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; - case 228: + case 230: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 201: - case 163: + case 203: + case 165: break; default: return undefined; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 228) { + if (searchSpaceNode.kind === 230) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -35210,25 +35590,25 @@ var ts; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 163: - case 201: + case 165: + case 203: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; + case 136: case 135: - case 134: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 202: + case 204: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 228: - if (container.kind === 228 && !ts.isExternalModule(container)) { + case 230: + if (container.kind === 230 && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -35263,11 +35643,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 | 64)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 202) { + if (declaration.kind === 204) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 203) { + else if (declaration.kind === 205) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -35317,17 +35697,17 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_31 = node.text; + var name_28 = node.text; if (contextualType) { if (contextualType.flags & 16384) { - var unionProperty = contextualType.getProperty(name_31); + var unionProperty = contextualType.getProperty(name_28); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_31); + var symbol = t.getProperty(name_28); if (symbol) { result_4.push(symbol); } @@ -35336,7 +35716,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_31); + var symbol_1 = contextualType.getProperty(name_28); if (symbol_1) { return [symbol_1]; } @@ -35381,10 +35761,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 169 || parent.kind === 168) { + if (parent.kind === 171 || parent.kind === 170) { return true; } - else if (parent.kind === 170 && parent.left === node) { + else if (parent.kind === 172 && parent.left === node) { var operator = parent.operatorToken.kind; return 53 <= operator && operator <= 64; } @@ -35417,33 +35797,33 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 130: - case 199: - case 153: - case 133: - case 132: - case 225: - case 226: - case 227: - case 135: + case 131: + case 201: + case 155: case 134: + case 133: + case 227: + case 228: + case 229: case 136: + case 135: case 137: case 138: - case 201: - case 163: - case 164: - case 224: - return 1; - case 129: + case 139: case 203: - case 204: - case 146: - return 2; - case 202: + case 165: + case 166: + case 226: + return 1; + case 130: case 205: - return 1 | 2; case 206: + case 148: + return 2; + case 204: + case 207: + return 1 | 2; + case 208: if (node.name.kind === 8) { return 4 | 1; } @@ -35453,14 +35833,14 @@ var ts; else { return 4; } - case 213: - case 214: - case 209: - case 210: case 215: case 216: + case 211: + case 212: + case 217: + case 218: return 1 | 2 | 4; - case 228: + case 230: return 4 | 1; } return 1 | 2 | 4; @@ -35470,7 +35850,8 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 142 || node.parent.kind === 177; + return node.parent.kind === 144 || + (node.parent.kind === 179 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -35478,47 +35859,47 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 156) { - while (root.parent && root.parent.kind === 156) { + if (root.parent.kind === 158) { + while (root.parent && root.parent.kind === 158) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 177 && root.parent.parent.kind === 223) { + if (!isLastClause && root.parent.kind === 179 && root.parent.parent.kind === 225) { var decl = root.parent.parent.parent; - return (decl.kind === 202 && root.parent.parent.token === 102) || - (decl.kind === 203 && root.parent.parent.token === 79); + return (decl.kind === 204 && root.parent.parent.token === 102) || + (decl.kind === 205 && root.parent.parent.token === 79); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 127) { - while (root.parent && root.parent.kind === 127) { + if (root.parent.kind === 128) { + while (root.parent && root.parent.kind === 128) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 142 && !isLastClause; + return root.parent.kind === 144 && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 127) { + while (node.parent.kind === 128) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { ts.Debug.assert(node.kind === 65); - if (node.parent.kind === 127 && + if (node.parent.kind === 128 && node.parent.right === node && - node.parent.parent.kind === 209) { + node.parent.parent.kind === 211) { return 1 | 2 | 4; } return 4; } function getMeaningFromLocation(node) { - if (node.parent.kind === 215) { + if (node.parent.kind === 217) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -35552,8 +35933,8 @@ var ts; return; } switch (node.kind) { - case 156: - case 127: + case 158: + case 128: case 8: case 80: case 95: @@ -35571,7 +35952,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 206 && + if (nodeForStartPos.parent.parent.kind === 208 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -35601,6 +35982,7 @@ var ts; var sourceFile = getValidSourceFile(fileName); var typeChecker = program.getTypeChecker(); var result = []; + var classifiableNames = program.getClassifiableNames(); processNode(sourceFile); return { spans: result, endOfLineState: 0 }; function pushClassification(start, length, type) { @@ -35610,6 +35992,9 @@ var ts; } function classifySymbol(symbol, meaningAtPosition) { var flags = symbol.getFlags(); + if ((flags & 788448) === 0) { + return; + } if (flags & 32) { return 11; } @@ -35636,18 +36021,22 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 206 && ts.getModuleInstanceState(declaration) == 1; + return declaration.kind === 208 && + ts.getModuleInstanceState(declaration) === 1; }); } } function processNode(node) { - if (node && ts.textSpanIntersectsWith(span, node.getStart(), node.getWidth())) { - if (node.kind === 65 && node.getWidth() > 0) { - var symbol = typeChecker.getSymbolAtLocation(node); - if (symbol) { - var type = classifySymbol(symbol, getMeaningFromLocation(node)); - if (type) { - pushClassification(node.getStart(), node.getWidth(), type); + if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { + if (node.kind === 65 && !ts.nodeIsMissing(node)) { + var identifier = node; + if (classifiableNames[identifier.text]) { + var symbol = typeChecker.getSymbolAtLocation(node); + if (symbol) { + var type = classifySymbol(symbol, getMeaningFromLocation(node)); + if (type) { + pushClassification(node.getStart(), node.getWidth(), type); + } } } } @@ -35693,6 +36082,8 @@ var ts; } function getEncodedSyntacticClassifications(fileName, span) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var spanStart = span.start; + var spanLength = span.length; var triviaScanner = ts.createScanner(2, false, sourceFile.text); var mergeConflictScanner = ts.createScanner(2, false, sourceFile.text); var result = []; @@ -35703,35 +36094,36 @@ var ts; result.push(length); result.push(type); } - function classifyLeadingTrivia(token) { - var tokenStart = ts.skipTrivia(sourceFile.text, token.pos, false); - if (tokenStart === token.pos) { - return; - } + function classifyLeadingTriviaAndGetTokenStart(token) { triviaScanner.setTextPos(token.pos); while (true) { var start = triviaScanner.getTextPos(); + if (!ts.couldStartTrivia(sourceFile.text, start)) { + return start; + } var kind = triviaScanner.scan(); var end = triviaScanner.getTextPos(); var width = end - start; if (!ts.isTrivia(kind)) { - return; + return start; } - if (ts.textSpanIntersectsWith(span, start, width)) { - if (ts.isComment(kind)) { - classifyComment(token, kind, start, width); + if (kind === 4 || kind === 5) { + continue; + } + if (ts.isComment(kind)) { + classifyComment(token, kind, start, width); + triviaScanner.setTextPos(end); + continue; + } + if (kind === 6) { + var text = sourceFile.text; + var ch = text.charCodeAt(start); + if (ch === 60 || ch === 62) { + pushClassification(start, width, 1); continue; } - if (kind === 6) { - var text = sourceFile.text; - var ch = text.charCodeAt(start); - if (ch === 60 || ch === 62) { - pushClassification(start, width, 1); - continue; - } - ts.Debug.assert(ch === 61); - classifyDisabledMergeCode(text, start, end); - } + ts.Debug.assert(ch === 61); + classifyDisabledMergeCode(text, start, end); } } } @@ -35760,16 +36152,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 247: + case 249: processJSDocParameterTag(tag); break; - case 250: + case 252: processJSDocTemplateTag(tag); break; - case 249: + case 251: processElement(tag.typeExpression); break; - case 248: + case 250: processElement(tag.typeExpression); break; } @@ -35825,11 +36217,13 @@ var ts; } } function classifyToken(token) { - classifyLeadingTrivia(token); - if (token.getWidth() > 0) { + var tokenStart = classifyLeadingTriviaAndGetTokenStart(token); + var tokenWidth = token.end - tokenStart; + ts.Debug.assert(tokenWidth >= 0); + if (tokenWidth > 0) { var type = classifyTokenType(token.kind, token); if (type) { - pushClassification(token.getStart(), token.getWidth(), type); + pushClassification(tokenStart, tokenWidth, type); } } } @@ -35845,16 +36239,16 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { if (tokenKind === 53) { - if (token.parent.kind === 199 || - token.parent.kind === 133 || - token.parent.kind === 130) { + if (token.parent.kind === 201 || + token.parent.kind === 134 || + token.parent.kind === 131) { return 5; } } - if (token.parent.kind === 170 || - token.parent.kind === 168 || - token.parent.kind === 169 || - token.parent.kind === 171) { + if (token.parent.kind === 172 || + token.parent.kind === 170 || + token.parent.kind === 171 || + token.parent.kind === 173) { return 5; } } @@ -35875,32 +36269,32 @@ var ts; else if (tokenKind === 65) { if (token) { switch (token.parent.kind) { - case 202: + case 204: if (token.parent.name === token) { return 11; } return; - case 129: + case 130: if (token.parent.name === token) { return 15; } return; - case 203: + case 205: if (token.parent.name === token) { return 13; } return; - case 205: + case 207: if (token.parent.name === token) { return 12; } return; - case 206: + case 208: if (token.parent.name === token) { return 14; } return; - case 130: + case 131: if (token.parent.name === token) { return 17; } @@ -35914,10 +36308,10 @@ var ts; if (!element) { return; } - if (ts.textSpanIntersectsWith(span, element.getFullStart(), element.getFullWidth())) { + if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { var children = element.getChildren(sourceFile); - for (var _i = 0; _i < children.length; _i++) { - var child = children[_i]; + for (var i = 0, n = children.length; i < n; i++) { + var child = children[i]; if (ts.isToken(child)) { classifyToken(child); } @@ -36169,7 +36563,7 @@ var ts; case 8: case 7: if (ts.isDeclarationName(node) || - node.parent.kind === 220 || + node.parent.kind === 222 || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -36182,7 +36576,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 157 && + node.parent.kind === 159 && node.parent.argumentExpression === node; } function createClassifier() { @@ -36204,7 +36598,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 116 || - keyword2 === 121 || + keyword2 === 122 || keyword2 === 114 || keyword2 === 109) { return true; @@ -36320,10 +36714,10 @@ var ts; angleBracketStack--; } else if (token === 112 || - token === 122 || - token === 120 || + token === 123 || + token === 121 || token === 113 || - token === 123) { + token === 124) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { token = 65; } @@ -36477,7 +36871,7 @@ var ts; } } function isKeyword(token) { - return token >= 66 && token <= 126; + return token >= 66 && token <= 127; } function classFromKind(token) { if (isKeyword(token)) { @@ -36529,7 +36923,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 228 ? new SourceFileObject() : new NodeObject(); + var proto = kind === 230 ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = 0; proto.end = 0; @@ -36547,7 +36941,6 @@ var ts; })(ts || (ts = {})); /// /// -/// /// /// var ts; @@ -36570,7 +36963,7 @@ var ts; if (a < b) { return -1; } - else if (a == b) { + else if (a === b) { return 0; } else @@ -36582,7 +36975,7 @@ var ts; } else if (a.file == b.file) { var n = compareNumber(a.start.line, b.start.line); - if (n == 0) { + if (n === 0) { return compareNumber(a.start.offset, b.start.offset); } else @@ -36639,9 +37032,11 @@ var ts; Errors.NoProject = new Error("No Project."); })(Errors || (Errors = {})); var Session = (function () { - function Session(host, logger) { + function Session(host, byteLength, hrtime, logger) { var _this = this; this.host = host; + this.byteLength = byteLength; + this.hrtime = hrtime; this.logger = logger; this.pendingOperation = false; this.fileHash = {}; @@ -36656,7 +37051,7 @@ var ts; var _this = this; if (eventName == "context") { this.projectService.log("got context event, updating diagnostics for" + fileName, "Info"); - this.updateErrorCheck([{ fileName: fileName, project: project }], this.changeSeq, function (n) { return n == _this.changeSeq; }, 100); + this.updateErrorCheck([{ fileName: fileName, project: project }], this.changeSeq, function (n) { return n === _this.changeSeq; }, 100); } }; Session.prototype.logError = function (err, cmd) { @@ -36678,7 +37073,7 @@ var ts; if (this.logger.isVerbose()) { this.logger.info(msg.type + ": " + json); } - this.sendLineToClient('Content-Length: ' + (1 + Buffer.byteLength(json, 'utf8')) + + this.sendLineToClient('Content-Length: ' + (1 + this.byteLength(json, 'utf8')) + '\r\n\r\n' + json); }; Session.prototype.event = function (info, eventName) { @@ -37015,7 +37410,7 @@ var ts; var position = compilerService.host.lineOffsetToPosition(file, line, offset); var formatOptions = this.projectService.getFormatCodeOptions(file); var edits = compilerService.languageService.getFormattingEditsAfterKeystroke(file, position, key, formatOptions); - if ((key == "\n") && ((!edits) || (edits.length == 0) || allEditsBeforePos(edits, position))) { + if ((key == "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) { var scriptInfo = compilerService.host.getScriptInfo(file); if (scriptInfo) { var lineInfo = scriptInfo.getLineInfo(line); @@ -37081,7 +37476,7 @@ var ts; return undefined; } return completions.entries.reduce(function (result, entry) { - if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) == 0)) { + if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { result.push(entry); } return result; @@ -37139,7 +37534,7 @@ var ts; return accum; }, []); if (checkList.length > 0) { - this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n == _this.changeSeq; }, delay); + this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n === _this.changeSeq; }, delay); } }; Session.prototype.change = function (line, offset, endLine, endOffset, insertString, fileName) { @@ -37154,7 +37549,7 @@ var ts; compilerService.host.editScript(file, start, end, insertString); this.changeSeq++; } - this.updateProjectStructure(this.changeSeq, function (n) { return n == _this.changeSeq; }); + this.updateProjectStructure(this.changeSeq, function (n) { return n === _this.changeSeq; }); } }; Session.prototype.reload = function (fileName, tempFileName, reqSeq) { @@ -37270,7 +37665,7 @@ var ts; Session.prototype.onMessage = function (message) { if (this.logger.isVerbose()) { this.logger.info("request: " + message); - var start = process.hrtime(); + var start = this.hrtime(); } try { var request = JSON.parse(message); @@ -37409,7 +37804,7 @@ var ts; } } if (this.logger.isVerbose()) { - var elapsed = process.hrtime(start); + var elapsed = this.hrtime(start); var seconds = elapsed[0]; var nanoseconds = elapsed[1]; var elapsedMs = ((1e9 * seconds) + nanoseconds) / 1000000.0; @@ -37442,7 +37837,6 @@ var ts; /// /// /// -/// var ts; (function (ts) { var server; @@ -37466,7 +37860,7 @@ var ts; this.isOpen = isOpen; this.children = []; this.formatCodeOptions = ts.clone(CompilerService.defaultFormatCodeOptions); - this.svc = ScriptVersionCache.fromString(content); + this.svc = ScriptVersionCache.fromString(host, content); } ScriptInfo.prototype.setFormatOptions = function (formatOptions) { if (formatOptions) { @@ -37501,6 +37895,7 @@ var ts; }; return ScriptInfo; })(); + server.ScriptInfo = ScriptInfo; var LSHost = (function () { function LSHost(host, project) { this.host = host; @@ -37631,6 +38026,7 @@ var ts; }; return LSHost; })(); + server.LSHost = LSHost; function getAbsolutePath(filename, directory) { var rootLength = ts.getRootLength(filename); if (rootLength > 0) { @@ -37931,7 +38327,7 @@ var ts; var orphanFiles = []; for (var i = 0, len = this.openFilesReferenced.length; i < len; i++) { var f = this.openFilesReferenced[i]; - if (f.defaultProject == removedProject) { + if (f.defaultProject === removedProject) { f.defaultProject = undefined; orphanFiles.push(f); } @@ -37955,7 +38351,7 @@ var ts; for (var i = 0, len = this.inferredProjects.length; i < len; i++) { var inferredProject = this.inferredProjects[i]; inferredProject.updateGraph(); - if (inferredProject != excludedProject) { + if (inferredProject !== excludedProject) { if (inferredProject.getSourceFile(info)) { info.defaultProject = inferredProject; referencingProjects.push(inferredProject); @@ -37993,7 +38389,7 @@ var ts; var rootFile = this.openFileRoots[i]; var rootedProject = rootFile.defaultProject; var referencingProjects = this.findReferencingProjects(rootFile, rootedProject); - if (referencingProjects.length == 0) { + if (referencingProjects.length === 0) { rootFile.defaultProject = rootedProject; openFileRoots.push(rootFile); } @@ -38167,7 +38563,7 @@ var ts; return rawConfig.error; } else { - var parsedCommandLine = ts.parseConfigFile(rawConfig.config, ts.sys, dirPath); + var parsedCommandLine = ts.parseConfigFile(rawConfig.config, this.host, dirPath); if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) { return { errorMsg: "tsconfig option errors" }; } @@ -38228,7 +38624,7 @@ var ts; CompilerService.defaultFormatCodeOptions = { IndentSize: 4, TabSize: 4, - NewLineCharacter: ts.sys.newLine, + NewLineCharacter: ts.sys ? ts.sys.newLine : '\n', ConvertTabsToSpaces: true, InsertSpaceAfterCommaDelimiter: true, InsertSpaceAfterSemicolonInForStatements: true, @@ -38241,7 +38637,7 @@ var ts; }; return CompilerService; })(); - var CharRangeSection; + server.CompilerService = CompilerService; (function (CharRangeSection) { CharRangeSection[CharRangeSection["PreStart"] = 0] = "PreStart"; CharRangeSection[CharRangeSection["Start"] = 1] = "Start"; @@ -38249,7 +38645,8 @@ var ts; CharRangeSection[CharRangeSection["Mid"] = 3] = "Mid"; CharRangeSection[CharRangeSection["End"] = 4] = "End"; CharRangeSection[CharRangeSection["PostEnd"] = 5] = "PostEnd"; - })(CharRangeSection || (CharRangeSection = {})); + })(server.CharRangeSection || (server.CharRangeSection = {})); + var CharRangeSection = server.CharRangeSection; var BaseLineIndexWalker = (function () { function BaseLineIndexWalker() { this.goSubtree = true; @@ -38294,7 +38691,7 @@ var ts; var lastZeroCount; for (var k = this.endBranch.length - 1; k >= 0; k--) { this.endBranch[k].updateCounts(); - if (this.endBranch[k].charCount() == 0) { + if (this.endBranch[k].charCount() === 0) { lastZeroCount = this.endBranch[k]; if (k > 0) { branchParent = this.endBranch[k - 1]; @@ -38350,7 +38747,7 @@ var ts; return this.lineIndex; }; EditWalker.prototype.post = function (relativeStart, relativeLength, lineCollection, parent, nodeType) { - if (lineCollection == this.lineCollectionAtBranch) { + if (lineCollection === this.lineCollectionAtBranch) { this.state = CharRangeSection.End; } this.stack.length--; @@ -38358,7 +38755,7 @@ var ts; }; EditWalker.prototype.pre = function (relativeStart, relativeLength, lineCollection, parent, nodeType) { var currentNode = this.stack[this.stack.length - 1]; - if ((this.state == CharRangeSection.Entire) && (nodeType == CharRangeSection.Start)) { + if ((this.state === CharRangeSection.Entire) && (nodeType === CharRangeSection.Start)) { this.state = CharRangeSection.Start; this.branchNode = currentNode; this.lineCollectionAtBranch = lineCollection; @@ -38374,12 +38771,12 @@ var ts; switch (nodeType) { case CharRangeSection.PreStart: this.goSubtree = false; - if (this.state != CharRangeSection.End) { + if (this.state !== CharRangeSection.End) { currentNode.add(lineCollection); } break; case CharRangeSection.Start: - if (this.state == CharRangeSection.End) { + if (this.state === CharRangeSection.End) { this.goSubtree = false; } else { @@ -38389,7 +38786,7 @@ var ts; } break; case CharRangeSection.Entire: - if (this.state != CharRangeSection.End) { + if (this.state !== CharRangeSection.End) { child = fresh(lineCollection); currentNode.add(child); this.startPath[this.startPath.length] = child; @@ -38406,7 +38803,7 @@ var ts; this.goSubtree = false; break; case CharRangeSection.End: - if (this.state != CharRangeSection.End) { + if (this.state !== CharRangeSection.End) { this.goSubtree = false; } else { @@ -38419,7 +38816,7 @@ var ts; break; case CharRangeSection.PostEnd: this.goSubtree = false; - if (this.state != CharRangeSection.Start) { + if (this.state !== CharRangeSection.Start) { currentNode.add(lineCollection); } break; @@ -38430,10 +38827,10 @@ var ts; return lineCollection; }; EditWalker.prototype.leaf = function (relativeStart, relativeLength, ll) { - if (this.state == CharRangeSection.Start) { + if (this.state === CharRangeSection.Start) { this.initialText = ll.text.substring(0, relativeStart); } - else if (this.state == CharRangeSection.Entire) { + else if (this.state === CharRangeSection.Entire) { this.initialText = ll.text.substring(0, relativeStart); this.trailingText = ll.text.substring(relativeStart + relativeLength); } @@ -38454,6 +38851,7 @@ var ts; }; return TextChange; })(); + server.TextChange = TextChange; var ScriptVersionCache = (function () { function ScriptVersionCache() { this.changes = []; @@ -38479,7 +38877,7 @@ var ts; return this.currentVersion; }; ScriptVersionCache.prototype.reloadFromFile = function (filename, cb) { - var content = ts.sys.readFile(filename); + var content = this.host.readFile(filename); this.reload(content); if (cb) cb(); @@ -38542,10 +38940,11 @@ var ts; return ts.unchangedTextChangeRange; } }; - ScriptVersionCache.fromString = function (script) { + ScriptVersionCache.fromString = function (host, script) { var svc = new ScriptVersionCache(); var snap = new LineIndexSnapshot(0, svc); svc.versions[svc.currentVersion] = snap; + svc.host = host; snap.index = new LineIndex(); var lm = LineIndex.linesFromText(script); snap.index.load(lm.lines); @@ -38600,6 +38999,7 @@ var ts; }; return LineIndexSnapshot; })(); + server.LineIndexSnapshot = LineIndexSnapshot; var LineIndex = (function () { function LineIndex() { this.checkEdits = false; @@ -38673,7 +39073,7 @@ var ts; if (nt === void 0) { nt = ""; } return source.substring(0, s) + nt + source.substring(s + dl, source.length); } - if (this.root.charCount() == 0) { + if (this.root.charCount() === 0) { if (newText) { this.load(LineIndex.linesFromText(newText).lines); return this; @@ -38699,7 +39099,7 @@ var ts; else if (deleteLength > 0) { var e = pos + deleteLength; var lineInfo = this.charOffsetToLineNumberAndPos(e); - if ((lineInfo && (lineInfo.offset == 0))) { + if ((lineInfo && (lineInfo.offset === 0))) { deleteLength += lineInfo.text.length; if (newText) { newText = newText + lineInfo.text; @@ -38742,7 +39142,7 @@ var ts; interiorNodes[i].totalChars = charCount; interiorNodes[i].totalLines = lineCount; } - if (interiorNodes.length == 1) { + if (interiorNodes.length === 1) { return interiorNodes[0]; } else { @@ -38751,7 +39151,7 @@ var ts; }; LineIndex.linesFromText = function (text) { var lineStarts = ts.computeLineStarts(text); - if (lineStarts.length == 0) { + if (lineStarts.length === 0) { return { lines: [], lineMap: lineStarts }; } var lines = new Array(lineStarts.length); @@ -38972,7 +39372,7 @@ var ts; LineNode.prototype.findChildIndex = function (child) { var childIndex = 0; var clen = this.children.length; - while ((this.children[childIndex] != child) && (childIndex < clen)) + while ((this.children[childIndex] !== child) && (childIndex < clen)) childIndex++; return childIndex; }; @@ -38980,7 +39380,7 @@ var ts; var childIndex = this.findChildIndex(child); var clen = this.children.length; var nodeCount = nodes.length; - if ((clen < lineCollectionCapacity) && (childIndex == (clen - 1)) && (nodeCount == 1)) { + if ((clen < lineCollectionCapacity) && (childIndex === (clen - 1)) && (nodeCount === 1)) { this.add(nodes[0]); this.updateCounts(); return []; @@ -39004,13 +39404,13 @@ var ts; var splitNode = splitNodes[0]; while (nodeIndex < nodeCount) { splitNode.add(nodes[nodeIndex++]); - if (splitNode.children.length == lineCollectionCapacity) { + if (splitNode.children.length === lineCollectionCapacity) { splitNodeIndex++; splitNode = splitNodes[splitNodeIndex]; } } for (i = splitNodes.length - 1; i >= 0; i--) { - if (splitNodes[i].children.length == 0) { + if (splitNodes[i].children.length === 0) { splitNodes.length--; } } @@ -39037,6 +39437,7 @@ var ts; }; return LineNode; })(); + server.LineNode = LineNode; var LineLeaf = (function () { function LineLeaf(text) { this.text = text; @@ -39061,6 +39462,7 @@ var ts; }; return LineLeaf; })(); + server.LineLeaf = LineLeaf; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); /// @@ -39170,7 +39572,7 @@ var ts; if (err) { watchedFile.callback(watchedFile.fileName); } - else if (watchedFile.mtime.getTime() != stats.mtime.getTime()) { + else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { watchedFile.mtime = WatchedFileSet.getModifiedTime(watchedFile.fileName); watchedFile.callback(watchedFile.fileName); } @@ -39182,7 +39584,7 @@ var ts; var count = 0; var nextToCheck = _this.nextFileToCheck; var firstCheck = -1; - while ((count < _this.chunkSize) && (nextToCheck != firstCheck)) { + while ((count < _this.chunkSize) && (nextToCheck !== firstCheck)) { _this.poll(nextToCheck); if (firstCheck < 0) { firstCheck = nextToCheck; @@ -39216,7 +39618,7 @@ var ts; var IOSession = (function (_super) { __extends(IOSession, _super); function IOSession(host, logger) { - _super.call(this, host, logger); + _super.call(this, host, Buffer.byteLength, process.hrtime, logger); } IOSession.prototype.exit = function () { this.projectService.log("Exiting...", "Info"); diff --git a/bin/typescript.d.ts b/bin/typescript.d.ts index c8e4ae8bc69..2fd4bb2c2f3 100644 --- a/bin/typescript.d.ts +++ b/bin/typescript.d.ts @@ -17,6 +17,13 @@ declare module "typescript" { interface Map { [index: string]: T; } + interface FileMap { + get(fileName: string): T; + set(fileName: string, value: T): void; + contains(fileName: string): boolean; + remove(fileName: string): void; + forEachValue(f: (v: T) => void): void; + } interface TextRange { pos: number; end: number; @@ -139,156 +146,158 @@ declare module "typescript" { ConstructorKeyword = 114, DeclareKeyword = 115, GetKeyword = 116, - ModuleKeyword = 117, - NamespaceKeyword = 118, - RequireKeyword = 119, - NumberKeyword = 120, - SetKeyword = 121, - StringKeyword = 122, - SymbolKeyword = 123, - TypeKeyword = 124, - FromKeyword = 125, - OfKeyword = 126, - QualifiedName = 127, - ComputedPropertyName = 128, - TypeParameter = 129, - Parameter = 130, - Decorator = 131, - PropertySignature = 132, - PropertyDeclaration = 133, - MethodSignature = 134, - MethodDeclaration = 135, - Constructor = 136, - GetAccessor = 137, - SetAccessor = 138, - CallSignature = 139, - ConstructSignature = 140, - IndexSignature = 141, - TypeReference = 142, - FunctionType = 143, - ConstructorType = 144, - TypeQuery = 145, - TypeLiteral = 146, - ArrayType = 147, - TupleType = 148, - UnionType = 149, - ParenthesizedType = 150, - ObjectBindingPattern = 151, - ArrayBindingPattern = 152, - BindingElement = 153, - ArrayLiteralExpression = 154, - ObjectLiteralExpression = 155, - PropertyAccessExpression = 156, - ElementAccessExpression = 157, - CallExpression = 158, - NewExpression = 159, - TaggedTemplateExpression = 160, - TypeAssertionExpression = 161, - ParenthesizedExpression = 162, - FunctionExpression = 163, - ArrowFunction = 164, - DeleteExpression = 165, - TypeOfExpression = 166, - VoidExpression = 167, - PrefixUnaryExpression = 168, - PostfixUnaryExpression = 169, - BinaryExpression = 170, - ConditionalExpression = 171, - TemplateExpression = 172, - YieldExpression = 173, - SpreadElementExpression = 174, - ClassExpression = 175, - OmittedExpression = 176, - ExpressionWithTypeArguments = 177, - TemplateSpan = 178, - SemicolonClassElement = 179, - Block = 180, - VariableStatement = 181, - EmptyStatement = 182, - ExpressionStatement = 183, - IfStatement = 184, - DoStatement = 185, - WhileStatement = 186, - ForStatement = 187, - ForInStatement = 188, - ForOfStatement = 189, - ContinueStatement = 190, - BreakStatement = 191, - ReturnStatement = 192, - WithStatement = 193, - SwitchStatement = 194, - LabeledStatement = 195, - ThrowStatement = 196, - TryStatement = 197, - DebuggerStatement = 198, - VariableDeclaration = 199, - VariableDeclarationList = 200, - FunctionDeclaration = 201, - ClassDeclaration = 202, - InterfaceDeclaration = 203, - TypeAliasDeclaration = 204, - EnumDeclaration = 205, - ModuleDeclaration = 206, - ModuleBlock = 207, - CaseBlock = 208, - ImportEqualsDeclaration = 209, - ImportDeclaration = 210, - ImportClause = 211, - NamespaceImport = 212, - NamedImports = 213, - ImportSpecifier = 214, - ExportAssignment = 215, - ExportDeclaration = 216, - NamedExports = 217, - ExportSpecifier = 218, - MissingDeclaration = 219, - ExternalModuleReference = 220, - CaseClause = 221, - DefaultClause = 222, - HeritageClause = 223, - CatchClause = 224, - PropertyAssignment = 225, - ShorthandPropertyAssignment = 226, - EnumMember = 227, - SourceFile = 228, - JSDocTypeExpression = 229, - JSDocAllType = 230, - JSDocUnknownType = 231, - JSDocArrayType = 232, - JSDocUnionType = 233, - JSDocTupleType = 234, - JSDocNullableType = 235, - JSDocNonNullableType = 236, - JSDocRecordType = 237, - JSDocRecordMember = 238, - JSDocTypeReference = 239, - JSDocOptionalType = 240, - JSDocFunctionType = 241, - JSDocVariadicType = 242, - JSDocConstructorType = 243, - JSDocThisType = 244, - JSDocComment = 245, - JSDocTag = 246, - JSDocParameterTag = 247, - JSDocReturnTag = 248, - JSDocTypeTag = 249, - JSDocTemplateTag = 250, - SyntaxList = 251, - Count = 252, + IsKeyword = 117, + ModuleKeyword = 118, + NamespaceKeyword = 119, + RequireKeyword = 120, + NumberKeyword = 121, + SetKeyword = 122, + StringKeyword = 123, + SymbolKeyword = 124, + TypeKeyword = 125, + FromKeyword = 126, + OfKeyword = 127, + QualifiedName = 128, + ComputedPropertyName = 129, + TypeParameter = 130, + Parameter = 131, + Decorator = 132, + PropertySignature = 133, + PropertyDeclaration = 134, + MethodSignature = 135, + MethodDeclaration = 136, + Constructor = 137, + GetAccessor = 138, + SetAccessor = 139, + CallSignature = 140, + ConstructSignature = 141, + IndexSignature = 142, + TypePredicate = 143, + TypeReference = 144, + FunctionType = 145, + ConstructorType = 146, + TypeQuery = 147, + TypeLiteral = 148, + ArrayType = 149, + TupleType = 150, + UnionType = 151, + ParenthesizedType = 152, + ObjectBindingPattern = 153, + ArrayBindingPattern = 154, + BindingElement = 155, + ArrayLiteralExpression = 156, + ObjectLiteralExpression = 157, + PropertyAccessExpression = 158, + ElementAccessExpression = 159, + CallExpression = 160, + NewExpression = 161, + TaggedTemplateExpression = 162, + TypeAssertionExpression = 163, + ParenthesizedExpression = 164, + FunctionExpression = 165, + ArrowFunction = 166, + DeleteExpression = 167, + TypeOfExpression = 168, + VoidExpression = 169, + PrefixUnaryExpression = 170, + PostfixUnaryExpression = 171, + BinaryExpression = 172, + ConditionalExpression = 173, + TemplateExpression = 174, + YieldExpression = 175, + SpreadElementExpression = 176, + ClassExpression = 177, + OmittedExpression = 178, + ExpressionWithTypeArguments = 179, + TemplateSpan = 180, + SemicolonClassElement = 181, + Block = 182, + VariableStatement = 183, + EmptyStatement = 184, + ExpressionStatement = 185, + IfStatement = 186, + DoStatement = 187, + WhileStatement = 188, + ForStatement = 189, + ForInStatement = 190, + ForOfStatement = 191, + ContinueStatement = 192, + BreakStatement = 193, + ReturnStatement = 194, + WithStatement = 195, + SwitchStatement = 196, + LabeledStatement = 197, + ThrowStatement = 198, + TryStatement = 199, + DebuggerStatement = 200, + VariableDeclaration = 201, + VariableDeclarationList = 202, + FunctionDeclaration = 203, + ClassDeclaration = 204, + InterfaceDeclaration = 205, + TypeAliasDeclaration = 206, + EnumDeclaration = 207, + ModuleDeclaration = 208, + ModuleBlock = 209, + CaseBlock = 210, + ImportEqualsDeclaration = 211, + ImportDeclaration = 212, + ImportClause = 213, + NamespaceImport = 214, + NamedImports = 215, + ImportSpecifier = 216, + ExportAssignment = 217, + ExportDeclaration = 218, + NamedExports = 219, + ExportSpecifier = 220, + MissingDeclaration = 221, + ExternalModuleReference = 222, + CaseClause = 223, + DefaultClause = 224, + HeritageClause = 225, + CatchClause = 226, + PropertyAssignment = 227, + ShorthandPropertyAssignment = 228, + EnumMember = 229, + SourceFile = 230, + JSDocTypeExpression = 231, + JSDocAllType = 232, + JSDocUnknownType = 233, + JSDocArrayType = 234, + JSDocUnionType = 235, + JSDocTupleType = 236, + JSDocNullableType = 237, + JSDocNonNullableType = 238, + JSDocRecordType = 239, + JSDocRecordMember = 240, + JSDocTypeReference = 241, + JSDocOptionalType = 242, + JSDocFunctionType = 243, + JSDocVariadicType = 244, + JSDocConstructorType = 245, + JSDocThisType = 246, + JSDocComment = 247, + JSDocTag = 248, + JSDocParameterTag = 249, + JSDocReturnTag = 250, + JSDocTypeTag = 251, + JSDocTemplateTag = 252, + SyntaxList = 253, + Count = 254, FirstAssignment = 53, LastAssignment = 64, FirstReservedWord = 66, LastReservedWord = 101, FirstKeyword = 66, - LastKeyword = 126, + LastKeyword = 127, FirstFutureReservedWord = 102, LastFutureReservedWord = 110, - FirstTypeNode = 142, - LastTypeNode = 150, + FirstTypeNode = 144, + LastTypeNode = 152, FirstPunctuation = 14, LastPunctuation = 64, FirstToken = 0, - LastToken = 126, + LastToken = 127, FirstTriviaToken = 2, LastTriviaToken = 6, FirstLiteralToken = 7, @@ -297,7 +306,7 @@ declare module "typescript" { LastTemplateToken = 13, FirstBinaryOperator = 24, LastBinaryOperator = 64, - FirstNode = 127, + FirstNode = 128, } const enum NodeFlags { Export = 1, @@ -458,6 +467,10 @@ declare module "typescript" { typeName: EntityName; typeArguments?: NodeArray; } + interface TypePredicateNode extends TypeNode { + parameterName: Identifier; + type: TypeNode; + } interface TypeQueryNode extends TypeNode { exprName: EntityName; } @@ -592,7 +605,7 @@ declare module "typescript" { type: TypeNode; expression: UnaryExpression; } - interface Statement extends Node, ModuleElement { + interface Statement extends Node { _statementBrand: any; } interface Block extends Statement { @@ -672,9 +685,6 @@ declare module "typescript" { variableDeclaration: VariableDeclaration; block: Block; } - interface ModuleElement extends Node { - _moduleElementBrand: any; - } interface ClassLikeDeclaration extends Declaration { name?: Identifier; typeParameters?: NodeArray; @@ -700,6 +710,7 @@ declare module "typescript" { } interface TypeAliasDeclaration extends Declaration, Statement { name: Identifier; + typeParameters?: NodeArray; type: TypeNode; } interface EnumMember extends Declaration { @@ -710,21 +721,21 @@ declare module "typescript" { name: Identifier; members: NodeArray; } - interface ModuleDeclaration extends Declaration, ModuleElement { + interface ModuleDeclaration extends Declaration, Statement { name: Identifier | LiteralExpression; body: ModuleBlock | ModuleDeclaration; } - interface ModuleBlock extends Node, ModuleElement { - statements: NodeArray; + interface ModuleBlock extends Node, Statement { + statements: NodeArray; } - interface ImportEqualsDeclaration extends Declaration, ModuleElement { + interface ImportEqualsDeclaration extends Declaration, Statement { name: Identifier; moduleReference: EntityName | ExternalModuleReference; } interface ExternalModuleReference extends Node { expression?: Expression; } - interface ImportDeclaration extends ModuleElement { + interface ImportDeclaration extends Statement { importClause?: ImportClause; moduleSpecifier: Expression; } @@ -735,7 +746,7 @@ declare module "typescript" { interface NamespaceImport extends Declaration { name: Identifier; } - interface ExportDeclaration extends Declaration, ModuleElement { + interface ExportDeclaration extends Declaration, Statement { exportClause?: NamedExports; moduleSpecifier?: Expression; } @@ -750,7 +761,7 @@ declare module "typescript" { } type ImportSpecifier = ImportOrExportSpecifier; type ExportSpecifier = ImportOrExportSpecifier; - interface ExportAssignment extends Declaration, ModuleElement { + interface ExportAssignment extends Declaration, Statement { isExportEquals?: boolean; expression: Expression; } @@ -838,7 +849,7 @@ declare module "typescript" { isBracketed: boolean; } interface SourceFile extends Declaration { - statements: NodeArray; + statements: NodeArray; endOfFileToken: Node; fileName: string; text: string; @@ -846,8 +857,16 @@ declare module "typescript" { path: string; name: string; }[]; - amdModuleName: string; + moduleName: string; referencedFiles: FileReference[]; + /** + * lib.d.ts should have a reference comment like + * + * /// + * + * If any other file has this comment, it signals not to include lib.d.ts + * because this containing file is intended to act as a default library. + */ hasNoDefaultLib: boolean; languageVersion: ScriptTarget; } @@ -878,8 +897,9 @@ declare module "typescript" { * will be invoked when writing the JavaScript and declaration files. */ emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult; - getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; + getOptionsDiagnostics(): Diagnostic[]; getGlobalDiagnostics(): Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[]; /** @@ -998,6 +1018,11 @@ declare module "typescript" { WriteTypeParametersOrArguments = 1, UseOnlyExternalAliasing = 2, } + interface TypePredicate { + parameterName: string; + parameterIndex: number; + type: Type; + } const enum SymbolFlags { None = 0, FunctionScopedVariable = 1, @@ -1060,6 +1085,7 @@ declare module "typescript" { ExportHasLocal = 944, HasExports = 1952, HasMembers = 6240, + BlockScoped = 418, PropertyOrAccessor = 98308, Export = 7340032, } @@ -1111,9 +1137,8 @@ declare module "typescript" { typeParameters: TypeParameter[]; outerTypeParameters: TypeParameter[]; localTypeParameters: TypeParameter[]; - } - interface InterfaceTypeWithBaseTypes extends InterfaceType { - baseTypes: ObjectType[]; + resolvedBaseConstructorType?: Type; + resolvedBaseTypes: ObjectType[]; } interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; @@ -1146,6 +1171,7 @@ declare module "typescript" { declaration: SignatureDeclaration; typeParameters: TypeParameter[]; parameters: Symbol[]; + typePredicate?: TypePredicate; } const enum IndexKind { String = 0, @@ -1323,6 +1349,7 @@ declare module "typescript" { function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter; function isWhiteSpace(ch: number): boolean; function isLineBreak(ch: number): boolean; + function couldStartTrivia(text: string, pos: number): boolean; function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; @@ -1338,6 +1365,7 @@ declare module "typescript" { function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan; function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean; function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean; + function decodedTextSpanIntersectsWith(start1: number, length1: number, start2: number, length2: number): boolean; function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean; function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan; function createTextSpan(start: number, length: number): TextSpan; @@ -1490,6 +1518,7 @@ declare module "typescript" { log?(s: string): void; trace?(s: string): void; error?(s: string): void; + useCaseSensitiveFileNames?(): boolean; } interface LanguageService { cleanupSemanticCache(): void; @@ -1948,11 +1977,11 @@ declare module "typescript" { isCancellationRequested(): boolean; throwIfCancellationRequested(): void; } - function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string; + function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; - function createDocumentRegistry(): DocumentRegistry; + function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry; function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; function createClassifier(): Classifier; diff --git a/bin/typescript.js b/bin/typescript.js index 138a38642c9..2e3a784b298 100644 --- a/bin/typescript.js +++ b/bin/typescript.js @@ -144,176 +144,178 @@ var ts; SyntaxKind[SyntaxKind["ConstructorKeyword"] = 114] = "ConstructorKeyword"; SyntaxKind[SyntaxKind["DeclareKeyword"] = 115] = "DeclareKeyword"; SyntaxKind[SyntaxKind["GetKeyword"] = 116] = "GetKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 117] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 118] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 119] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 120] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 121] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 122] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 123] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 124] = "TypeKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 125] = "FromKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 126] = "OfKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 117] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 118] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 119] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 120] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 121] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 122] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 123] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 124] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 125] = "TypeKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 126] = "FromKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 127] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 127] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 128] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 128] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 129] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 129] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 130] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 131] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 130] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 131] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 132] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 132] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 133] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 134] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 135] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 136] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 137] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 138] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 139] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 140] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 141] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 133] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 134] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 135] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 136] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 137] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 138] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 139] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 140] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 141] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 142] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypeReference"] = 142] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 143] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 144] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 145] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 146] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 147] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 148] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 149] = "UnionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 150] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 143] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 144] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 145] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 146] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 147] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 148] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 149] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 150] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 151] = "UnionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 152] = "ParenthesizedType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 151] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 152] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 153] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 153] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 154] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 155] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 154] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 155] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 156] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 157] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 158] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 159] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 160] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 161] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 162] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 163] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 164] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 165] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 166] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 167] = "VoidExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 168] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 169] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 170] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 171] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 172] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 173] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 174] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 175] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 176] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 177] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 156] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 157] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 158] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 159] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 160] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 161] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 162] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 163] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 164] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 165] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 166] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 167] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 168] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 169] = "VoidExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 170] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 171] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 172] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 173] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 174] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 175] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 176] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 177] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 178] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 179] = "ExpressionWithTypeArguments"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 178] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 179] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 180] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 181] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 180] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 181] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 182] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 183] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 184] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 185] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 186] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 187] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 188] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 189] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 190] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 191] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 192] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 193] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 194] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 195] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 196] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 197] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 198] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 199] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 200] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 201] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 202] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 203] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 204] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 205] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 206] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 207] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 208] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 209] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 210] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 211] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 212] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 213] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 214] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 215] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 216] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 217] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 218] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 219] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 182] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 183] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 184] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 185] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 186] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 187] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 188] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 189] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 190] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 191] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 192] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 193] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 194] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 195] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 196] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 197] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 198] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 199] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 200] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 201] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 202] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 203] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 204] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 205] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 206] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 207] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 208] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 209] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 210] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 211] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 212] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 213] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 214] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 215] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 216] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 217] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 218] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 219] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 220] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 221] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 220] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 222] = "ExternalModuleReference"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 221] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 222] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 223] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 224] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 223] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 224] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 225] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 226] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 225] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 226] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 227] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 228] = "ShorthandPropertyAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 227] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 229] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 228] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 230] = "SourceFile"; // JSDoc nodes. - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 229] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 231] = "JSDocTypeExpression"; // The * type. - SyntaxKind[SyntaxKind["JSDocAllType"] = 230] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 232] = "JSDocAllType"; // The ? type. - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 231] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 232] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 233] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 234] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 235] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 236] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 237] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 238] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 239] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 240] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 241] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 242] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 243] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 244] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 245] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 246] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 247] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 248] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 249] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 250] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 233] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 234] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 235] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 236] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 237] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 238] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 239] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 240] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 241] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 242] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 243] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 244] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 245] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 246] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 247] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 248] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 249] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 250] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 251] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 252] = "JSDocTemplateTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 251] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 253] = "SyntaxList"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 252] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 254] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 53] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 64] = "LastAssignment"; SyntaxKind[SyntaxKind["FirstReservedWord"] = 66] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 101] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 66] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 126] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 127] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 102] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 110] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 142] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 150] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 144] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 152] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 14] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 64] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 126] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 127] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 6] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 7] = "FirstLiteralToken"; @@ -322,7 +324,7 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 13] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 24] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 64] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 127] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstNode"] = 128] = "FirstNode"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { @@ -349,9 +351,6 @@ var ts; /* @internal */ (function (ParserContextFlags) { ParserContextFlags[ParserContextFlags["None"] = 0] = "None"; - // Set if this node was parsed in strict mode. Used for grammar error checks, as well as - // checking if the node can be reused in incremental settings. - ParserContextFlags[ParserContextFlags["StrictMode"] = 1] = "StrictMode"; // If this node was parsed in a context where 'in-expressions' are not allowed. ParserContextFlags[ParserContextFlags["DisallowIn"] = 2] = "DisallowIn"; // If this node was parsed in the 'yield' context created when parsing a generator. @@ -368,7 +367,7 @@ var ts; // its type can be specified usign a JSDoc comment. ParserContextFlags[ParserContextFlags["JavaScriptFile"] = 64] = "JavaScriptFile"; // Context flags set directly by the parser. - ParserContextFlags[ParserContextFlags["ParserGeneratedFlags"] = 63] = "ParserGeneratedFlags"; + ParserContextFlags[ParserContextFlags["ParserGeneratedFlags"] = 62] = "ParserGeneratedFlags"; // Context flags computed by aggregating child flags upwards. // Used during incremental parsing to determine if this node or any of its children had an // error. Computed only once and then cached. @@ -494,8 +493,13 @@ var ts; SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; SymbolFlags[SymbolFlags["HasExports"] = 1952] = "HasExports"; SymbolFlags[SymbolFlags["HasMembers"] = 6240] = "HasMembers"; + SymbolFlags[SymbolFlags["BlockScoped"] = 418] = "BlockScoped"; SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; SymbolFlags[SymbolFlags["Export"] = 7340032] = "Export"; + /* @internal */ + // The set of things we consider semantically classifiable. Used to speed up the LS during + // classification. + SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; })(ts.SymbolFlags || (ts.SymbolFlags = {})); var SymbolFlags = ts.SymbolFlags; /* @internal */ @@ -735,6 +739,36 @@ var ts; Ternary[Ternary["True"] = -1] = "True"; })(ts.Ternary || (ts.Ternary = {})); var Ternary = ts.Ternary; + function createFileMap(getCanonicalFileName) { + var files = {}; + return { + get: get, + set: set, + contains: contains, + remove: remove, + forEachValue: forEachValueInMap + }; + function set(fileName, value) { + files[normalizeKey(fileName)] = value; + } + function get(fileName) { + return files[normalizeKey(fileName)]; + } + function contains(fileName) { + return hasProperty(files, normalizeKey(fileName)); + } + function remove(fileName) { + var key = normalizeKey(fileName); + delete files[key]; + } + function forEachValueInMap(f) { + forEachValue(files, f); + } + function normalizeKey(key) { + return getCanonicalFileName(normalizeSlashes(key)); + } + } + ts.createFileMap = createFileMap; (function (Comparison) { Comparison[Comparison["LessThan"] = -1] = "LessThan"; Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; @@ -1232,7 +1266,7 @@ var ts; function getNormalizedPathComponents(path, currentDirectory) { path = normalizeSlashes(path); var rootLength = getRootLength(path); - if (rootLength == 0) { + if (rootLength === 0) { // If the path is not rooted it is relative to current directory path = combinePaths(normalizeSlashes(currentDirectory), path); rootLength = getRootLength(path); @@ -1896,14 +1930,26 @@ var ts; A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, - Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" }, - Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, + Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Modules are automatically in strict mode." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators are only available when targeting ECMAScript 6 or higher." }, Generators_are_not_allowed_in_an_ambient_context: { code: 1221, category: ts.DiagnosticCategory.Error, key: "Generators are not allowed in an ambient context." }, An_overload_signature_cannot_be_declared_as_a_generator: { code: 1222, category: ts.DiagnosticCategory.Error, key: "An overload signature cannot be declared as a generator." }, _0_tag_already_specified: { code: 1223, category: ts.DiagnosticCategory.Error, key: "'{0}' tag already specified." }, + Signature_0_must_have_a_type_predicate: { code: 1224, category: ts.DiagnosticCategory.Error, key: "Signature '{0}' must have a type predicate." }, + Cannot_find_parameter_0: { code: 1225, category: ts.DiagnosticCategory.Error, key: "Cannot find parameter '{0}'." }, + Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: ts.DiagnosticCategory.Error, key: "Type predicate '{0}' is not assignable to '{1}'." }, + Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' is not in the same position as parameter '{1}'." }, + A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: ts.DiagnosticCategory.Error, key: "A type predicate is only allowed in return type position for functions and methods." }, + A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: ts.DiagnosticCategory.Error, key: "A type predicate cannot reference a rest parameter." }, + A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: ts.DiagnosticCategory.Error, key: "A type predicate cannot reference element '{0}' in a binding pattern." }, + An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: ts.DiagnosticCategory.Error, key: "An export assignment can only be used in a module." }, + An_import_declaration_can_only_be_used_in_a_namespace_or_module: { code: 1232, category: ts.DiagnosticCategory.Error, key: "An import declaration can only be used in a namespace or module." }, + An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: ts.DiagnosticCategory.Error, key: "An export declaration can only be used in a module." }, + An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: ts.DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." }, + A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: ts.DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -2097,6 +2143,11 @@ var ts; Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, No_best_common_type_exists_among_yield_expressions: { code: 2504, category: ts.DiagnosticCategory.Error, key: "No best common type exists among yield expressions." }, A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: ts.DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." }, + _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: ts.DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own base expression." }, + Type_0_is_not_a_constructor_function_type: { code: 2507, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not a constructor function type." }, + No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: ts.DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." }, + Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: ts.DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." }, + Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: ts.DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -2306,7 +2357,7 @@ var ts; "false": 80 /* FalseKeyword */, "finally": 81 /* FinallyKeyword */, "for": 82 /* ForKeyword */, - "from": 125 /* FromKeyword */, + "from": 126 /* FromKeyword */, "function": 83 /* FunctionKeyword */, "get": 116 /* GetKeyword */, "if": 84 /* IfKeyword */, @@ -2315,36 +2366,37 @@ var ts; "in": 86 /* InKeyword */, "instanceof": 87 /* InstanceOfKeyword */, "interface": 103 /* InterfaceKeyword */, + "is": 117 /* IsKeyword */, "let": 104 /* LetKeyword */, - "module": 117 /* ModuleKeyword */, - "namespace": 118 /* NamespaceKeyword */, + "module": 118 /* ModuleKeyword */, + "namespace": 119 /* NamespaceKeyword */, "new": 88 /* NewKeyword */, "null": 89 /* NullKeyword */, - "number": 120 /* NumberKeyword */, + "number": 121 /* NumberKeyword */, "package": 105 /* PackageKeyword */, "private": 106 /* PrivateKeyword */, "protected": 107 /* ProtectedKeyword */, "public": 108 /* PublicKeyword */, - "require": 119 /* RequireKeyword */, + "require": 120 /* RequireKeyword */, "return": 90 /* ReturnKeyword */, - "set": 121 /* SetKeyword */, + "set": 122 /* SetKeyword */, "static": 109 /* StaticKeyword */, - "string": 122 /* StringKeyword */, + "string": 123 /* StringKeyword */, "super": 91 /* SuperKeyword */, "switch": 92 /* SwitchKeyword */, - "symbol": 123 /* SymbolKeyword */, + "symbol": 124 /* SymbolKeyword */, "this": 93 /* ThisKeyword */, "throw": 94 /* ThrowKeyword */, "true": 95 /* TrueKeyword */, "try": 96 /* TryKeyword */, - "type": 124 /* TypeKeyword */, + "type": 125 /* TypeKeyword */, "typeof": 97 /* TypeOfKeyword */, "var": 98 /* VarKeyword */, "void": 99 /* VoidKeyword */, "while": 100 /* WhileKeyword */, "with": 101 /* WithKeyword */, "yield": 110 /* YieldKeyword */, - "of": 126 /* OfKeyword */, + "of": 127 /* OfKeyword */, "{": 14 /* OpenBraceToken */, "}": 15 /* CloseBraceToken */, "(": 16 /* OpenParenToken */, @@ -2604,8 +2656,31 @@ var ts; return ch >= 48 /* _0 */ && ch <= 55 /* _7 */; } ts.isOctalDigit = isOctalDigit; + function couldStartTrivia(text, pos) { + // Keep in sync with skipTrivia + var ch = text.charCodeAt(pos); + switch (ch) { + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 32 /* space */: + case 47 /* slash */: + // starts of normal trivia + case 60 /* lessThan */: + case 61 /* equals */: + case 62 /* greaterThan */: + // Starts of conflict marker trivia + return true; + default: + return ch > 127 /* maxAsciiCharacter */; + } + } + ts.couldStartTrivia = couldStartTrivia; /* @internal */ function skipTrivia(text, pos, stopAfterLineBreak) { + // Keep in sync with couldStartTrivia while (true) { var ch = text.charCodeAt(pos); switch (ch) { @@ -3109,7 +3184,7 @@ var ts; error(ts.Diagnostics.Unexpected_end_of_text); isInvalidExtendedEscape = true; } - else if (text.charCodeAt(pos) == 125 /* closeBrace */) { + else if (text.charCodeAt(pos) === 125 /* closeBrace */) { // Only swallow the following character up if it's a '}'. pos++; } @@ -3666,16 +3741,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 203 /* InterfaceDeclaration */ || node.kind === 204 /* TypeAliasDeclaration */) { + if (node.kind === 205 /* InterfaceDeclaration */ || node.kind === 206 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 210 /* ImportDeclaration */ || node.kind === 209 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { + else if ((node.kind === 212 /* ImportDeclaration */ || node.kind === 211 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 207 /* ModuleBlock */) { + else if (node.kind === 209 /* ModuleBlock */) { var state = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -3694,7 +3769,7 @@ var ts; }); return state; } - else if (node.kind === 206 /* ModuleDeclaration */) { + else if (node.kind === 208 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -3734,11 +3809,17 @@ var ts; var container; var blockScopeContainer; var lastContainer; + // If this file is an external module, then it is automatically in strict-mode according to + // ES6. If it is not an external module, then we'll determine if it is in strict mode or + // not depending on if we see "use strict" in certain places (or if we hit a class/namespace). + var inStrictMode = !!file.externalModuleIndicator; var symbolCount = 0; var Symbol = ts.objectAllocator.getSymbolConstructor(); + var classifiableNames = {}; if (!file.locals) { bind(file); file.symbolCount = symbolCount; + file.classifiableNames = classifiableNames; } return; function createSymbol(flags, name) { @@ -3766,10 +3847,10 @@ var ts; // unless it is a well known Symbol. function getDeclarationName(node) { if (node.name) { - if (node.kind === 206 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */) { + if (node.kind === 208 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */) { return '"' + node.name.text + '"'; } - if (node.name.kind === 128 /* ComputedPropertyName */) { + if (node.name.kind === 129 /* ComputedPropertyName */) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -3777,22 +3858,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 136 /* Constructor */: + case 137 /* Constructor */: return "__constructor"; - case 143 /* FunctionType */: - case 139 /* CallSignature */: + case 145 /* FunctionType */: + case 140 /* CallSignature */: return "__call"; - case 144 /* ConstructorType */: - case 140 /* ConstructSignature */: + case 146 /* ConstructorType */: + case 141 /* ConstructSignature */: return "__new"; - case 141 /* IndexSignature */: + case 142 /* IndexSignature */: return "__index"; - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: return "__export"; - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 201 /* FunctionDeclaration */: - case 202 /* ClassDeclaration */: + case 203 /* FunctionDeclaration */: + case 204 /* ClassDeclaration */: return node.flags & 256 /* Default */ ? "default" : undefined; } } @@ -3826,6 +3907,9 @@ var ts; symbol = ts.hasProperty(symbolTable, name) ? symbolTable[name] : (symbolTable[name] = createSymbol(0 /* None */, name)); + if (name && (includes & 788448 /* Classifiable */)) { + classifiableNames[name] = name; + } if (symbol.flags & excludes) { if (node.name) { node.name.parent = node; @@ -3852,7 +3936,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 218 /* ExportSpecifier */ || (node.kind === 209 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 220 /* ExportSpecifier */ || (node.kind === 211 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -3933,36 +4017,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 175 /* ClassExpression */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 146 /* TypeLiteral */: - case 155 /* ObjectLiteralExpression */: + case 177 /* ClassExpression */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 148 /* TypeLiteral */: + case 157 /* ObjectLiteralExpression */: return 1 /* IsContainer */; - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 201 /* FunctionDeclaration */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - case 206 /* ModuleDeclaration */: - case 228 /* SourceFile */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 203 /* FunctionDeclaration */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 208 /* ModuleDeclaration */: + case 230 /* SourceFile */: + case 206 /* TypeAliasDeclaration */: return 5 /* IsContainerWithLocals */; - case 224 /* CatchClause */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 208 /* CaseBlock */: + case 226 /* CatchClause */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 210 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 180 /* Block */: + case 182 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Othewise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -3995,45 +4080,47 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - // Modules, source files, and classes need specialized handling for how their + // Modules, source files, and classes need specialized handling for how their // members are declared (for example, a member of a class will go into a specific - // symbol table depending on if it is static or not). As such, we defer to - // specialized handlers to take care of declaring these child members. - case 206 /* ModuleDeclaration */: + // symbol table depending on if it is static or not). We defer to specialized + // handlers to take care of declaring these child members. + case 208 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 228 /* SourceFile */: + case 230 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 175 /* ClassExpression */: - case 202 /* ClassDeclaration */: + case 177 /* ClassExpression */: + case 204 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 146 /* TypeLiteral */: - case 155 /* ObjectLiteralExpression */: - case 203 /* InterfaceDeclaration */: + case 148 /* TypeLiteral */: + case 157 /* ObjectLiteralExpression */: + case 205 /* InterfaceDeclaration */: // Interface/Object-types always have their children added to the 'members' of - // their container. They are only accessible through an instance of their - // container, and are never in scope otherwise (even inside the body of the - // object / type / interface declaring them). + // their container. They are only accessible through an instance of their + // container, and are never in scope otherwise (even inside the body of the + // object / type / interface declaring them). An exception is type parameters, + // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 206 /* TypeAliasDeclaration */: // All the children of these container types are never visible through another - // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, - // they're only accessed 'lexically' (i.e. from code that exists underneath + // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, + // they're only accessed 'lexically' (i.e. from code that exists underneath // their container in the tree. To accomplish this, we simply add their declared - // symbol to the 'locals' of the container. These symbols can then be found as + // symbol to the 'locals' of the container. These symbols can then be found as // the type checker walks up the containers, checking them for matching names. return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } @@ -4058,11 +4145,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 228 /* SourceFile */ ? node : node.body; - if (body.kind === 228 /* SourceFile */ || body.kind === 207 /* ModuleBlock */) { + var body = node.kind === 230 /* SourceFile */ ? node : node.body; + if (body.kind === 230 /* SourceFile */ || body.kind === 209 /* ModuleBlock */) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 216 /* ExportDeclaration */ || stat.kind === 215 /* ExportAssignment */) { + if (stat.kind === 218 /* ExportDeclaration */ || stat.kind === 217 /* ExportAssignment */) { return true; } } @@ -4117,16 +4204,54 @@ var ts; typeLiteralSymbol.members = (_a = {}, _a[symbol.name] = symbol, _a); var _a; } + function bindObjectLiteralExpression(node) { + var ElementKind; + (function (ElementKind) { + ElementKind[ElementKind["Property"] = 1] = "Property"; + ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; + })(ElementKind || (ElementKind = {})); + if (inStrictMode) { + var seen = {}; + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var prop = _a[_i]; + if (prop.name.kind !== 65 /* Identifier */) { + continue; + } + var identifier = prop.name; + // ECMA-262 11.1.5 Object Initialiser + // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true + // a.This production is contained in strict code and IsDataDescriptor(previous) is true and + // IsDataDescriptor(propId.descriptor) is true. + // b.IsDataDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true. + // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. + // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true + // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields + var currentKind = prop.kind === 227 /* PropertyAssignment */ || prop.kind === 228 /* ShorthandPropertyAssignment */ || prop.kind === 136 /* MethodDeclaration */ + ? 1 /* Property */ + : 2 /* Accessor */; + var existingKind = seen[identifier.text]; + if (!existingKind) { + seen[identifier.text] = currentKind; + continue; + } + if (currentKind === 1 /* Property */ && existingKind === 1 /* Property */) { + var span = ts.getErrorSpanForNode(file, identifier); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode)); + } + } + } + return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object"); + } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); addDeclarationToSymbol(symbol, node, symbolFlags); } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 228 /* SourceFile */: + case 230 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -4143,11 +4268,126 @@ var ts; function bindBlockScopedVariableDeclaration(node) { bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */); } + // The binder visits every node in the syntax tree so it is a convenient place to perform a single localized + // check for reserved words used as identifiers in strict mode code. + function checkStrictModeIdentifier(node) { + if (inStrictMode && + node.originalKeywordKind >= 102 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 110 /* LastFutureReservedWord */ && + !ts.isIdentifierName(node)) { + // Report error only if there are no parse errors in file + if (!file.parseDiagnostics.length) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); + } + } + } + function getStrictModeIdentifierMessage(node) { + // Provide specialized messages to help the user understand why we think they're in + // strict mode. + if (ts.getAncestor(node, 204 /* ClassDeclaration */) || ts.getAncestor(node, 177 /* ClassExpression */)) { + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode; + } + if (file.externalModuleIndicator) { + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode; + } + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode; + } + function checkStrictModeBinaryExpression(node) { + if (inStrictMode && ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) { + // ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an + // Assignment operator(11.13) or of a PostfixExpression(11.3) + checkStrictModeEvalOrArguments(node, node.left); + } + } + function checkStrictModeCatchClause(node) { + // It is a SyntaxError if a TryStatement with a Catch occurs within strict code and the Identifier of the + // Catch production is eval or arguments + if (inStrictMode && node.variableDeclaration) { + checkStrictModeEvalOrArguments(node, node.variableDeclaration.name); + } + } + function checkStrictModeDeleteExpression(node) { + // Grammar checking + if (inStrictMode && node.expression.kind === 65 /* Identifier */) { + // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its + // UnaryExpression is a direct reference to a variable, function argument, or function name + var span = ts.getErrorSpanForNode(file, node.expression); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); + } + } + function isEvalOrArgumentsIdentifier(node) { + return node.kind === 65 /* Identifier */ && + (node.text === "eval" || node.text === "arguments"); + } + function checkStrictModeEvalOrArguments(contextNode, name) { + if (name && name.kind === 65 /* Identifier */) { + var identifier = name; + if (isEvalOrArgumentsIdentifier(identifier)) { + // We check first if the name is inside class declaration or class expression; if so give explicit message + // otherwise report generic error message. + var span = ts.getErrorSpanForNode(file, name); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, getStrictModeEvalOrArgumentsMessage(contextNode), identifier.text)); + } + } + } + function getStrictModeEvalOrArgumentsMessage(node) { + // Provide specialized messages to help the user understand why we think they're in + // strict mode. + if (ts.getAncestor(node, 204 /* ClassDeclaration */) || ts.getAncestor(node, 177 /* ClassExpression */)) { + return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode; + } + if (file.externalModuleIndicator) { + return ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode; + } + return ts.Diagnostics.Invalid_use_of_0_in_strict_mode; + } + function checkStrictModeFunctionName(node) { + if (inStrictMode) { + // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a strict mode FunctionDeclaration or FunctionExpression (13.1)) + checkStrictModeEvalOrArguments(node, node.name); + } + } + function checkStrictModeNumericLiteral(node) { + if (inStrictMode && node.flags & 16384 /* OctalLiteral */) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); + } + } + function checkStrictModePostfixUnaryExpression(node) { + // Grammar checking + // The identifier eval or arguments may not appear as the LeftHandSideExpression of an + // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression + // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator. + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.operand); + } + } + function checkStrictModePrefixUnaryExpression(node) { + // Grammar checking + if (inStrictMode) { + if (node.operator === 38 /* PlusPlusToken */ || node.operator === 39 /* MinusMinusToken */) { + checkStrictModeEvalOrArguments(node, node.operand); + } + } + } + function checkStrictModeWithStatement(node) { + // Grammar checking for withStatement + if (inStrictMode) { + grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); + } + } + function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + var span = ts.getSpanOfTokenAtPosition(file, node.pos); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); + } function getDestructuringParameterName(node) { return "__" + ts.indexOf(node.parent.parameters, node); } function bind(node) { node.parent = parent; + var savedInStrictMode = inStrictMode; + if (!savedInStrictMode) { + updateStrictMode(node); + } // First we bind declaration nodes to a symbol if possible. We'll both create a symbol // and then potentially add the symbol to an appropriate symbol table. Possible // destination symbol tables are: @@ -4164,76 +4404,132 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. bindChildren(node); + inStrictMode = savedInStrictMode; + } + function updateStrictMode(node) { + switch (node.kind) { + case 230 /* SourceFile */: + case 209 /* ModuleBlock */: + updateStrictModeStatementList(node.statements); + return; + case 182 /* Block */: + if (ts.isFunctionLike(node.parent)) { + updateStrictModeStatementList(node.statements); + } + return; + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: + // All classes are automatically in strict mode in ES6. + inStrictMode = true; + return; + } + } + function updateStrictModeStatementList(statements) { + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (!ts.isPrologueDirective(statement)) { + return; + } + if (isUseStrictPrologueDirective(statement)) { + inStrictMode = true; + return; + } + } + } + /// Should be called only on prologue directives (isPrologueDirective(node) should be true) + function isUseStrictPrologueDirective(node) { + var nodeText = ts.getTextOfNodeFromSourceText(file.text, node.expression); + // Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the + // string to contain unicode escapes (as per ES5). + return nodeText === '"use strict"' || nodeText === "'use strict'"; } function bindWorker(node) { switch (node.kind) { - case 129 /* TypeParameter */: + case 65 /* Identifier */: + return checkStrictModeIdentifier(node); + case 172 /* BinaryExpression */: + return checkStrictModeBinaryExpression(node); + case 226 /* CatchClause */: + return checkStrictModeCatchClause(node); + case 167 /* DeleteExpression */: + return checkStrictModeDeleteExpression(node); + case 7 /* NumericLiteral */: + return checkStrictModeNumericLiteral(node); + case 171 /* PostfixUnaryExpression */: + return checkStrictModePostfixUnaryExpression(node); + case 170 /* PrefixUnaryExpression */: + return checkStrictModePrefixUnaryExpression(node); + case 195 /* WithStatement */: + return checkStrictModeWithStatement(node); + case 130 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */); - case 130 /* Parameter */: + case 131 /* Parameter */: return bindParameter(node); - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */); - case 225 /* PropertyAssignment */: - case 226 /* ShorthandPropertyAssignment */: + case 227 /* PropertyAssignment */: + case 228 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); - case 227 /* EnumMember */: + case 229 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: + checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */); - case 136 /* Constructor */: + case 137 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, 0 /* None */); - case 137 /* GetAccessor */: + case 138 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 138 /* SetAccessor */: + case 139 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 146 /* TypeLiteral */: + case 148 /* TypeLiteral */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 155 /* ObjectLiteralExpression */: - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object"); - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 157 /* ObjectLiteralExpression */: + return bindObjectLiteralExpression(node); + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + checkStrictModeFunctionName(node); return bindAnonymousDeclaration(node, 16 /* Function */, "__function"); - case 175 /* ClassExpression */: - case 202 /* ClassDeclaration */: + case 177 /* ClassExpression */: + case 204 /* ClassDeclaration */: return bindClassLikeDeclaration(node); - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792992 /* InterfaceExcludes */); - case 204 /* TypeAliasDeclaration */: + case 206 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return bindModuleDeclaration(node); - case 209 /* ImportEqualsDeclaration */: - case 212 /* NamespaceImport */: - case 214 /* ImportSpecifier */: - case 218 /* ExportSpecifier */: + case 211 /* ImportEqualsDeclaration */: + case 214 /* NamespaceImport */: + case 216 /* ImportSpecifier */: + case 220 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 211 /* ImportClause */: + case 213 /* ImportClause */: return bindImportClause(node); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: return bindExportDeclaration(node); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return bindExportAssignment(node); - case 228 /* SourceFile */: + case 230 /* SourceFile */: return bindSourceFileIfExternalModule(); } } @@ -4244,7 +4540,11 @@ var ts; } } function bindExportAssignment(node) { - if (node.expression.kind === 65 /* Identifier */) { + if (!container.symbol || !container.symbol.exports) { + // Export assignment in some sort of block construct + bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); + } + else if (node.expression.kind === 65 /* Identifier */) { // An export default clause with an identifier exports all meanings of that identifier declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* Alias */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); } @@ -4254,7 +4554,11 @@ var ts; } } function bindExportDeclaration(node) { - if (!node.exportClause) { + if (!container.symbol || !container.symbol.exports) { + // Export * in some sort of block construct + bindAnonymousDeclaration(node, 1073741824 /* ExportStar */, getDeclarationName(node)); + } + else if (!node.exportClause) { // All export * declarations are collected in an __export symbol declareSymbol(container.symbol.exports, container.symbol, node, 1073741824 /* ExportStar */, 0 /* None */); } @@ -4265,7 +4569,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899583 /* ClassExcludes */); } else { @@ -4297,6 +4601,9 @@ var ts; : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); } function bindVariableDeclarationOrBindingElement(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.name); + } if (!ts.isBindingPattern(node.name)) { if (ts.isBlockOrCatchScoped(node)) { bindBlockScopedVariableDeclaration(node); @@ -4319,6 +4626,11 @@ var ts; } } function bindParameter(node) { + if (inStrictMode) { + // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a + // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) + checkStrictModeEvalOrArguments(node, node.name); + } if (ts.isBindingPattern(node.name)) { bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, getDestructuringParameterName(node)); } @@ -4328,8 +4640,8 @@ var ts; // If this is a property-parameter, then also declare the property symbol into the // containing class. if (node.flags & 112 /* AccessibilityModifier */ && - node.parent.kind === 136 /* Constructor */ && - (node.parent.parent.kind === 202 /* ClassDeclaration */ || node.parent.parent.kind === 175 /* ClassExpression */)) { + node.parent.kind === 137 /* Constructor */ && + (node.parent.parent.kind === 204 /* ClassDeclaration */ || node.parent.parent.kind === 177 /* ClassExpression */)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); } @@ -4359,7 +4671,7 @@ var ts; // Pool writers to avoid needing to allocate them for every symbol we write. var stringWriters = []; function getSingleLineStringWriter() { - if (stringWriters.length == 0) { + if (stringWriters.length === 0) { var str = ""; var writeText = function (text) { return str += text; }; return { @@ -4416,7 +4728,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 228 /* SourceFile */) { + while (node && node.kind !== 230 /* SourceFile */) { node = node.parent; } return node; @@ -4526,15 +4838,15 @@ var ts; return current; } switch (current.kind) { - case 228 /* SourceFile */: - case 208 /* CaseBlock */: - case 224 /* CatchClause */: - case 206 /* ModuleDeclaration */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: + case 230 /* SourceFile */: + case 210 /* CaseBlock */: + case 226 /* CatchClause */: + case 208 /* ModuleDeclaration */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: return current; - case 180 /* Block */: + case 182 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block if (!isFunctionLike(current.parent)) { @@ -4547,9 +4859,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 199 /* VariableDeclaration */ && + declaration.kind === 201 /* VariableDeclaration */ && declaration.parent && - declaration.parent.kind === 224 /* CatchClause */; + declaration.parent.kind === 226 /* CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; // Return display name of an identifier @@ -4588,7 +4900,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 228 /* SourceFile */: + case 230 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -4597,16 +4909,16 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: - case 202 /* ClassDeclaration */: - case 175 /* ClassExpression */: - case 203 /* InterfaceDeclaration */: - case 206 /* ModuleDeclaration */: - case 205 /* EnumDeclaration */: - case 227 /* EnumMember */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: + case 205 /* InterfaceDeclaration */: + case 208 /* ModuleDeclaration */: + case 207 /* EnumDeclaration */: + case 229 /* EnumMember */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: errorNode = node.name; break; } @@ -4630,11 +4942,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 205 /* EnumDeclaration */ && isConst(node); + return node.kind === 207 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 153 /* BindingElement */ || isBindingPattern(node))) { + while (node && (node.kind === 155 /* BindingElement */ || isBindingPattern(node))) { node = node.parent; } return node; @@ -4649,14 +4961,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 199 /* VariableDeclaration */) { + if (node.kind === 201 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 200 /* VariableDeclarationList */) { + if (node && node.kind === 202 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 181 /* VariableStatement */) { + if (node && node.kind === 183 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -4671,12 +4983,12 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 183 /* ExpressionStatement */ && node.expression.kind === 8 /* StringLiteral */; + return node.kind === 185 /* ExpressionStatement */ && node.expression.kind === 8 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { // If parameter/type parameter, the prev token trailing comments are part of this node too - if (node.kind === 130 /* Parameter */ || node.kind === 129 /* TypeParameter */) { + if (node.kind === 131 /* Parameter */ || node.kind === 130 /* TypeParameter */) { // e.g. (/** blah */ a, /** blah */ b); // e.g.: ( // /** blah */ a, @@ -4700,40 +5012,40 @@ var ts; ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (142 /* FirstTypeNode */ <= node.kind && node.kind <= 150 /* LastTypeNode */) { + if (144 /* FirstTypeNode */ <= node.kind && node.kind <= 152 /* LastTypeNode */) { return true; } switch (node.kind) { case 112 /* AnyKeyword */: - case 120 /* NumberKeyword */: - case 122 /* StringKeyword */: + case 121 /* NumberKeyword */: + case 123 /* StringKeyword */: case 113 /* BooleanKeyword */: - case 123 /* SymbolKeyword */: + case 124 /* SymbolKeyword */: return true; case 99 /* VoidKeyword */: - return node.parent.kind !== 167 /* VoidExpression */; + return node.parent.kind !== 169 /* VoidExpression */; case 8 /* StringLiteral */: // Specialized signatures can have string literals as their parameters' type names - return node.parent.kind === 130 /* Parameter */; - case 177 /* ExpressionWithTypeArguments */: - return true; + return node.parent.kind === 131 /* Parameter */; + case 179 /* ExpressionWithTypeArguments */: + return !isExpressionWithTypeArgumentsInClassExtendsClause(node); // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 65 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 127 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 128 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 156 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 158 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // fall through - case 127 /* QualifiedName */: - case 156 /* PropertyAccessExpression */: + case 128 /* QualifiedName */: + case 158 /* PropertyAccessExpression */: // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 65 /* Identifier */ || node.kind === 127 /* QualifiedName */ || node.kind === 156 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + ts.Debug.assert(node.kind === 65 /* Identifier */ || node.kind === 128 /* QualifiedName */ || node.kind === 158 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_1 = node.parent; - if (parent_1.kind === 145 /* TypeQuery */) { + if (parent_1.kind === 147 /* TypeQuery */) { return false; } // Do not recursively call isTypeNode on the parent. In the example: @@ -4742,38 +5054,38 @@ var ts; // // Calling isTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (142 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 150 /* LastTypeNode */) { + if (144 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 152 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 177 /* ExpressionWithTypeArguments */: - return true; - case 129 /* TypeParameter */: + case 179 /* ExpressionWithTypeArguments */: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); + case 130 /* TypeParameter */: return node === parent_1.constraint; - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 130 /* Parameter */: - case 199 /* VariableDeclaration */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 131 /* Parameter */: + case 201 /* VariableDeclaration */: return node === parent_1.type; - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - case 136 /* Constructor */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 137 /* Constructor */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: return node === parent_1.type; - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: return node === parent_1.type; - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: return node === parent_1.type; - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 160 /* TaggedTemplateExpression */: + case 162 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -4787,23 +5099,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 192 /* ReturnStatement */: + case 194 /* ReturnStatement */: return visitor(node); - case 208 /* CaseBlock */: - case 180 /* Block */: - case 184 /* IfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 193 /* WithStatement */: - case 194 /* SwitchStatement */: - case 221 /* CaseClause */: - case 222 /* DefaultClause */: - case 195 /* LabeledStatement */: - case 197 /* TryStatement */: - case 224 /* CatchClause */: + case 210 /* CaseBlock */: + case 182 /* Block */: + case 186 /* IfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 195 /* WithStatement */: + case 196 /* SwitchStatement */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: + case 197 /* LabeledStatement */: + case 199 /* TryStatement */: + case 226 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -4813,17 +5125,17 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 173 /* YieldExpression */: + case 175 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 205 /* EnumDeclaration */: - case 203 /* InterfaceDeclaration */: - case 206 /* ModuleDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 202 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 205 /* InterfaceDeclaration */: + case 208 /* ModuleDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 204 /* ClassDeclaration */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. @@ -4831,7 +5143,7 @@ var ts; default: if (isFunctionLike(node)) { var name_4 = node.name; - if (name_4 && name_4.kind === 128 /* ComputedPropertyName */) { + if (name_4 && name_4.kind === 129 /* ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(name_4.expression); @@ -4850,14 +5162,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 153 /* BindingElement */: - case 227 /* EnumMember */: - case 130 /* Parameter */: - case 225 /* PropertyAssignment */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 226 /* ShorthandPropertyAssignment */: - case 199 /* VariableDeclaration */: + case 155 /* BindingElement */: + case 229 /* EnumMember */: + case 131 /* Parameter */: + case 227 /* PropertyAssignment */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 228 /* ShorthandPropertyAssignment */: + case 201 /* VariableDeclaration */: return true; } } @@ -4867,8 +5179,8 @@ var ts; function isAccessor(node) { if (node) { switch (node.kind) { - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: return true; } } @@ -4877,26 +5189,26 @@ var ts; ts.isAccessor = isAccessor; function isClassLike(node) { if (node) { - return node.kind === 202 /* ClassDeclaration */ || node.kind === 175 /* ClassExpression */; + return node.kind === 204 /* ClassDeclaration */ || node.kind === 177 /* ClassExpression */; } } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 136 /* Constructor */: - case 163 /* FunctionExpression */: - case 201 /* FunctionDeclaration */: - case 164 /* ArrowFunction */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: - case 143 /* FunctionType */: - case 144 /* ConstructorType */: + case 137 /* Constructor */: + case 165 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: + case 166 /* ArrowFunction */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: return true; } } @@ -4904,11 +5216,11 @@ var ts; } ts.isFunctionLike = isFunctionLike; function isFunctionBlock(node) { - return node && node.kind === 180 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 182 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 135 /* MethodDeclaration */ && node.parent.kind === 155 /* ObjectLiteralExpression */; + return node && node.kind === 136 /* MethodDeclaration */ && node.parent.kind === 157 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -4927,12 +5239,12 @@ var ts; return undefined; } switch (node.kind) { - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container // so that we can error on it. - if (node.parent.parent.kind === 202 /* ClassDeclaration */) { + if (node.parent.parent.kind === 204 /* ClassDeclaration */) { return node; } // If this is a computed property, then the parent should not @@ -4942,9 +5254,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 131 /* Decorator */: + case 132 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 130 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 131 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -4955,23 +5267,23 @@ var ts; node = node.parent; } break; - case 164 /* ArrowFunction */: + case 166 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 206 /* ModuleDeclaration */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 205 /* EnumDeclaration */: - case 228 /* SourceFile */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 208 /* ModuleDeclaration */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 207 /* EnumDeclaration */: + case 230 /* SourceFile */: return node; } } @@ -4983,12 +5295,12 @@ var ts; if (!node) return node; switch (node.kind) { - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'super' container. // A computed property name in a class needs to be a super container // so that we can error on it. - if (node.parent.parent.kind === 202 /* ClassDeclaration */) { + if (node.parent.parent.kind === 204 /* ClassDeclaration */) { return node; } // If this is a computed property, then the parent should not @@ -4998,9 +5310,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 131 /* Decorator */: + case 132 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 130 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 131 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -5011,26 +5323,26 @@ var ts; node = node.parent; } break; - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: if (!includeFunctions) { continue; } - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: return node; } } } ts.getSuperContainer = getSuperContainer; function getInvokedExpression(node) { - if (node.kind === 160 /* TaggedTemplateExpression */) { + if (node.kind === 162 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression or NewExpression. @@ -5039,44 +5351,44 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: // classes are valid targets return true; - case 133 /* PropertyDeclaration */: + case 134 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 202 /* ClassDeclaration */; - case 130 /* Parameter */: + return node.parent.kind === 204 /* ClassDeclaration */; + case 131 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; - return node.parent.body && node.parent.parent.kind === 202 /* ClassDeclaration */; - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 135 /* MethodDeclaration */: + return node.parent.body && node.parent.parent.kind === 204 /* ClassDeclaration */; + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 136 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. - return node.body && node.parent.kind === 202 /* ClassDeclaration */; + return node.body && node.parent.kind === 204 /* ClassDeclaration */; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: if (node.decorators) { return true; } return false; - case 133 /* PropertyDeclaration */: - case 130 /* Parameter */: + case 134 /* PropertyDeclaration */: + case 131 /* Parameter */: if (node.decorators) { return true; } return false; - case 137 /* GetAccessor */: + case 138 /* GetAccessor */: if (node.body && node.decorators) { return true; } return false; - case 135 /* MethodDeclaration */: - case 138 /* SetAccessor */: + case 136 /* MethodDeclaration */: + case 139 /* SetAccessor */: if (node.body && node.decorators) { return true; } @@ -5087,10 +5399,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 135 /* MethodDeclaration */: - case 138 /* SetAccessor */: + case 136 /* MethodDeclaration */: + case 139 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -5108,38 +5420,38 @@ var ts; case 95 /* TrueKeyword */: case 80 /* FalseKeyword */: case 9 /* RegularExpressionLiteral */: - case 154 /* ArrayLiteralExpression */: - case 155 /* ObjectLiteralExpression */: - case 156 /* PropertyAccessExpression */: - case 157 /* ElementAccessExpression */: - case 158 /* CallExpression */: - case 159 /* NewExpression */: - case 160 /* TaggedTemplateExpression */: - case 161 /* TypeAssertionExpression */: - case 162 /* ParenthesizedExpression */: - case 163 /* FunctionExpression */: - case 175 /* ClassExpression */: - case 164 /* ArrowFunction */: - case 167 /* VoidExpression */: - case 165 /* DeleteExpression */: - case 166 /* TypeOfExpression */: - case 168 /* PrefixUnaryExpression */: - case 169 /* PostfixUnaryExpression */: - case 170 /* BinaryExpression */: - case 171 /* ConditionalExpression */: - case 174 /* SpreadElementExpression */: - case 172 /* TemplateExpression */: + case 156 /* ArrayLiteralExpression */: + case 157 /* ObjectLiteralExpression */: + case 158 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: + case 162 /* TaggedTemplateExpression */: + case 163 /* TypeAssertionExpression */: + case 164 /* ParenthesizedExpression */: + case 165 /* FunctionExpression */: + case 177 /* ClassExpression */: + case 166 /* ArrowFunction */: + case 169 /* VoidExpression */: + case 167 /* DeleteExpression */: + case 168 /* TypeOfExpression */: + case 170 /* PrefixUnaryExpression */: + case 171 /* PostfixUnaryExpression */: + case 172 /* BinaryExpression */: + case 173 /* ConditionalExpression */: + case 176 /* SpreadElementExpression */: + case 174 /* TemplateExpression */: case 10 /* NoSubstitutionTemplateLiteral */: - case 176 /* OmittedExpression */: - case 173 /* YieldExpression */: + case 178 /* OmittedExpression */: + case 175 /* YieldExpression */: return true; - case 127 /* QualifiedName */: - while (node.parent.kind === 127 /* QualifiedName */) { + case 128 /* QualifiedName */: + while (node.parent.kind === 128 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 145 /* TypeQuery */; + return node.parent.kind === 147 /* TypeQuery */; case 65 /* Identifier */: - if (node.parent.kind === 145 /* TypeQuery */) { + if (node.parent.kind === 147 /* TypeQuery */) { return true; } // fall through @@ -5147,43 +5459,45 @@ var ts; case 8 /* StringLiteral */: var parent_2 = node.parent; switch (parent_2.kind) { - case 199 /* VariableDeclaration */: - case 130 /* Parameter */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 227 /* EnumMember */: - case 225 /* PropertyAssignment */: - case 153 /* BindingElement */: + case 201 /* VariableDeclaration */: + case 131 /* Parameter */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 229 /* EnumMember */: + case 227 /* PropertyAssignment */: + case 155 /* BindingElement */: return parent_2.initializer === node; - case 183 /* ExpressionStatement */: - case 184 /* IfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: - case 192 /* ReturnStatement */: - case 193 /* WithStatement */: - case 194 /* SwitchStatement */: - case 221 /* CaseClause */: - case 196 /* ThrowStatement */: - case 194 /* SwitchStatement */: + case 185 /* ExpressionStatement */: + case 186 /* IfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: + case 194 /* ReturnStatement */: + case 195 /* WithStatement */: + case 196 /* SwitchStatement */: + case 223 /* CaseClause */: + case 198 /* ThrowStatement */: + case 196 /* SwitchStatement */: return parent_2.expression === node; - case 187 /* ForStatement */: + case 189 /* ForStatement */: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 200 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 202 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 200 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 202 /* VariableDeclarationList */) || forInStatement.expression === node; - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: return node === parent_2.expression; - case 178 /* TemplateSpan */: + case 180 /* TemplateSpan */: return node === parent_2.expression; - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: return node === parent_2.expression; - case 131 /* Decorator */: + case 132 /* Decorator */: return true; + case 179 /* ExpressionWithTypeArguments */: + return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { return true; @@ -5200,7 +5514,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 209 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 220 /* ExternalModuleReference */; + return node.kind === 211 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 222 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5209,20 +5523,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 209 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 220 /* ExternalModuleReference */; + return node.kind === 211 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 222 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 210 /* ImportDeclaration */) { + if (node.kind === 212 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 209 /* ImportEqualsDeclaration */) { + if (node.kind === 211 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 220 /* ExternalModuleReference */) { + if (reference.kind === 222 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 216 /* ExportDeclaration */) { + if (node.kind === 218 /* ExportDeclaration */) { return node.moduleSpecifier; } } @@ -5230,15 +5544,15 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 130 /* Parameter */: + case 131 /* Parameter */: return node.questionToken !== undefined; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return node.questionToken !== undefined; - case 226 /* ShorthandPropertyAssignment */: - case 225 /* PropertyAssignment */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 228 /* ShorthandPropertyAssignment */: + case 227 /* PropertyAssignment */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -5246,9 +5560,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 241 /* JSDocFunctionType */ && + return node.kind === 243 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 243 /* JSDocConstructorType */; + node.parameters[0].type.kind === 245 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -5262,15 +5576,15 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 249 /* JSDocTypeTag */); + return getJSDocTag(node, 251 /* JSDocTypeTag */); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 248 /* JSDocReturnTag */); + return getJSDocTag(node, 250 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 250 /* JSDocTemplateTag */); + return getJSDocTag(node, 252 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { @@ -5281,7 +5595,7 @@ var ts; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 247 /* JSDocParameterTag */) { + if (t.kind === 249 /* JSDocParameterTag */) { var parameterTag = t; var name_5 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_5.text === parameterName) { @@ -5300,12 +5614,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 64 /* JavaScriptFile */) { - if (node.type && node.type.kind === 242 /* JSDocVariadicType */) { + if (node.type && node.type.kind === 244 /* JSDocVariadicType */) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 242 /* JSDocVariadicType */; + return paramTag.typeExpression.type.kind === 244 /* JSDocVariadicType */; } } return node.dotDotDotToken !== undefined; @@ -5326,7 +5640,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 152 /* ArrayBindingPattern */ || node.kind === 151 /* ObjectBindingPattern */); + return !!node && (node.kind === 154 /* ArrayBindingPattern */ || node.kind === 153 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -5341,33 +5655,33 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 164 /* ArrowFunction */: - case 153 /* BindingElement */: - case 202 /* ClassDeclaration */: - case 136 /* Constructor */: - case 205 /* EnumDeclaration */: - case 227 /* EnumMember */: - case 218 /* ExportSpecifier */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 137 /* GetAccessor */: - case 211 /* ImportClause */: - case 209 /* ImportEqualsDeclaration */: - case 214 /* ImportSpecifier */: - case 203 /* InterfaceDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 206 /* ModuleDeclaration */: - case 212 /* NamespaceImport */: - case 130 /* Parameter */: - case 225 /* PropertyAssignment */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 138 /* SetAccessor */: - case 226 /* ShorthandPropertyAssignment */: - case 204 /* TypeAliasDeclaration */: - case 129 /* TypeParameter */: - case 199 /* VariableDeclaration */: + case 166 /* ArrowFunction */: + case 155 /* BindingElement */: + case 204 /* ClassDeclaration */: + case 137 /* Constructor */: + case 207 /* EnumDeclaration */: + case 229 /* EnumMember */: + case 220 /* ExportSpecifier */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 138 /* GetAccessor */: + case 213 /* ImportClause */: + case 211 /* ImportEqualsDeclaration */: + case 216 /* ImportSpecifier */: + case 205 /* InterfaceDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 208 /* ModuleDeclaration */: + case 214 /* NamespaceImport */: + case 131 /* Parameter */: + case 227 /* PropertyAssignment */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 139 /* SetAccessor */: + case 228 /* ShorthandPropertyAssignment */: + case 206 /* TypeAliasDeclaration */: + case 130 /* TypeParameter */: + case 201 /* VariableDeclaration */: return true; } return false; @@ -5375,25 +5689,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 191 /* BreakStatement */: - case 190 /* ContinueStatement */: - case 198 /* DebuggerStatement */: - case 185 /* DoStatement */: - case 183 /* ExpressionStatement */: - case 182 /* EmptyStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 187 /* ForStatement */: - case 184 /* IfStatement */: - case 195 /* LabeledStatement */: - case 192 /* ReturnStatement */: - case 194 /* SwitchStatement */: + case 193 /* BreakStatement */: + case 192 /* ContinueStatement */: + case 200 /* DebuggerStatement */: + case 187 /* DoStatement */: + case 185 /* ExpressionStatement */: + case 184 /* EmptyStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 189 /* ForStatement */: + case 186 /* IfStatement */: + case 197 /* LabeledStatement */: + case 194 /* ReturnStatement */: + case 196 /* SwitchStatement */: case 94 /* ThrowKeyword */: - case 197 /* TryStatement */: - case 181 /* VariableStatement */: - case 186 /* WhileStatement */: - case 193 /* WithStatement */: - case 215 /* ExportAssignment */: + case 199 /* TryStatement */: + case 183 /* VariableStatement */: + case 188 /* WhileStatement */: + case 195 /* WithStatement */: + case 217 /* ExportAssignment */: return true; default: return false; @@ -5402,13 +5716,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 136 /* Constructor */: - case 133 /* PropertyDeclaration */: - case 135 /* MethodDeclaration */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 134 /* MethodSignature */: - case 141 /* IndexSignature */: + case 137 /* Constructor */: + case 134 /* PropertyDeclaration */: + case 136 /* MethodDeclaration */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 135 /* MethodSignature */: + case 142 /* IndexSignature */: return true; default: return false; @@ -5421,7 +5735,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 214 /* ImportSpecifier */ || parent.kind === 218 /* ExportSpecifier */) { + if (parent.kind === 216 /* ImportSpecifier */ || parent.kind === 220 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -5432,6 +5746,41 @@ var ts; return false; } ts.isDeclarationName = isDeclarationName; + // Return true if the given identifier is classified as an IdentifierName + function isIdentifierName(node) { + var parent = node.parent; + switch (parent.kind) { + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 229 /* EnumMember */: + case 227 /* PropertyAssignment */: + case 158 /* PropertyAccessExpression */: + // Name in member declaration or property name in property access + return parent.name === node; + case 128 /* QualifiedName */: + // Name on right hand side of dot in a type query + if (parent.right === node) { + while (parent.kind === 128 /* QualifiedName */) { + parent = parent.parent; + } + return parent.kind === 147 /* TypeQuery */; + } + return false; + case 155 /* BindingElement */: + case 216 /* ImportSpecifier */: + // Property name in binding element or import specifier + return parent.propertyName === node; + case 220 /* ExportSpecifier */: + // Any name in an export specifier + return true; + } + return false; + } + ts.isIdentifierName = isIdentifierName; // An alias symbol is created by one of the following declarations: // import = ... // import from ... @@ -5441,12 +5790,12 @@ var ts; // export = ... // export default ... function isAliasSymbolDeclaration(node) { - return node.kind === 209 /* ImportEqualsDeclaration */ || - node.kind === 211 /* ImportClause */ && !!node.name || - node.kind === 212 /* NamespaceImport */ || - node.kind === 214 /* ImportSpecifier */ || - node.kind === 218 /* ExportSpecifier */ || - node.kind === 215 /* ExportAssignment */ && node.expression.kind === 65 /* Identifier */; + return node.kind === 211 /* ImportEqualsDeclaration */ || + node.kind === 213 /* ImportClause */ && !!node.name || + node.kind === 214 /* NamespaceImport */ || + node.kind === 216 /* ImportSpecifier */ || + node.kind === 220 /* ExportSpecifier */ || + node.kind === 217 /* ExportAssignment */ && node.expression.kind === 65 /* Identifier */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { @@ -5529,7 +5878,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 66 /* FirstKeyword */ <= token && token <= 126 /* LastKeyword */; + return 66 /* FirstKeyword */ <= token && token <= 127 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -5545,7 +5894,7 @@ var ts; */ function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 128 /* ComputedPropertyName */ && + declaration.name.kind === 129 /* ComputedPropertyName */ && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; @@ -5555,14 +5904,14 @@ var ts; * where Symbol is literally the word "Symbol", and name is any identifierName */ function isWellKnownSymbolSyntactically(node) { - return node.kind === 156 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); + return node.kind === 158 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { if (name.kind === 65 /* Identifier */ || name.kind === 8 /* StringLiteral */ || name.kind === 7 /* NumericLiteral */) { return name.text; } - if (name.kind === 128 /* ComputedPropertyName */) { + if (name.kind === 129 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -5600,18 +5949,18 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 130 /* Parameter */; + return root.kind === 131 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 153 /* BindingElement */) { + while (node.kind === 155 /* BindingElement */) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 206 /* ModuleDeclaration */ || n.kind === 228 /* SourceFile */; + return isFunctionLike(n) || n.kind === 208 /* ModuleDeclaration */ || n.kind === 230 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -5847,7 +6196,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 136 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 137 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -5872,10 +6221,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 137 /* GetAccessor */) { + if (accessor.kind === 138 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 138 /* SetAccessor */) { + else if (accessor.kind === 139 /* SetAccessor */) { setAccessor = accessor; } else { @@ -5884,7 +6233,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 137 /* GetAccessor */ || member.kind === 138 /* SetAccessor */) + if ((member.kind === 138 /* GetAccessor */ || member.kind === 139 /* SetAccessor */) && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -5895,10 +6244,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 137 /* GetAccessor */ && !getAccessor) { + if (member.kind === 138 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 138 /* SetAccessor */ && !setAccessor) { + if (member.kind === 139 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -6046,22 +6395,22 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 156 /* PropertyAccessExpression */: - case 157 /* ElementAccessExpression */: - case 159 /* NewExpression */: - case 158 /* CallExpression */: - case 160 /* TaggedTemplateExpression */: - case 154 /* ArrayLiteralExpression */: - case 162 /* ParenthesizedExpression */: - case 155 /* ObjectLiteralExpression */: - case 175 /* ClassExpression */: - case 163 /* FunctionExpression */: + case 158 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + case 161 /* NewExpression */: + case 160 /* CallExpression */: + case 162 /* TaggedTemplateExpression */: + case 156 /* ArrayLiteralExpression */: + case 164 /* ParenthesizedExpression */: + case 157 /* ObjectLiteralExpression */: + case 177 /* ClassExpression */: + case 165 /* FunctionExpression */: case 65 /* Identifier */: case 9 /* RegularExpressionLiteral */: case 7 /* NumericLiteral */: case 8 /* StringLiteral */: case 10 /* NoSubstitutionTemplateLiteral */: - case 172 /* TemplateExpression */: + case 174 /* TemplateExpression */: case 80 /* FalseKeyword */: case 89 /* NullKeyword */: case 93 /* ThisKeyword */: @@ -6077,6 +6426,12 @@ var ts; return token >= 53 /* FirstAssignment */ && token <= 64 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; + function isExpressionWithTypeArgumentsInClassExtendsClause(node) { + return node.kind === 179 /* ExpressionWithTypeArguments */ && + node.parent.token === 79 /* ExtendsKeyword */ && + node.parent.parent.kind === 204 /* ClassDeclaration */; + } + ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; // Returns false if this heritage clause element's expression contains something unsupported // (i.e. not a name or dotted name). function isSupportedExpressionWithTypeArguments(node) { @@ -6087,7 +6442,7 @@ var ts; if (node.kind === 65 /* Identifier */) { return true; } - else if (node.kind === 156 /* PropertyAccessExpression */) { + else if (node.kind === 158 /* PropertyAccessExpression */) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -6095,8 +6450,8 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 127 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 156 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 128 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 158 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function getLocalSymbolForExportDefault(symbol) { @@ -6237,6 +6592,12 @@ var ts; return start <= textSpanEnd(span) && end >= span.start; } ts.textSpanIntersectsWith = textSpanIntersectsWith; + function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { + var end1 = start1 + length1; + var end2 = start2 + length2; + return start2 <= end1 && end2 >= start1; + } + ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; function textSpanIntersectsWithPosition(span, position) { return position <= textSpanEnd(span) && position >= span.start; } @@ -6396,9 +6757,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 129 /* TypeParameter */) { + if (d && d.kind === 130 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 203 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 205 /* InterfaceDeclaration */) { return current; } } @@ -6410,7 +6771,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(252 /* Count */); + var nodeConstructors = new Array(254 /* Count */); /* @internal */ ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -6455,20 +6816,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 127 /* QualifiedName */: + case 128 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 129 /* TypeParameter */: + case 130 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 130 /* Parameter */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 225 /* PropertyAssignment */: - case 226 /* ShorthandPropertyAssignment */: - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: + case 131 /* Parameter */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 227 /* PropertyAssignment */: + case 228 /* ShorthandPropertyAssignment */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -6477,24 +6838,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 163 /* FunctionExpression */: - case 201 /* FunctionDeclaration */: - case 164 /* ArrowFunction */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 165 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: + case 166 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -6505,263 +6866,267 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 142 /* TypeReference */: + case 144 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 145 /* TypeQuery */: + case 143 /* TypePredicate */: + return visitNode(cbNode, node.parameterName) || + visitNode(cbNode, node.type); + case 147 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 146 /* TypeLiteral */: + case 148 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 147 /* ArrayType */: + case 149 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 148 /* TupleType */: + case 150 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 149 /* UnionType */: + case 151 /* UnionType */: return visitNodes(cbNodes, node.types); - case 150 /* ParenthesizedType */: + case 152 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 151 /* ObjectBindingPattern */: - case 152 /* ArrayBindingPattern */: + case 153 /* ObjectBindingPattern */: + case 154 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 155 /* ObjectLiteralExpression */: + case 157 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 156 /* PropertyAccessExpression */: + case 158 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 157 /* ElementAccessExpression */: + case 159 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 160 /* TaggedTemplateExpression */: + case 162 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 165 /* DeleteExpression */: + case 167 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 166 /* TypeOfExpression */: + case 168 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 167 /* VoidExpression */: + case 169 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 168 /* PrefixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 173 /* YieldExpression */: + case 175 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 169 /* PostfixUnaryExpression */: + case 171 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 174 /* SpreadElementExpression */: + case 176 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 180 /* Block */: - case 207 /* ModuleBlock */: + case 182 /* Block */: + case 209 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 228 /* SourceFile */: + case 230 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 200 /* VariableDeclarationList */: + case 202 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 183 /* ExpressionStatement */: + case 185 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 184 /* IfStatement */: + case 186 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 185 /* DoStatement */: + case 187 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 186 /* WhileStatement */: + case 188 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 187 /* ForStatement */: + case 189 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 188 /* ForInStatement */: + case 190 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 189 /* ForOfStatement */: + case 191 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 190 /* ContinueStatement */: - case 191 /* BreakStatement */: + case 192 /* ContinueStatement */: + case 193 /* BreakStatement */: return visitNode(cbNode, node.label); - case 192 /* ReturnStatement */: + case 194 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 193 /* WithStatement */: + case 195 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 194 /* SwitchStatement */: + case 196 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 208 /* CaseBlock */: + case 210 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 221 /* CaseClause */: + case 223 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 222 /* DefaultClause */: + case 224 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 196 /* ThrowStatement */: + case 198 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 197 /* TryStatement */: + case 199 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 224 /* CatchClause */: + case 226 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 131 /* Decorator */: + case 132 /* Decorator */: return visitNode(cbNode, node.expression); - case 202 /* ClassDeclaration */: - case 175 /* ClassExpression */: + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 204 /* TypeAliasDeclaration */: + case 206 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 227 /* EnumMember */: + case 229 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 211 /* ImportClause */: + case 213 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 212 /* NamespaceImport */: + case 214 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 213 /* NamedImports */: - case 217 /* NamedExports */: + case 215 /* NamedImports */: + case 219 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 214 /* ImportSpecifier */: - case 218 /* ExportSpecifier */: + case 216 /* ImportSpecifier */: + case 220 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 172 /* TemplateExpression */: + case 174 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 178 /* TemplateSpan */: + case 180 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 223 /* HeritageClause */: + case 225 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 177 /* ExpressionWithTypeArguments */: + case 179 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 220 /* ExternalModuleReference */: + case 222 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 219 /* MissingDeclaration */: + case 221 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 229 /* JSDocTypeExpression */: + case 231 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 233 /* JSDocUnionType */: + case 235 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 234 /* JSDocTupleType */: + case 236 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 232 /* JSDocArrayType */: + case 234 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 236 /* JSDocNonNullableType */: + case 238 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 235 /* JSDocNullableType */: + case 237 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 237 /* JSDocRecordType */: + case 239 /* JSDocRecordType */: return visitNodes(cbNodes, node.members); - case 239 /* JSDocTypeReference */: + case 241 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 240 /* JSDocOptionalType */: + case 242 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 241 /* JSDocFunctionType */: + case 243 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 242 /* JSDocVariadicType */: + case 244 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 243 /* JSDocConstructorType */: + case 245 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 244 /* JSDocThisType */: + case 246 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 238 /* JSDocRecordMember */: + case 240 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 245 /* JSDocComment */: + case 247 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 247 /* JSDocParameterTag */: + case 249 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 248 /* JSDocReturnTag */: + case 250 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 249 /* JSDocTypeTag */: + case 251 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 250 /* JSDocTemplateTag */: + case 252 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); } } @@ -6891,13 +7256,6 @@ var ts; // Note: any errors at the end of the file that do not precede a regular node, should get // attached to the EOF token. var parseErrorBeforeNextFinishedNode = false; - (function (StatementFlags) { - StatementFlags[StatementFlags["None"] = 0] = "None"; - StatementFlags[StatementFlags["Statement"] = 1] = "Statement"; - StatementFlags[StatementFlags["ModuleElement"] = 2] = "ModuleElement"; - StatementFlags[StatementFlags["StatementOrModuleElement"] = 3] = "StatementOrModuleElement"; - })(Parser.StatementFlags || (Parser.StatementFlags = {})); - var StatementFlags = Parser.StatementFlags; function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes) { initializeState(fileName, _sourceText, languageVersion, _syntaxCursor); var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); @@ -6936,7 +7294,7 @@ var ts; // Prime the scanner. token = nextToken(); processReferenceComments(sourceFile); - sourceFile.statements = parseList(0 /* SourceElements */, true, parseSourceElement); + sourceFile.statements = parseList(0 /* SourceElements */, parseStatement); ts.Debug.assert(token === 1 /* EndOfFileToken */); sourceFile.endOfFileToken = parseTokenNode(); setExternalModuleIndicator(sourceFile); @@ -6962,9 +7320,9 @@ var ts; // Add additional cases as necessary depending on how we see JSDoc comments used // in the wild. switch (node.kind) { - case 181 /* VariableStatement */: - case 201 /* FunctionDeclaration */: - case 130 /* Parameter */: + case 183 /* VariableStatement */: + case 203 /* FunctionDeclaration */: + case 131 /* Parameter */: addJSDocComment(node); } forEachChild(node, visit); @@ -7005,7 +7363,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(228 /* SourceFile */, 0); + var sourceFile = createNode(230 /* SourceFile */, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -7023,9 +7381,6 @@ var ts; contextFlags &= ~flag; } } - function setStrictModeContext(val) { - setContextFlag(val, 1 /* StrictMode */); - } function setDisallowInContext(val) { setContextFlag(val, 2 /* DisallowIn */); } @@ -7102,9 +7457,6 @@ var ts; function inYieldContext() { return (contextFlags & 4 /* Yield */) !== 0; } - function inStrictModeContext() { - return (contextFlags & 1 /* StrictMode */) !== 0; - } function inGeneratorParameterContext() { return (contextFlags & 8 /* GeneratorParameter */) !== 0; } @@ -7356,7 +7708,7 @@ var ts; // ComputedPropertyName[Yield] : // [ AssignmentExpression[In, ?Yield] ] // - var node = createNode(128 /* ComputedPropertyName */); + var node = createNode(129 /* ComputedPropertyName */); parseExpected(18 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -7414,37 +7766,34 @@ var ts; } switch (parsingContext) { case 0 /* SourceElements */: - case 1 /* ModuleElements */: + case 1 /* BlockStatements */: + case 3 /* SwitchClauseStatements */: // If we're in error recovery, then we don't want to treat ';' as an empty statement. // The problem is that ';' can show up in far too many contexts, and if we see one // and assume it's a statement, then we may bail out inappropriately from whatever // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token === 22 /* SemicolonToken */ && inErrorRecovery) && isStartOfModuleElement(); - case 2 /* BlockStatements */: - case 4 /* SwitchClauseStatements */: - // During error recovery we don't treat empty statements as statements return !(token === 22 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); - case 3 /* SwitchClauses */: + case 2 /* SwitchClauses */: return token === 67 /* CaseKeyword */ || token === 73 /* DefaultKeyword */; - case 5 /* TypeMembers */: + case 4 /* TypeMembers */: return isStartOfTypeMember(); - case 6 /* ClassMembers */: + case 5 /* ClassMembers */: // We allow semicolons as class elements (as specified by ES6) as long as we're // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. return lookAhead(isClassMemberStart) || (token === 22 /* SemicolonToken */ && !inErrorRecovery); - case 7 /* EnumMembers */: + case 6 /* EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. return token === 18 /* OpenBracketToken */ || isLiteralPropertyName(); - case 13 /* ObjectLiteralMembers */: + case 12 /* ObjectLiteralMembers */: return token === 18 /* OpenBracketToken */ || token === 35 /* AsteriskToken */ || isLiteralPropertyName(); - case 10 /* ObjectBindingElements */: + case 9 /* ObjectBindingElements */: return isLiteralPropertyName(); - case 8 /* HeritageClauseElement */: + case 7 /* HeritageClauseElement */: // If we see { } then only consume it as an expression if it is followed by , or { // That way we won't consume the body of a class in its heritage clause. if (token === 14 /* OpenBraceToken */) { @@ -7459,29 +7808,29 @@ var ts; // element during recovery. return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); } - case 9 /* VariableDeclarations */: + case 8 /* VariableDeclarations */: return isIdentifierOrPattern(); - case 11 /* ArrayBindingElements */: + case 10 /* ArrayBindingElements */: return token === 23 /* CommaToken */ || token === 21 /* DotDotDotToken */ || isIdentifierOrPattern(); - case 16 /* TypeParameters */: + case 15 /* TypeParameters */: return isIdentifier(); - case 12 /* ArgumentExpressions */: - case 14 /* ArrayLiteralMembers */: + case 11 /* ArgumentExpressions */: + case 13 /* ArrayLiteralMembers */: return token === 23 /* CommaToken */ || token === 21 /* DotDotDotToken */ || isStartOfExpression(); - case 15 /* Parameters */: + case 14 /* Parameters */: return isStartOfParameter(); - case 17 /* TypeArguments */: - case 18 /* TupleElementTypes */: + case 16 /* TypeArguments */: + case 17 /* TupleElementTypes */: return token === 23 /* CommaToken */ || isStartOfType(); - case 19 /* HeritageClauses */: + case 18 /* HeritageClauses */: return isHeritageClause(); - case 20 /* ImportOrExportSpecifiers */: + case 19 /* ImportOrExportSpecifiers */: return isIdentifierOrKeyword(); - case 21 /* JSDocFunctionParameters */: - case 22 /* JSDocTypeArguments */: - case 24 /* JSDocTupleTypes */: + case 20 /* JSDocFunctionParameters */: + case 21 /* JSDocTypeArguments */: + case 23 /* JSDocTupleTypes */: return JSDocParser.isJSDocType(); - case 23 /* JSDocRecordMembers */: + case 22 /* JSDocRecordMembers */: return isSimplePropertyName(); } ts.Debug.fail("Non-exhaustive case in 'isListElement'."); @@ -7523,47 +7872,46 @@ var ts; return true; } switch (kind) { - case 1 /* ModuleElements */: - case 2 /* BlockStatements */: - case 3 /* SwitchClauses */: - case 5 /* TypeMembers */: - case 6 /* ClassMembers */: - case 7 /* EnumMembers */: - case 13 /* ObjectLiteralMembers */: - case 10 /* ObjectBindingElements */: - case 20 /* ImportOrExportSpecifiers */: + case 1 /* BlockStatements */: + case 2 /* SwitchClauses */: + case 4 /* TypeMembers */: + case 5 /* ClassMembers */: + case 6 /* EnumMembers */: + case 12 /* ObjectLiteralMembers */: + case 9 /* ObjectBindingElements */: + case 19 /* ImportOrExportSpecifiers */: return token === 15 /* CloseBraceToken */; - case 4 /* SwitchClauseStatements */: + case 3 /* SwitchClauseStatements */: return token === 15 /* CloseBraceToken */ || token === 67 /* CaseKeyword */ || token === 73 /* DefaultKeyword */; - case 8 /* HeritageClauseElement */: + case 7 /* HeritageClauseElement */: return token === 14 /* OpenBraceToken */ || token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */; - case 9 /* VariableDeclarations */: + case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); - case 16 /* TypeParameters */: + case 15 /* TypeParameters */: // Tokens other than '>' are here for better error recovery return token === 25 /* GreaterThanToken */ || token === 16 /* OpenParenToken */ || token === 14 /* OpenBraceToken */ || token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */; - case 12 /* ArgumentExpressions */: + case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token === 17 /* CloseParenToken */ || token === 22 /* SemicolonToken */; - case 14 /* ArrayLiteralMembers */: - case 18 /* TupleElementTypes */: - case 11 /* ArrayBindingElements */: + case 13 /* ArrayLiteralMembers */: + case 17 /* TupleElementTypes */: + case 10 /* ArrayBindingElements */: return token === 19 /* CloseBracketToken */; - case 15 /* Parameters */: + case 14 /* Parameters */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery return token === 17 /* CloseParenToken */ || token === 19 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; - case 17 /* TypeArguments */: + case 16 /* TypeArguments */: // Tokens other than '>' are here for better error recovery return token === 25 /* GreaterThanToken */ || token === 16 /* OpenParenToken */; - case 19 /* HeritageClauses */: + case 18 /* HeritageClauses */: return token === 14 /* OpenBraceToken */ || token === 15 /* CloseBraceToken */; - case 21 /* JSDocFunctionParameters */: + case 20 /* JSDocFunctionParameters */: return token === 17 /* CloseParenToken */ || token === 51 /* ColonToken */ || token === 15 /* CloseBraceToken */; - case 22 /* JSDocTypeArguments */: + case 21 /* JSDocTypeArguments */: return token === 25 /* GreaterThanToken */ || token === 15 /* CloseBraceToken */; - case 24 /* JSDocTupleTypes */: + case 23 /* JSDocTupleTypes */: return token === 19 /* CloseBracketToken */ || token === 15 /* CloseBraceToken */; - case 23 /* JSDocRecordMembers */: + case 22 /* JSDocRecordMembers */: return token === 15 /* CloseBraceToken */; } } @@ -7590,7 +7938,7 @@ var ts; } // True if positioned at element or terminator of the current list or any enclosing list function isInSomeParsingContext() { - for (var kind = 0; kind < 25 /* Count */; kind++) { + for (var kind = 0; kind < 24 /* Count */; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, true) || isListTerminator(kind)) { return true; @@ -7600,47 +7948,25 @@ var ts; return false; } // Parses a list of elements - function parseList(kind, checkForStrictMode, parseElement) { + function parseList(kind, parseElement) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; var result = []; result.pos = getNodePos(); - var savedStrictModeContext = inStrictModeContext(); while (!isListTerminator(kind)) { if (isListElement(kind, false)) { var element = parseListElement(kind, parseElement); result.push(element); - // test elements only if we are not already in strict mode - if (checkForStrictMode && !inStrictModeContext()) { - if (ts.isPrologueDirective(element)) { - if (isUseStrictPrologueDirective(element)) { - setStrictModeContext(true); - checkForStrictMode = false; - } - } - else { - checkForStrictMode = false; - } - } continue; } if (abortParsingListOrMoveToNextToken(kind)) { break; } } - setStrictModeContext(savedStrictModeContext); result.end = getNodeEnd(); parsingContext = saveParsingContext; return result; } - /// Should be called only on prologue directives (isPrologueDirective(node) should be true) - function isUseStrictPrologueDirective(node) { - ts.Debug.assert(ts.isPrologueDirective(node)); - var nodeText = ts.getTextOfNodeFromSourceText(sourceText, node.expression); - // Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the - // string to contain unicode escapes (as per ES5). - return nodeText === '"use strict"' || nodeText === "'use strict'"; - } function parseListElement(parsingContext, parseElement) { var node = currentNode(parsingContext); if (node) { @@ -7688,7 +8014,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.parserContextFlags & 63 /* ParserGeneratedFlags */; + var nodeContextFlags = node.parserContextFlags & 62 /* ParserGeneratedFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -7707,37 +8033,36 @@ var ts; } function canReuseNode(node, parsingContext) { switch (parsingContext) { - case 1 /* ModuleElements */: - return isReusableModuleElement(node); - case 6 /* ClassMembers */: + case 5 /* ClassMembers */: return isReusableClassMember(node); - case 3 /* SwitchClauses */: + case 2 /* SwitchClauses */: return isReusableSwitchClause(node); - case 2 /* BlockStatements */: - case 4 /* SwitchClauseStatements */: + case 0 /* SourceElements */: + case 1 /* BlockStatements */: + case 3 /* SwitchClauseStatements */: return isReusableStatement(node); - case 7 /* EnumMembers */: + case 6 /* EnumMembers */: return isReusableEnumMember(node); - case 5 /* TypeMembers */: + case 4 /* TypeMembers */: return isReusableTypeMember(node); - case 9 /* VariableDeclarations */: + case 8 /* VariableDeclarations */: return isReusableVariableDeclaration(node); - case 15 /* Parameters */: + case 14 /* Parameters */: return isReusableParameter(node); // Any other lists we do not care about reusing nodes in. But feel free to add if // you can do so safely. Danger areas involve nodes that may involve speculative // parsing. If speculative parsing is involved with the node, then the range the // parser reached while looking ahead might be in the edited range (see the example // in canReuseVariableDeclaratorNode for a good case of this). - case 19 /* HeritageClauses */: + case 18 /* HeritageClauses */: // This would probably be safe to reuse. There is no speculative parsing with // heritage clauses. - case 16 /* TypeParameters */: + case 15 /* TypeParameters */: // This would probably be safe to reuse. There is no speculative parsing with // type parameters. Note that that's because type *parameters* only occur in // unambiguous *type* contexts. While type *arguments* occur in very ambiguous // *expression* contexts. - case 18 /* TupleElementTypes */: + case 17 /* TupleElementTypes */: // This would probably be safe to reuse. There is no speculative parsing with // tuple types. // Technically, type argument list types are probably safe to reuse. While @@ -7745,51 +8070,41 @@ var ts; // produced from speculative parsing a < as a type argument list), we only have // the types because speculative parsing succeeded. Thus, the lookahead never // went past the end of the list and rewound. - case 17 /* TypeArguments */: + case 16 /* TypeArguments */: // Note: these are almost certainly not safe to ever reuse. Expressions commonly // need a large amount of lookahead, and we should not reuse them as they may // have actually intersected the edit. - case 12 /* ArgumentExpressions */: + case 11 /* ArgumentExpressions */: // This is not safe to reuse for the same reason as the 'AssignmentExpression' // cases. i.e. a property assignment may end with an expression, and thus might // have lookahead far beyond it's old node. - case 13 /* ObjectLiteralMembers */: + case 12 /* ObjectLiteralMembers */: // This is probably not safe to reuse. There can be speculative parsing with // type names in a heritage clause. There can be generic names in the type // name list, and there can be left hand side expressions (which can have type // arguments.) - case 8 /* HeritageClauseElement */: - } - return false; - } - function isReusableModuleElement(node) { - if (node) { - switch (node.kind) { - case 210 /* ImportDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 216 /* ExportDeclaration */: - case 215 /* ExportAssignment */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 206 /* ModuleDeclaration */: - case 205 /* EnumDeclaration */: - return true; - } - return isReusableStatement(node); + case 7 /* HeritageClauseElement */: } return false; } function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 136 /* Constructor */: - case 141 /* IndexSignature */: - case 135 /* MethodDeclaration */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 133 /* PropertyDeclaration */: - case 179 /* SemicolonClassElement */: + case 137 /* Constructor */: + case 142 /* IndexSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 134 /* PropertyDeclaration */: + case 181 /* SemicolonClassElement */: return true; + case 136 /* MethodDeclaration */: + // Method declarations are not necessarily reusable. An object-literal + // may have a method calls "constructor(...)" and we must reparse that + // into an actual .ConstructorDeclaration. + var methodDeclaration = node; + var nameIsConstructor = methodDeclaration.name.kind === 65 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 114 /* ConstructorKeyword */; + return !nameIsConstructor; } } return false; @@ -7797,8 +8112,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 221 /* CaseClause */: - case 222 /* DefaultClause */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: return true; } } @@ -7807,49 +8122,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 201 /* FunctionDeclaration */: - case 181 /* VariableStatement */: - case 180 /* Block */: - case 184 /* IfStatement */: - case 183 /* ExpressionStatement */: - case 196 /* ThrowStatement */: - case 192 /* ReturnStatement */: - case 194 /* SwitchStatement */: - case 191 /* BreakStatement */: - case 190 /* ContinueStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 187 /* ForStatement */: - case 186 /* WhileStatement */: - case 193 /* WithStatement */: - case 182 /* EmptyStatement */: - case 197 /* TryStatement */: - case 195 /* LabeledStatement */: - case 185 /* DoStatement */: - case 198 /* DebuggerStatement */: + case 203 /* FunctionDeclaration */: + case 183 /* VariableStatement */: + case 182 /* Block */: + case 186 /* IfStatement */: + case 185 /* ExpressionStatement */: + case 198 /* ThrowStatement */: + case 194 /* ReturnStatement */: + case 196 /* SwitchStatement */: + case 193 /* BreakStatement */: + case 192 /* ContinueStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 189 /* ForStatement */: + case 188 /* WhileStatement */: + case 195 /* WithStatement */: + case 184 /* EmptyStatement */: + case 199 /* TryStatement */: + case 197 /* LabeledStatement */: + case 187 /* DoStatement */: + case 200 /* DebuggerStatement */: + case 212 /* ImportDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 218 /* ExportDeclaration */: + case 217 /* ExportAssignment */: + case 208 /* ModuleDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 206 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 227 /* EnumMember */; + return node.kind === 229 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 140 /* ConstructSignature */: - case 134 /* MethodSignature */: - case 141 /* IndexSignature */: - case 132 /* PropertySignature */: - case 139 /* CallSignature */: + case 141 /* ConstructSignature */: + case 135 /* MethodSignature */: + case 142 /* IndexSignature */: + case 133 /* PropertySignature */: + case 140 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 199 /* VariableDeclaration */) { + if (node.kind !== 201 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -7870,7 +8194,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 130 /* Parameter */) { + if (node.kind !== 131 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -7889,30 +8213,29 @@ var ts; function parsingContextErrors(context) { switch (context) { case 0 /* SourceElements */: return ts.Diagnostics.Declaration_or_statement_expected; - case 1 /* ModuleElements */: return ts.Diagnostics.Declaration_or_statement_expected; - case 2 /* BlockStatements */: return ts.Diagnostics.Statement_expected; - case 3 /* SwitchClauses */: return ts.Diagnostics.case_or_default_expected; - case 4 /* SwitchClauseStatements */: return ts.Diagnostics.Statement_expected; - case 5 /* TypeMembers */: return ts.Diagnostics.Property_or_signature_expected; - case 6 /* ClassMembers */: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; - case 7 /* EnumMembers */: return ts.Diagnostics.Enum_member_expected; - case 8 /* HeritageClauseElement */: return ts.Diagnostics.Expression_expected; - case 9 /* VariableDeclarations */: return ts.Diagnostics.Variable_declaration_expected; - case 10 /* ObjectBindingElements */: return ts.Diagnostics.Property_destructuring_pattern_expected; - case 11 /* ArrayBindingElements */: return ts.Diagnostics.Array_element_destructuring_pattern_expected; - case 12 /* ArgumentExpressions */: return ts.Diagnostics.Argument_expression_expected; - case 13 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected; - case 14 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; - case 15 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; - case 16 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; - case 17 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; - case 18 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; - case 19 /* HeritageClauses */: return ts.Diagnostics.Unexpected_token_expected; - case 20 /* ImportOrExportSpecifiers */: return ts.Diagnostics.Identifier_expected; - case 21 /* JSDocFunctionParameters */: return ts.Diagnostics.Parameter_declaration_expected; - case 22 /* JSDocTypeArguments */: return ts.Diagnostics.Type_argument_expected; - case 24 /* JSDocTupleTypes */: return ts.Diagnostics.Type_expected; - case 23 /* JSDocRecordMembers */: return ts.Diagnostics.Property_assignment_expected; + case 1 /* BlockStatements */: return ts.Diagnostics.Declaration_or_statement_expected; + case 2 /* SwitchClauses */: return ts.Diagnostics.case_or_default_expected; + case 3 /* SwitchClauseStatements */: return ts.Diagnostics.Statement_expected; + case 4 /* TypeMembers */: return ts.Diagnostics.Property_or_signature_expected; + case 5 /* ClassMembers */: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; + case 6 /* EnumMembers */: return ts.Diagnostics.Enum_member_expected; + case 7 /* HeritageClauseElement */: return ts.Diagnostics.Expression_expected; + case 8 /* VariableDeclarations */: return ts.Diagnostics.Variable_declaration_expected; + case 9 /* ObjectBindingElements */: return ts.Diagnostics.Property_destructuring_pattern_expected; + case 10 /* ArrayBindingElements */: return ts.Diagnostics.Array_element_destructuring_pattern_expected; + case 11 /* ArgumentExpressions */: return ts.Diagnostics.Argument_expression_expected; + case 12 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected; + case 13 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; + case 14 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; + case 15 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; + case 16 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; + case 17 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; + case 18 /* HeritageClauses */: return ts.Diagnostics.Unexpected_token_expected; + case 19 /* ImportOrExportSpecifiers */: return ts.Diagnostics.Identifier_expected; + case 20 /* JSDocFunctionParameters */: return ts.Diagnostics.Parameter_declaration_expected; + case 21 /* JSDocTypeArguments */: return ts.Diagnostics.Type_argument_expected; + case 23 /* JSDocTupleTypes */: return ts.Diagnostics.Type_expected; + case 22 /* JSDocRecordMembers */: return ts.Diagnostics.Property_assignment_expected; } } ; @@ -7986,7 +8309,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(20 /* DotToken */)) { - var node = createNode(127 /* QualifiedName */, entity.pos); + var node = createNode(128 /* QualifiedName */, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -7994,38 +8317,38 @@ var ts; return entity; } function parseRightSideOfDot(allowIdentifierNames) { - // Technically a keyword is valid here as all keywords are identifier names. - // However, often we'll encounter this in error situations when the keyword + // Technically a keyword is valid here as all identifiers and keywords are identifier names. + // However, often we'll encounter this in error situations when the identifier or keyword // is actually starting another valid construct. // // So, we check for the following specific case: // // name. - // keyword identifierNameOrKeyword + // identifierOrKeyword identifierNameOrKeyword // // Note: the newlines are important here. For example, if that above code // were rewritten into: // - // name.keyword + // name.identifierOrKeyword // identifierNameOrKeyword // // Then we would consider it valid. That's because ASI would take effect and - // the code would be implicitly: "name.keyword; identifierNameOrKeyword". + // the code would be implicitly: "name.identifierOrKeyword; identifierNameOrKeyword". // In the first case though, ASI will not take effect because there is not a - // line terminator after the keyword. - if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord()) { + // line terminator after the identifier or keyword. + if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually - // be an identifier and the error woudl be quite confusing. + // be an identifier and the error would be quite confusing. return createMissingNode(65 /* Identifier */, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(172 /* TemplateExpression */); + var template = createNode(174 /* TemplateExpression */); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 11 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; @@ -8038,7 +8361,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(178 /* TemplateSpan */); + var span = createNode(180 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token === 15 /* CloseBraceToken */) { @@ -8078,22 +8401,30 @@ var ts; return node; } // TYPES - function parseTypeReference() { - var node = createNode(142 /* TypeReference */); - node.typeName = parseEntityName(false, ts.Diagnostics.Type_expected); + function parseTypeReferenceOrTypePredicate() { + var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); + if (typeName.kind === 65 /* Identifier */ && token === 117 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + nextToken(); + var node_1 = createNode(143 /* TypePredicate */, typeName.pos); + node_1.parameterName = typeName; + node_1.type = parseType(); + return finishNode(node_1); + } + var node = createNode(144 /* TypeReference */, typeName.pos); + node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 24 /* LessThanToken */) { - node.typeArguments = parseBracketedList(17 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); + node.typeArguments = parseBracketedList(16 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(145 /* TypeQuery */); + var node = createNode(147 /* TypeQuery */); parseExpected(97 /* TypeOfKeyword */); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(129 /* TypeParameter */); + var node = createNode(130 /* TypeParameter */); node.name = parseIdentifier(); if (parseOptional(79 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the @@ -8118,7 +8449,7 @@ var ts; } function parseTypeParameters() { if (token === 24 /* LessThanToken */) { - return parseBracketedList(16 /* TypeParameters */, parseTypeParameter, 24 /* LessThanToken */, 25 /* GreaterThanToken */); + return parseBracketedList(15 /* TypeParameters */, parseTypeParameter, 24 /* LessThanToken */, 25 /* GreaterThanToken */); } } function parseParameterType() { @@ -8139,7 +8470,7 @@ var ts; } } function parseParameter() { - var node = createNode(130 /* Parameter */); + var node = createNode(131 /* Parameter */); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); @@ -8210,7 +8541,7 @@ var ts; var savedGeneratorParameterContext = inGeneratorParameterContext(); setYieldContext(yieldAndGeneratorParameterContext); setGeneratorParameterContext(yieldAndGeneratorParameterContext); - var result = parseDelimitedList(15 /* Parameters */, parseParameter); + var result = parseDelimitedList(14 /* Parameters */, parseParameter); setYieldContext(savedYieldContext); setGeneratorParameterContext(savedGeneratorParameterContext); if (!parseExpected(17 /* CloseParenToken */) && requireCompleteParameterList) { @@ -8236,7 +8567,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 140 /* ConstructSignature */) { + if (kind === 141 /* ConstructSignature */) { parseExpected(88 /* NewKeyword */); } fillSignature(51 /* ColonToken */, false, false, node); @@ -8300,10 +8631,10 @@ var ts; return token === 51 /* ColonToken */ || token === 23 /* CommaToken */ || token === 19 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(141 /* IndexSignature */, fullStart); + var node = createNode(142 /* IndexSignature */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.parameters = parseBracketedList(15 /* Parameters */, parseParameter, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); + node.parameters = parseBracketedList(14 /* Parameters */, parseParameter, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); @@ -8313,7 +8644,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(50 /* QuestionToken */); if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { - var method = createNode(134 /* MethodSignature */, fullStart); + var method = createNode(135 /* MethodSignature */, fullStart); method.name = name; method.questionToken = questionToken; // Method signatues don't exist in expression contexts. So they have neither @@ -8323,7 +8654,7 @@ var ts; return finishNode(method); } else { - var property = createNode(132 /* PropertySignature */, fullStart); + var property = createNode(133 /* PropertySignature */, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -8365,7 +8696,7 @@ var ts; switch (token) { case 16 /* OpenParenToken */: case 24 /* LessThanToken */: - return parseSignatureMember(139 /* CallSignature */); + return parseSignatureMember(140 /* CallSignature */); case 18 /* OpenBracketToken */: // Indexer or computed property return isIndexSignature() @@ -8373,7 +8704,7 @@ var ts; : parsePropertyOrMethodSignature(); case 88 /* NewKeyword */: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(140 /* ConstructSignature */); + return parseSignatureMember(141 /* ConstructSignature */); } // fall through. case 8 /* StringLiteral */: @@ -8410,14 +8741,14 @@ var ts; return token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(146 /* TypeLiteral */); + var node = createNode(148 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; if (parseExpected(14 /* OpenBraceToken */)) { - members = parseList(5 /* TypeMembers */, false, parseTypeMember); + members = parseList(4 /* TypeMembers */, parseTypeMember); parseExpected(15 /* CloseBraceToken */); } else { @@ -8426,12 +8757,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(148 /* TupleType */); - node.elementTypes = parseBracketedList(18 /* TupleElementTypes */, parseType, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); + var node = createNode(150 /* TupleType */); + node.elementTypes = parseBracketedList(17 /* TupleElementTypes */, parseType, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(150 /* ParenthesizedType */); + var node = createNode(152 /* ParenthesizedType */); parseExpected(16 /* OpenParenToken */); node.type = parseType(); parseExpected(17 /* CloseParenToken */); @@ -8439,7 +8770,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 144 /* ConstructorType */) { + if (kind === 146 /* ConstructorType */) { parseExpected(88 /* NewKeyword */); } fillSignature(32 /* EqualsGreaterThanToken */, false, false, node); @@ -8452,13 +8783,13 @@ var ts; function parseNonArrayType() { switch (token) { case 112 /* AnyKeyword */: - case 122 /* StringKeyword */: - case 120 /* NumberKeyword */: + case 123 /* StringKeyword */: + case 121 /* NumberKeyword */: case 113 /* BooleanKeyword */: - case 123 /* SymbolKeyword */: + case 124 /* SymbolKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); - return node || parseTypeReference(); + return node || parseTypeReferenceOrTypePredicate(); case 99 /* VoidKeyword */: return parseTokenNode(); case 97 /* TypeOfKeyword */: @@ -8470,16 +8801,16 @@ var ts; case 16 /* OpenParenToken */: return parseParenthesizedType(); default: - return parseTypeReference(); + return parseTypeReferenceOrTypePredicate(); } } function isStartOfType() { switch (token) { case 112 /* AnyKeyword */: - case 122 /* StringKeyword */: - case 120 /* NumberKeyword */: + case 123 /* StringKeyword */: + case 121 /* NumberKeyword */: case 113 /* BooleanKeyword */: - case 123 /* SymbolKeyword */: + case 124 /* SymbolKeyword */: case 99 /* VoidKeyword */: case 97 /* TypeOfKeyword */: case 14 /* OpenBraceToken */: @@ -8503,7 +8834,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(18 /* OpenBracketToken */)) { parseExpected(19 /* CloseBracketToken */); - var node = createNode(147 /* ArrayType */, type.pos); + var node = createNode(149 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -8518,7 +8849,7 @@ var ts; types.push(parseArrayTypeOrHigher()); } types.end = getNodeEnd(); - var node = createNode(149 /* UnionType */, type.pos); + var node = createNode(151 /* UnionType */, type.pos); node.types = types; type = finishNode(node); } @@ -8573,10 +8904,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(143 /* FunctionType */); + return parseFunctionOrConstructorType(145 /* FunctionType */); } if (token === 88 /* NewKeyword */) { - return parseFunctionOrConstructorType(144 /* ConstructorType */); + return parseFunctionOrConstructorType(146 /* ConstructorType */); } return parseUnionTypeOrHigher(); } @@ -8745,11 +9076,6 @@ var ts; if (inYieldContext()) { return true; } - if (inStrictModeContext()) { - // If we're in strict mode, then 'yield' is a keyword, could only ever start - // a yield expression. - return true; - } // We're in a context where 'yield expr' is not allowed. However, if we can // definitely tell that the user was trying to parse a 'yield expr' and not // just a normal expr that start with a 'yield' identifier, then parse out @@ -8764,7 +9090,7 @@ var ts; // for now we just check if the next token is an identifier. More heuristics // can be added here later as necessary. We just need to make sure that we // don't accidently consume something legal. - return lookAhead(nextTokenIsIdentifierOnSameLine); + return lookAhead(nextTokenIsIdentifierOrKeywordOrNumberOnSameLine); } return false; } @@ -8773,7 +9099,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(173 /* YieldExpression */); + var node = createNode(175 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -8793,8 +9119,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 32 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(164 /* ArrowFunction */, identifier.pos); - var parameter = createNode(130 /* Parameter */, identifier.pos); + var node = createNode(166 /* ArrowFunction */, identifier.pos); + var parameter = createNode(131 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -8912,7 +9238,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(164 /* ArrowFunction */); + var node = createNode(166 /* ArrowFunction */); // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -8974,7 +9300,7 @@ var ts; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(171 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(173 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -8987,7 +9313,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 86 /* InKeyword */ || t === 126 /* OfKeyword */; + return t === 86 /* InKeyword */ || t === 127 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -9053,33 +9379,33 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(170 /* BinaryExpression */, left.pos); + var node = createNode(172 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(168 /* PrefixUnaryExpression */); + var node = createNode(170 /* PrefixUnaryExpression */); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(165 /* DeleteExpression */); + var node = createNode(167 /* DeleteExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(166 /* TypeOfExpression */); + var node = createNode(168 /* TypeOfExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(167 /* VoidExpression */); + var node = createNode(169 /* VoidExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -9109,7 +9435,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token === 38 /* PlusPlusToken */ || token === 39 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(169 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(171 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -9213,14 +9539,14 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(156 /* PropertyAccessExpression */, expression.pos); + var node = createNode(158 /* PropertyAccessExpression */, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(20 /* DotToken */, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } function parseTypeAssertion() { - var node = createNode(161 /* TypeAssertionExpression */); + var node = createNode(163 /* TypeAssertionExpression */); parseExpected(24 /* LessThanToken */); node.type = parseType(); parseExpected(25 /* GreaterThanToken */); @@ -9231,7 +9557,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(20 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(156 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(158 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); @@ -9240,7 +9566,7 @@ var ts; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(18 /* OpenBracketToken */)) { - var indexedAccess = createNode(157 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(159 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; // It's not uncommon for a user to write: "new Type[]". // Check for that common pattern and report a better error message. @@ -9256,7 +9582,7 @@ var ts; continue; } if (token === 10 /* NoSubstitutionTemplateLiteral */ || token === 11 /* TemplateHead */) { - var tagExpression = createNode(160 /* TaggedTemplateExpression */, expression.pos); + var tagExpression = createNode(162 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 10 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() @@ -9279,7 +9605,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(158 /* CallExpression */, expression.pos); + var callExpr = createNode(160 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -9287,7 +9613,7 @@ var ts; continue; } else if (token === 16 /* OpenParenToken */) { - var callExpr = createNode(158 /* CallExpression */, expression.pos); + var callExpr = createNode(160 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -9298,7 +9624,7 @@ var ts; } function parseArgumentList() { parseExpected(16 /* OpenParenToken */); - var result = parseDelimitedList(12 /* ArgumentExpressions */, parseArgumentExpression); + var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); parseExpected(17 /* CloseParenToken */); return result; } @@ -9306,7 +9632,7 @@ var ts; if (!parseOptional(24 /* LessThanToken */)) { return undefined; } - var typeArguments = parseDelimitedList(17 /* TypeArguments */, parseType); + var typeArguments = parseDelimitedList(16 /* TypeArguments */, parseType); if (!parseExpected(25 /* GreaterThanToken */)) { // If it doesn't have the closing > then it's definitely not an type argument list. return undefined; @@ -9389,41 +9715,41 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(162 /* ParenthesizedExpression */); + var node = createNode(164 /* ParenthesizedExpression */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(174 /* SpreadElementExpression */); + var node = createNode(176 /* SpreadElementExpression */); parseExpected(21 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 21 /* DotDotDotToken */ ? parseSpreadElement() : - token === 23 /* CommaToken */ ? createNode(176 /* OmittedExpression */) : + token === 23 /* CommaToken */ ? createNode(178 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(154 /* ArrayLiteralExpression */); + var node = createNode(156 /* ArrayLiteralExpression */); parseExpected(18 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 512 /* MultiLine */; - node.elements = parseDelimitedList(14 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); + node.elements = parseDelimitedList(13 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); parseExpected(19 /* CloseBracketToken */); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(116 /* GetKeyword */)) { - return parseAccessorDeclaration(137 /* GetAccessor */, fullStart, decorators, modifiers); + return parseAccessorDeclaration(138 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(121 /* SetKeyword */)) { - return parseAccessorDeclaration(138 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(122 /* SetKeyword */)) { + return parseAccessorDeclaration(139 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -9446,13 +9772,13 @@ var ts; } // Parse to check if it is short-hand property assignment or normal property assignment if ((token === 23 /* CommaToken */ || token === 15 /* CloseBraceToken */) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(226 /* ShorthandPropertyAssignment */, fullStart); + var shorthandDeclaration = createNode(228 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(225 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(227 /* PropertyAssignment */, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; parseExpected(51 /* ColonToken */); @@ -9461,12 +9787,12 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(155 /* ObjectLiteralExpression */); + var node = createNode(157 /* ObjectLiteralExpression */); parseExpected(14 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.flags |= 512 /* MultiLine */; } - node.properties = parseDelimitedList(13 /* ObjectLiteralMembers */, parseObjectLiteralElement, true); + node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, true); parseExpected(15 /* CloseBraceToken */); return finishNode(node); } @@ -9479,7 +9805,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(163 /* FunctionExpression */); + var node = createNode(165 /* FunctionExpression */); parseExpected(83 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(35 /* AsteriskToken */); node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); @@ -9494,7 +9820,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(159 /* NewExpression */); + var node = createNode(161 /* NewExpression */); parseExpected(88 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -9504,10 +9830,10 @@ var ts; return finishNode(node); } // STATEMENTS - function parseBlock(ignoreMissingOpenBrace, checkForStrictMode, diagnosticMessage) { - var node = createNode(180 /* Block */); + function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { + var node = createNode(182 /* Block */); if (parseExpected(14 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { - node.statements = parseList(2 /* BlockStatements */, checkForStrictMode, parseStatement); + node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(15 /* CloseBraceToken */); } else { @@ -9524,7 +9850,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var block = parseBlock(ignoreMissingOpenBrace, true, diagnosticMessage); + var block = parseBlock(ignoreMissingOpenBrace, diagnosticMessage); if (saveDecoratorContext) { setDecoratorContext(true); } @@ -9532,12 +9858,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(182 /* EmptyStatement */); + var node = createNode(184 /* EmptyStatement */); parseExpected(22 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(184 /* IfStatement */); + var node = createNode(186 /* IfStatement */); parseExpected(84 /* IfKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -9547,7 +9873,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(185 /* DoStatement */); + var node = createNode(187 /* DoStatement */); parseExpected(75 /* DoKeyword */); node.statement = parseStatement(); parseExpected(100 /* WhileKeyword */); @@ -9562,7 +9888,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(186 /* WhileStatement */); + var node = createNode(188 /* WhileStatement */); parseExpected(100 /* WhileKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -9585,21 +9911,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(86 /* InKeyword */)) { - var forInStatement = createNode(188 /* ForInStatement */, pos); + var forInStatement = createNode(190 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(126 /* OfKeyword */)) { - var forOfStatement = createNode(189 /* ForOfStatement */, pos); + else if (parseOptional(127 /* OfKeyword */)) { + var forOfStatement = createNode(191 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(17 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(187 /* ForStatement */, pos); + var forStatement = createNode(189 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(22 /* SemicolonToken */); if (token !== 22 /* SemicolonToken */ && token !== 17 /* CloseParenToken */) { @@ -9617,7 +9943,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 191 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */); + parseExpected(kind === 193 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -9625,7 +9951,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(192 /* ReturnStatement */); + var node = createNode(194 /* ReturnStatement */); parseExpected(90 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -9634,7 +9960,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(193 /* WithStatement */); + var node = createNode(195 /* WithStatement */); parseExpected(101 /* WithKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -9643,32 +9969,32 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(221 /* CaseClause */); + var node = createNode(223 /* CaseClause */); parseExpected(67 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(51 /* ColonToken */); - node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatement); + node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(222 /* DefaultClause */); + var node = createNode(224 /* DefaultClause */); parseExpected(73 /* DefaultKeyword */); parseExpected(51 /* ColonToken */); - node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatement); + node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { return token === 67 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(194 /* SwitchStatement */); + var node = createNode(196 /* SwitchStatement */); parseExpected(92 /* SwitchKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); - var caseBlock = createNode(208 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(210 /* CaseBlock */, scanner.getStartPos()); parseExpected(14 /* OpenBraceToken */); - caseBlock.clauses = parseList(3 /* SwitchClauses */, false, parseCaseOrDefaultClause); + caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(15 /* CloseBraceToken */); node.caseBlock = finishNode(caseBlock); return finishNode(node); @@ -9681,7 +10007,7 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(196 /* ThrowStatement */); + var node = createNode(198 /* ThrowStatement */); parseExpected(94 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -9689,30 +10015,30 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(197 /* TryStatement */); + var node = createNode(199 /* TryStatement */); parseExpected(96 /* TryKeyword */); - node.tryBlock = parseBlock(false, false); + node.tryBlock = parseBlock(false); node.catchClause = token === 68 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. if (!node.catchClause || token === 81 /* FinallyKeyword */) { parseExpected(81 /* FinallyKeyword */); - node.finallyBlock = parseBlock(false, false); + node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(224 /* CatchClause */); + var result = createNode(226 /* CatchClause */); parseExpected(68 /* CatchKeyword */); if (parseExpected(16 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); } parseExpected(17 /* CloseParenToken */); - result.block = parseBlock(false, false); + result.block = parseBlock(false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(198 /* DebuggerStatement */); + var node = createNode(200 /* DebuggerStatement */); parseExpected(72 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -9724,13 +10050,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 65 /* Identifier */ && parseOptional(51 /* ColonToken */)) { - var labeledStatement = createNode(195 /* LabeledStatement */, fullStart); + var labeledStatement = createNode(197 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(183 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(185 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -9743,7 +10069,11 @@ var ts; nextToken(); return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); } - function parseDeclarationFlags() { + function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { + nextToken(); + return (isIdentifierOrKeyword() || token === 7 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak(); + } + function isDeclaration() { while (true) { switch (token) { case 98 /* VarKeyword */: @@ -9752,28 +10082,52 @@ var ts; case 83 /* FunctionKeyword */: case 69 /* ClassKeyword */: case 77 /* EnumKeyword */: - return 1 /* Statement */; + return true; + // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; + // however, an identifier cannot be followed by another identifier on the same line. This is what we + // count on to parse out the respective declarations. For instance, we exploit this to say that + // + // namespace n + // + // can be none other than the beginning of a namespace declaration, but need to respect that JavaScript sees + // + // namespace + // n + // + // as the identifier 'namespace' on one line followed by the identifier 'n' on another. + // We need to look one token ahead to see if it permissible to try parsing a declaration. + // + // *Note*: 'interface' is actually a strict mode reserved word. So while + // + // "use strict" + // interface + // I {} + // + // could be legal, it would add complexity for very little gain. case 103 /* InterfaceKeyword */: - case 124 /* TypeKeyword */: + case 125 /* TypeKeyword */: + return nextTokenIsIdentifierOnSameLine(); + case 118 /* ModuleKeyword */: + case 119 /* NamespaceKeyword */: + return nextTokenIsIdentifierOrStringLiteralOnSameLine(); + case 115 /* DeclareKeyword */: nextToken(); - return isIdentifierOrKeyword() ? 1 /* Statement */ : 0 /* None */; - case 117 /* ModuleKeyword */: - case 118 /* NamespaceKeyword */: - nextToken(); - return isIdentifierOrKeyword() || token === 8 /* StringLiteral */ ? 2 /* ModuleElement */ : 0 /* None */; + // ASI takes effect for this modifier. + if (scanner.hasPrecedingLineBreak()) { + return false; + } + continue; case 85 /* ImportKeyword */: nextToken(); return token === 8 /* StringLiteral */ || token === 35 /* AsteriskToken */ || - token === 14 /* OpenBraceToken */ || isIdentifierOrKeyword() ? - 2 /* ModuleElement */ : 0 /* None */; + token === 14 /* OpenBraceToken */ || isIdentifierOrKeyword(); case 78 /* ExportKeyword */: nextToken(); if (token === 53 /* EqualsToken */ || token === 35 /* AsteriskToken */ || token === 14 /* OpenBraceToken */ || token === 73 /* DefaultKeyword */) { - return 2 /* ModuleElement */; + return true; } continue; - case 115 /* DeclareKeyword */: case 108 /* PublicKeyword */: case 106 /* PrivateKeyword */: case 107 /* ProtectedKeyword */: @@ -9781,14 +10135,14 @@ var ts; nextToken(); continue; default: - return 0 /* None */; + return false; } } } - function getDeclarationFlags() { - return lookAhead(parseDeclarationFlags); + function isStartOfDeclaration() { + return lookAhead(isDeclaration); } - function getStatementFlags() { + function isStartOfStatement() { switch (token) { case 52 /* AtToken */: case 22 /* SemicolonToken */: @@ -9814,61 +10168,44 @@ var ts; // however, we say they are here so that we may gracefully parse them and error later. case 68 /* CatchKeyword */: case 81 /* FinallyKeyword */: - return 1 /* Statement */; + return true; case 70 /* ConstKeyword */: case 78 /* ExportKeyword */: case 85 /* ImportKeyword */: - return getDeclarationFlags(); + return isStartOfDeclaration(); case 115 /* DeclareKeyword */: case 103 /* InterfaceKeyword */: - case 117 /* ModuleKeyword */: - case 118 /* NamespaceKeyword */: - case 124 /* TypeKeyword */: + case 118 /* ModuleKeyword */: + case 119 /* NamespaceKeyword */: + case 125 /* TypeKeyword */: // When these don't start a declaration, they're an identifier in an expression statement - return getDeclarationFlags() || 1 /* Statement */; + return true; case 108 /* PublicKeyword */: case 106 /* PrivateKeyword */: case 107 /* ProtectedKeyword */: case 109 /* StaticKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. - return getDeclarationFlags() || - (lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? 0 /* None */ : 1 /* Statement */); + return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: - return isStartOfExpression() ? 1 /* Statement */ : 0 /* None */; + return isStartOfExpression(); } } - function isStartOfStatement() { - return (getStatementFlags() & 1 /* Statement */) !== 0; - } - function isStartOfModuleElement() { - return (getStatementFlags() & 3 /* StatementOrModuleElement */) !== 0; - } - function nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine() { + function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return !scanner.hasPrecedingLineBreak() && - (isIdentifier() || token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */); + return isIdentifier() || token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */; } function isLetDeclaration() { - // It is let declaration if in strict mode or next token is identifier\open bracket\open curly on same line. - // otherwise it needs to be treated like identifier - return inStrictModeContext() || lookAhead(nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine); + // In ES6 'let' always starts a lexical declaration if followed by an identifier or { + // or [. + return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } function parseStatement() { - return parseModuleElementOfKind(1 /* Statement */); - } - function parseModuleElement() { - return parseModuleElementOfKind(3 /* StatementOrModuleElement */); - } - function parseSourceElement() { - return parseModuleElementOfKind(3 /* StatementOrModuleElement */); - } - function parseModuleElementOfKind(flags) { switch (token) { case 22 /* SemicolonToken */: return parseEmptyStatement(); case 14 /* OpenBraceToken */: - return parseBlock(false, false); + return parseBlock(false); case 98 /* VarKeyword */: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); case 104 /* LetKeyword */: @@ -9889,9 +10226,9 @@ var ts; case 82 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 71 /* ContinueKeyword */: - return parseBreakOrContinueStatement(190 /* ContinueStatement */); + return parseBreakOrContinueStatement(192 /* ContinueStatement */); case 66 /* BreakKeyword */: - return parseBreakOrContinueStatement(191 /* BreakStatement */); + return parseBreakOrContinueStatement(193 /* BreakStatement */); case 90 /* ReturnKeyword */: return parseReturnStatement(); case 101 /* WithKeyword */: @@ -9901,7 +10238,7 @@ var ts; case 94 /* ThrowKeyword */: return parseThrowStatement(); case 96 /* TryKeyword */: - // Include the next two for error recovery. + // Include 'catch' and 'finally' for error recovery. case 68 /* CatchKeyword */: case 81 /* FinallyKeyword */: return parseTryStatement(); @@ -9909,20 +10246,20 @@ var ts; return parseDebuggerStatement(); case 52 /* AtToken */: return parseDeclaration(); - case 70 /* ConstKeyword */: + case 103 /* InterfaceKeyword */: + case 125 /* TypeKeyword */: + case 118 /* ModuleKeyword */: + case 119 /* NamespaceKeyword */: case 115 /* DeclareKeyword */: + case 70 /* ConstKeyword */: case 77 /* EnumKeyword */: case 78 /* ExportKeyword */: case 85 /* ImportKeyword */: - case 103 /* InterfaceKeyword */: - case 117 /* ModuleKeyword */: - case 118 /* NamespaceKeyword */: case 106 /* PrivateKeyword */: case 107 /* ProtectedKeyword */: case 108 /* PublicKeyword */: case 109 /* StaticKeyword */: - case 124 /* TypeKeyword */: - if (getDeclarationFlags() & flags) { + if (isStartOfDeclaration()) { return parseDeclaration(); } break; @@ -9944,12 +10281,12 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 103 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 124 /* TypeKeyword */: + case 125 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 77 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 117 /* ModuleKeyword */: - case 118 /* NamespaceKeyword */: + case 118 /* ModuleKeyword */: + case 119 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); case 85 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); @@ -9959,10 +10296,10 @@ var ts; parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: - if (decorators) { + if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(219 /* MissingDeclaration */, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(221 /* MissingDeclaration */, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -9970,6 +10307,10 @@ var ts; } } } + function nextTokenIsIdentifierOrStringLiteralOnSameLine() { + nextToken(); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 8 /* StringLiteral */); + } function parseFunctionBlockOrSemicolon(isGenerator, diagnosticMessage) { if (token !== 14 /* OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); @@ -9980,16 +10321,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token === 23 /* CommaToken */) { - return createNode(176 /* OmittedExpression */); + return createNode(178 /* OmittedExpression */); } - var node = createNode(153 /* BindingElement */); + var node = createNode(155 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(153 /* BindingElement */); + var node = createNode(155 /* BindingElement */); // TODO(andersh): Handle computed properties var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -10005,16 +10346,16 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(151 /* ObjectBindingPattern */); + var node = createNode(153 /* ObjectBindingPattern */); parseExpected(14 /* OpenBraceToken */); - node.elements = parseDelimitedList(10 /* ObjectBindingElements */, parseObjectBindingElement); + node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(15 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(152 /* ArrayBindingPattern */); + var node = createNode(154 /* ArrayBindingPattern */); parseExpected(18 /* OpenBracketToken */); - node.elements = parseDelimitedList(11 /* ArrayBindingElements */, parseArrayBindingElement); + node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(19 /* CloseBracketToken */); return finishNode(node); } @@ -10031,7 +10372,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(199 /* VariableDeclaration */); + var node = createNode(201 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -10040,7 +10381,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(200 /* VariableDeclarationList */); + var node = createNode(202 /* VariableDeclarationList */); switch (token) { case 98 /* VarKeyword */: break; @@ -10063,13 +10404,13 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token === 126 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token === 127 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { var savedDisallowIn = inDisallowInContext(); setDisallowInContext(inForStatementInitializer); - node.declarations = parseDelimitedList(9 /* VariableDeclarations */, parseVariableDeclaration); + node.declarations = parseDelimitedList(8 /* VariableDeclarations */, parseVariableDeclaration); setDisallowInContext(savedDisallowIn); } return finishNode(node); @@ -10078,7 +10419,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 17 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(181 /* VariableStatement */, fullStart); + var node = createNode(183 /* VariableStatement */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -10086,7 +10427,7 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(201 /* FunctionDeclaration */, fullStart); + var node = createNode(203 /* FunctionDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(83 /* FunctionKeyword */); @@ -10097,7 +10438,7 @@ var ts; return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(136 /* Constructor */, pos); + var node = createNode(137 /* Constructor */, pos); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(114 /* ConstructorKeyword */); @@ -10106,7 +10447,7 @@ var ts; return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(135 /* MethodDeclaration */, fullStart); + var method = createNode(136 /* MethodDeclaration */, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -10117,7 +10458,7 @@ var ts; return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(133 /* PropertyDeclaration */, fullStart); + var property = createNode(134 /* PropertyDeclaration */, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -10209,7 +10550,7 @@ var ts; // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 121 /* SetKeyword */ || idToken === 116 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 122 /* SetKeyword */ || idToken === 116 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -10243,7 +10584,7 @@ var ts; decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(131 /* Decorator */, decoratorStart); + var decorator = createNode(132 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -10276,7 +10617,7 @@ var ts; } function parseClassElement() { if (token === 22 /* SemicolonToken */) { - var result = createNode(179 /* SemicolonClassElement */); + var result = createNode(181 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -10302,7 +10643,7 @@ var ts; token === 18 /* OpenBracketToken */) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } - if (decorators) { + if (decorators || modifiers) { // treat this as a property declaration with a missing name. var name_6 = createMissingNode(65 /* Identifier */, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_6, undefined); @@ -10314,15 +10655,12 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 175 /* ClassExpression */); + /*modifiers*/ undefined, 177 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 202 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 204 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { - // In ES6 specification, All parts of a ClassDeclaration or a ClassExpression are strict mode code - var savedStrictModeContext = inStrictModeContext(); - setStrictModeContext(true); var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); @@ -10342,9 +10680,7 @@ var ts; else { node.members = createMissingList(); } - var finishedNode = finishNode(node); - setStrictModeContext(savedStrictModeContext); - return finishedNode; + return finishNode(node); } function parseHeritageClauses(isClassHeritageClause) { // ClassTail[Yield,GeneratorParameter] : See 14.5 @@ -10358,23 +10694,23 @@ var ts; return undefined; } function parseHeritageClausesWorker() { - return parseList(19 /* HeritageClauses */, false, parseHeritageClause); + return parseList(18 /* HeritageClauses */, parseHeritageClause); } function parseHeritageClause() { if (token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */) { - var node = createNode(223 /* HeritageClause */); + var node = createNode(225 /* HeritageClause */); node.token = token; nextToken(); - node.types = parseDelimitedList(8 /* HeritageClauseElement */, parseExpressionWithTypeArguments); + node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(177 /* ExpressionWithTypeArguments */); + var node = createNode(179 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 24 /* LessThanToken */) { - node.typeArguments = parseBracketedList(17 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); + node.typeArguments = parseBracketedList(16 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); } return finishNode(node); } @@ -10382,10 +10718,10 @@ var ts; return token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */; } function parseClassMembers() { - return parseList(6 /* ClassMembers */, false, parseClassElement); + return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(203 /* InterfaceDeclaration */, fullStart); + var node = createNode(205 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(103 /* InterfaceKeyword */); @@ -10396,11 +10732,12 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(204 /* TypeAliasDeclaration */, fullStart); + var node = createNode(206 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(124 /* TypeKeyword */); + parseExpected(125 /* TypeKeyword */); node.name = parseIdentifier(); + node.typeParameters = parseTypeParameters(); parseExpected(53 /* EqualsToken */); node.type = parseType(); parseSemicolon(); @@ -10411,19 +10748,19 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNode(227 /* EnumMember */, scanner.getStartPos()); + var node = createNode(229 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(205 /* EnumDeclaration */, fullStart); + var node = createNode(207 /* EnumDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(77 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(14 /* OpenBraceToken */)) { - node.members = parseDelimitedList(7 /* EnumMembers */, parseEnumMember); + node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); parseExpected(15 /* CloseBraceToken */); } else { @@ -10432,9 +10769,9 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(207 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(209 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(14 /* OpenBraceToken */)) { - node.statements = parseList(1 /* ModuleElements */, false, parseModuleElement); + node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(15 /* CloseBraceToken */); } else { @@ -10443,7 +10780,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(206 /* ModuleDeclaration */, fullStart); + var node = createNode(208 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; @@ -10454,7 +10791,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(206 /* ModuleDeclaration */, fullStart); + var node = createNode(208 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -10463,11 +10800,11 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(118 /* NamespaceKeyword */)) { + if (parseOptional(119 /* NamespaceKeyword */)) { flags |= 32768 /* Namespace */; } else { - parseExpected(117 /* ModuleKeyword */); + parseExpected(118 /* ModuleKeyword */); if (token === 8 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -10475,7 +10812,7 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 119 /* RequireKeyword */ && + return token === 120 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -10484,7 +10821,7 @@ var ts; function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 23 /* CommaToken */ || - token === 125 /* FromKeyword */; + token === 126 /* FromKeyword */; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { parseExpected(85 /* ImportKeyword */); @@ -10492,11 +10829,11 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 /* CommaToken */ && token !== 125 /* FromKeyword */) { + if (token !== 23 /* CommaToken */ && token !== 126 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(209 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(211 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; @@ -10507,7 +10844,7 @@ var ts; } } // Import statement - var importDeclaration = createNode(210 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(212 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); // ImportDeclaration: @@ -10517,7 +10854,7 @@ var ts; token === 35 /* AsteriskToken */ || token === 14 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(125 /* FromKeyword */); + parseExpected(126 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -10530,7 +10867,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(211 /* ImportClause */, fullStart); + var importClause = createNode(213 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -10540,7 +10877,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(23 /* CommaToken */)) { - importClause.namedBindings = token === 35 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(213 /* NamedImports */); + importClause.namedBindings = token === 35 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(215 /* NamedImports */); } return finishNode(importClause); } @@ -10550,8 +10887,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(220 /* ExternalModuleReference */); - parseExpected(119 /* RequireKeyword */); + var node = createNode(222 /* ExternalModuleReference */); + parseExpected(120 /* RequireKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(17 /* CloseParenToken */); @@ -10572,7 +10909,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(212 /* NamespaceImport */); + var namespaceImport = createNode(214 /* NamespaceImport */); parseExpected(35 /* AsteriskToken */); parseExpected(111 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -10587,14 +10924,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(20 /* ImportOrExportSpecifiers */, kind === 213 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 14 /* OpenBraceToken */, 15 /* CloseBraceToken */); + node.elements = parseBracketedList(19 /* ImportOrExportSpecifiers */, kind === 215 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 14 /* OpenBraceToken */, 15 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(218 /* ExportSpecifier */); + return parseImportOrExportSpecifier(220 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(214 /* ImportSpecifier */); + return parseImportOrExportSpecifier(216 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -10619,23 +10956,23 @@ var ts; else { node.name = identifierName; } - if (kind === 214 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 216 /* ImportSpecifier */ && checkIdentifierIsKeyword) { // Report error identifier expected parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216 /* ExportDeclaration */, fullStart); + var node = createNode(218 /* ExportDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(35 /* AsteriskToken */)) { - parseExpected(125 /* FromKeyword */); + parseExpected(126 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(217 /* NamedExports */); - if (parseOptional(125 /* FromKeyword */)) { + node.exportClause = parseNamedImportsOrExports(219 /* NamedExports */); + if (parseOptional(126 /* FromKeyword */)) { node.moduleSpecifier = parseModuleSpecifier(); } } @@ -10643,7 +10980,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(215 /* ExportAssignment */, fullStart); + var node = createNode(217 /* ExportAssignment */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(53 /* EqualsToken */)) { @@ -10711,15 +11048,15 @@ var ts; } sourceFile.referencedFiles = referencedFiles; sourceFile.amdDependencies = amdDependencies; - sourceFile.amdModuleName = amdModuleName; + sourceFile.moduleName = amdModuleName; } function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 /* Export */ - || node.kind === 209 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 220 /* ExternalModuleReference */ - || node.kind === 210 /* ImportDeclaration */ - || node.kind === 215 /* ExportAssignment */ - || node.kind === 216 /* ExportDeclaration */ + || node.kind === 211 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 222 /* ExternalModuleReference */ + || node.kind === 212 /* ImportDeclaration */ + || node.kind === 217 /* ExportAssignment */ + || node.kind === 218 /* ExportDeclaration */ ? node : undefined; }); @@ -10727,31 +11064,30 @@ var ts; var ParsingContext; (function (ParsingContext) { ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements"; - ParsingContext[ParsingContext["ModuleElements"] = 1] = "ModuleElements"; - ParsingContext[ParsingContext["BlockStatements"] = 2] = "BlockStatements"; - ParsingContext[ParsingContext["SwitchClauses"] = 3] = "SwitchClauses"; - ParsingContext[ParsingContext["SwitchClauseStatements"] = 4] = "SwitchClauseStatements"; - ParsingContext[ParsingContext["TypeMembers"] = 5] = "TypeMembers"; - ParsingContext[ParsingContext["ClassMembers"] = 6] = "ClassMembers"; - ParsingContext[ParsingContext["EnumMembers"] = 7] = "EnumMembers"; - ParsingContext[ParsingContext["HeritageClauseElement"] = 8] = "HeritageClauseElement"; - ParsingContext[ParsingContext["VariableDeclarations"] = 9] = "VariableDeclarations"; - ParsingContext[ParsingContext["ObjectBindingElements"] = 10] = "ObjectBindingElements"; - ParsingContext[ParsingContext["ArrayBindingElements"] = 11] = "ArrayBindingElements"; - ParsingContext[ParsingContext["ArgumentExpressions"] = 12] = "ArgumentExpressions"; - ParsingContext[ParsingContext["ObjectLiteralMembers"] = 13] = "ObjectLiteralMembers"; - ParsingContext[ParsingContext["ArrayLiteralMembers"] = 14] = "ArrayLiteralMembers"; - ParsingContext[ParsingContext["Parameters"] = 15] = "Parameters"; - ParsingContext[ParsingContext["TypeParameters"] = 16] = "TypeParameters"; - ParsingContext[ParsingContext["TypeArguments"] = 17] = "TypeArguments"; - ParsingContext[ParsingContext["TupleElementTypes"] = 18] = "TupleElementTypes"; - ParsingContext[ParsingContext["HeritageClauses"] = 19] = "HeritageClauses"; - ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 20] = "ImportOrExportSpecifiers"; - ParsingContext[ParsingContext["JSDocFunctionParameters"] = 21] = "JSDocFunctionParameters"; - ParsingContext[ParsingContext["JSDocTypeArguments"] = 22] = "JSDocTypeArguments"; - ParsingContext[ParsingContext["JSDocRecordMembers"] = 23] = "JSDocRecordMembers"; - ParsingContext[ParsingContext["JSDocTupleTypes"] = 24] = "JSDocTupleTypes"; - ParsingContext[ParsingContext["Count"] = 25] = "Count"; // Number of parsing contexts + ParsingContext[ParsingContext["BlockStatements"] = 1] = "BlockStatements"; + ParsingContext[ParsingContext["SwitchClauses"] = 2] = "SwitchClauses"; + ParsingContext[ParsingContext["SwitchClauseStatements"] = 3] = "SwitchClauseStatements"; + ParsingContext[ParsingContext["TypeMembers"] = 4] = "TypeMembers"; + ParsingContext[ParsingContext["ClassMembers"] = 5] = "ClassMembers"; + ParsingContext[ParsingContext["EnumMembers"] = 6] = "EnumMembers"; + ParsingContext[ParsingContext["HeritageClauseElement"] = 7] = "HeritageClauseElement"; + ParsingContext[ParsingContext["VariableDeclarations"] = 8] = "VariableDeclarations"; + ParsingContext[ParsingContext["ObjectBindingElements"] = 9] = "ObjectBindingElements"; + ParsingContext[ParsingContext["ArrayBindingElements"] = 10] = "ArrayBindingElements"; + ParsingContext[ParsingContext["ArgumentExpressions"] = 11] = "ArgumentExpressions"; + ParsingContext[ParsingContext["ObjectLiteralMembers"] = 12] = "ObjectLiteralMembers"; + ParsingContext[ParsingContext["ArrayLiteralMembers"] = 13] = "ArrayLiteralMembers"; + ParsingContext[ParsingContext["Parameters"] = 14] = "Parameters"; + ParsingContext[ParsingContext["TypeParameters"] = 15] = "TypeParameters"; + ParsingContext[ParsingContext["TypeArguments"] = 16] = "TypeArguments"; + ParsingContext[ParsingContext["TupleElementTypes"] = 17] = "TupleElementTypes"; + ParsingContext[ParsingContext["HeritageClauses"] = 18] = "HeritageClauses"; + ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 19] = "ImportOrExportSpecifiers"; + ParsingContext[ParsingContext["JSDocFunctionParameters"] = 20] = "JSDocFunctionParameters"; + ParsingContext[ParsingContext["JSDocTypeArguments"] = 21] = "JSDocTypeArguments"; + ParsingContext[ParsingContext["JSDocRecordMembers"] = 22] = "JSDocRecordMembers"; + ParsingContext[ParsingContext["JSDocTupleTypes"] = 23] = "JSDocTupleTypes"; + ParsingContext[ParsingContext["Count"] = 24] = "Count"; // Number of parsing contexts })(ParsingContext || (ParsingContext = {})); var Tristate; (function (Tristate) { @@ -10793,7 +11129,7 @@ var ts; scanner.setText(sourceText, start, length); // Prime the first token for us to start processing. token = nextToken(); - var result = createNode(229 /* JSDocTypeExpression */); + var result = createNode(231 /* JSDocTypeExpression */); parseExpected(14 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(15 /* CloseBraceToken */); @@ -10804,12 +11140,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token === 44 /* BarToken */) { - var unionType = createNode(233 /* JSDocUnionType */, type.pos); + var unionType = createNode(235 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token === 53 /* EqualsToken */) { - var optionalType = createNode(240 /* JSDocOptionalType */, type.pos); + var optionalType = createNode(242 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -10820,20 +11156,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 18 /* OpenBracketToken */) { - var arrayType = createNode(232 /* JSDocArrayType */, type.pos); + var arrayType = createNode(234 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); parseExpected(19 /* CloseBracketToken */); type = finishNode(arrayType); } else if (token === 50 /* QuestionToken */) { - var nullableType = createNode(235 /* JSDocNullableType */, type.pos); + var nullableType = createNode(237 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token === 46 /* ExclamationToken */) { - var nonNullableType = createNode(236 /* JSDocNonNullableType */, type.pos); + var nonNullableType = createNode(238 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -10867,40 +11203,40 @@ var ts; case 93 /* ThisKeyword */: return parseJSDocThisType(); case 112 /* AnyKeyword */: - case 122 /* StringKeyword */: - case 120 /* NumberKeyword */: + case 123 /* StringKeyword */: + case 121 /* NumberKeyword */: case 113 /* BooleanKeyword */: - case 123 /* SymbolKeyword */: + case 124 /* SymbolKeyword */: case 99 /* VoidKeyword */: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(244 /* JSDocThisType */); + var result = createNode(246 /* JSDocThisType */); nextToken(); parseExpected(51 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(243 /* JSDocConstructorType */); + var result = createNode(245 /* JSDocConstructorType */); nextToken(); parseExpected(51 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(242 /* JSDocVariadicType */); + var result = createNode(244 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(241 /* JSDocFunctionType */); + var result = createNode(243 /* JSDocFunctionType */); nextToken(); parseExpected(16 /* OpenParenToken */); - result.parameters = parseDelimitedList(21 /* JSDocFunctionParameters */, parseJSDocParameter); + result.parameters = parseDelimitedList(20 /* JSDocFunctionParameters */, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(17 /* CloseParenToken */); if (token === 51 /* ColonToken */) { @@ -10910,18 +11246,18 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(130 /* Parameter */); + var parameter = createNode(131 /* Parameter */); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(240 /* JSDocOptionalType */, type.pos); + var result = createNode(242 /* JSDocOptionalType */, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(239 /* JSDocTypeReference */); + var result = createNode(241 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); while (parseOptional(20 /* DotToken */)) { if (token === 24 /* LessThanToken */) { @@ -10937,7 +11273,7 @@ var ts; function parseTypeArguments() { // Move past the < nextToken(); - var typeArguments = parseDelimitedList(22 /* JSDocTypeArguments */, parseJSDocType); + var typeArguments = parseDelimitedList(21 /* JSDocTypeArguments */, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); parseExpected(25 /* GreaterThanToken */); @@ -10951,21 +11287,21 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(127 /* QualifiedName */, left.pos); + var result = createNode(128 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(237 /* JSDocRecordType */); + var result = createNode(239 /* JSDocRecordType */); nextToken(); - result.members = parseDelimitedList(23 /* JSDocRecordMembers */, parseJSDocRecordMember); + result.members = parseDelimitedList(22 /* JSDocRecordMembers */, parseJSDocRecordMember); checkForTrailingComma(result.members); parseExpected(15 /* CloseBraceToken */); return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(238 /* JSDocRecordMember */); + var result = createNode(240 /* JSDocRecordMember */); result.name = parseSimplePropertyName(); if (token === 51 /* ColonToken */) { nextToken(); @@ -10974,15 +11310,15 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(236 /* JSDocNonNullableType */); + var result = createNode(238 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(234 /* JSDocTupleType */); + var result = createNode(236 /* JSDocTupleType */); nextToken(); - result.types = parseDelimitedList(24 /* JSDocTupleTypes */, parseJSDocType); + result.types = parseDelimitedList(23 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); parseExpected(19 /* CloseBracketToken */); return finishNode(result); @@ -10994,7 +11330,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(233 /* JSDocUnionType */); + var result = createNode(235 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(17 /* CloseParenToken */); @@ -11012,7 +11348,7 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(230 /* JSDocAllType */); + var result = createNode(232 /* JSDocAllType */); nextToken(); return finishNode(result); } @@ -11035,11 +11371,11 @@ var ts; token === 25 /* GreaterThanToken */ || token === 53 /* EqualsToken */ || token === 44 /* BarToken */) { - var result = createNode(231 /* JSDocUnknownType */, pos); + var result = createNode(233 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(235 /* JSDocNullableType */, pos); + var result = createNode(237 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -11127,7 +11463,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(245 /* JSDocComment */, start); + var result = createNode(247 /* JSDocComment */, start); result.tags = tags; return finishNode(result, end); } @@ -11165,7 +11501,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(246 /* JSDocTag */, atToken.pos); + var result = createNode(248 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -11217,7 +11553,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(247 /* JSDocParameterTag */, atToken.pos); + var result = createNode(249 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -11227,27 +11563,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 248 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 250 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(248 /* JSDocReturnTag */, atToken.pos); + var result = createNode(250 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 249 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 251 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(249 /* JSDocTypeTag */, atToken.pos); + var result = createNode(251 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 250 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 252 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -11260,7 +11596,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(129 /* TypeParameter */, name_7.pos); + var typeParameter = createNode(130 /* TypeParameter */, name_7.pos); typeParameter.name = name_7; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -11271,7 +11607,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(250 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(252 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -11857,8 +12193,8 @@ var ts; emptyGenericType.instantiations = {}; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var anySignature = createSignature(undefined, undefined, emptyArray, anyType, 0, false, false); - var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, false, false); + var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); + var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); var globals = {}; var globalESSymbolConstructorSymbol; var globalObjectType; @@ -11909,6 +12245,11 @@ var ts; flags: 2097152 /* ESSymbol */ } }; + var subtypeRelation = {}; + var assignableRelation = {}; + var identityRelation = {}; + initializeTypeChecker(); + return checker; function getEmitResolver(sourceFile) { // Ensure we have all the type information in place for this file so that all the // emitter questions of this resolver will return the right information. @@ -12051,10 +12392,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 228 /* SourceFile */); + return ts.getAncestor(node, 230 /* SourceFile */); } function isGlobalSourceFile(node) { - return node.kind === 228 /* SourceFile */ && !ts.isExternalModule(node); + return node.kind === 230 /* SourceFile */ && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -12111,40 +12452,54 @@ var ts; } } switch (location.kind) { - case 228 /* SourceFile */: + case 230 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 206 /* ModuleDeclaration */: - if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8914931 /* ModuleMember */)) { - if (result.flags & meaning || !(result.flags & 8388608 /* Alias */ && getDeclarationOfAliasSymbol(result).kind === 218 /* ExportSpecifier */)) { - break loop; + case 208 /* ModuleDeclaration */: + var moduleExports = getSymbolOfNode(location).exports; + if (location.kind === 230 /* SourceFile */ || + (location.kind === 208 /* ModuleDeclaration */ && location.name.kind === 8 /* StringLiteral */)) { + // It's an external module. Because of module/namespace merging, a module's exports are in scope, + // yet we never want to treat an export specifier as putting a member in scope. Therefore, + // if the name we find is purely an export specifier, it is not actually considered in scope. + // Two things to note about this: + // 1. We have to check this without calling getSymbol. The problem with calling getSymbol + // on an export specifier is that it might find the export specifier itself, and try to + // resolve it as an alias. This will cause the checker to consider the export specifier + // a circular alias reference when it might not be. + // 2. We check === SymbolFlags.Alias in order to check that the symbol is *purely* + // an alias. If we used &, we'd be throwing out symbols that have non alias aspects, + // which is not the desired behavior. + if (ts.hasProperty(moduleExports, name) && + moduleExports[name].flags === 8388608 /* Alias */ && + ts.getDeclarationOfKind(moduleExports[name], 220 /* ExportSpecifier */)) { + break; } - result = undefined; - } - else if (location.kind === 228 /* SourceFile */ || - (location.kind === 206 /* ModuleDeclaration */ && location.name.kind === 8 /* StringLiteral */)) { - result = getSymbolOfNode(location).exports["default"]; + result = moduleExports["default"]; var localSymbol = ts.getLocalSymbolForExportDefault(result); if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; } result = undefined; } + if (result = getSymbol(moduleExports, name, meaning & 8914931 /* ModuleMember */)) { + break loop; + } break; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or // local variables of the constructor. This effectively means that entities from outer scopes // by the same name as a constructor parameter or local variable are inaccessible // in initializer expressions for instance member variables. - if (location.parent.kind === 202 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) { + if (location.parent.kind === 204 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455 /* Value */)) { @@ -12154,8 +12509,8 @@ var ts; } } break; - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { if (lastLocation && lastLocation.flags & 128 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -12175,9 +12530,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (grandparent.kind === 202 /* ClassDeclaration */ || grandparent.kind === 203 /* InterfaceDeclaration */) { + if (grandparent.kind === 204 /* ClassDeclaration */ || grandparent.kind === 205 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -12185,19 +12540,19 @@ var ts; } } break; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 201 /* FunctionDeclaration */: - case 164 /* ArrowFunction */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 203 /* FunctionDeclaration */: + case 166 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 163 /* FunctionExpression */: + case 165 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -12210,7 +12565,7 @@ var ts; } } break; - case 175 /* ClassExpression */: + case 177 /* ClassExpression */: if (meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { @@ -12219,7 +12574,7 @@ var ts; } } break; - case 131 /* Decorator */: + case 132 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -12228,7 +12583,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 130 /* Parameter */) { + if (location.parent && location.parent.kind === 131 /* Parameter */) { location = location.parent; } // @@ -12284,16 +12639,16 @@ var ts; // for (let x in x) // for (let x of x) // climb up to the variable declaration skipping binding patterns - var variableDeclaration = ts.getAncestor(declaration, 199 /* VariableDeclaration */); + var variableDeclaration = ts.getAncestor(declaration, 201 /* VariableDeclaration */); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 181 /* VariableStatement */ || - variableDeclaration.parent.parent.kind === 187 /* ForStatement */) { + if (variableDeclaration.parent.parent.kind === 183 /* VariableStatement */ || + variableDeclaration.parent.parent.kind === 189 /* ForStatement */) { // variable statement/for statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 189 /* ForOfStatement */ || - variableDeclaration.parent.parent.kind === 188 /* ForInStatement */) { + else if (variableDeclaration.parent.parent.kind === 191 /* ForOfStatement */ || + variableDeclaration.parent.parent.kind === 190 /* ForInStatement */) { // ForIn/ForOf case - use site should not be used in expression part var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); @@ -12320,10 +12675,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 209 /* ImportEqualsDeclaration */) { + if (node.kind === 211 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 210 /* ImportDeclaration */) { + while (node && node.kind !== 212 /* ImportDeclaration */) { node = node.parent; } return node; @@ -12333,7 +12688,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 220 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 222 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -12440,17 +12795,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 211 /* ImportClause */: + case 213 /* ImportClause */: return getTargetOfImportClause(node); - case 212 /* NamespaceImport */: + case 214 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 214 /* ImportSpecifier */: + case 216 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 218 /* ExportSpecifier */: + case 220 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return getTargetOfExportAssignment(node); } } @@ -12495,11 +12850,11 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 215 /* ExportAssignment */) { + if (node.kind === 217 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 218 /* ExportSpecifier */) { + else if (node.kind === 220 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -12512,7 +12867,7 @@ var ts; // This function is only for imports with entity names function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 209 /* ImportEqualsDeclaration */); + importDeclaration = ts.getAncestor(entityName, 211 /* ImportEqualsDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } // There are three things we might try to look for. In the following examples, @@ -12525,13 +12880,13 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 65 /* Identifier */ || entityName.parent.kind === 127 /* QualifiedName */) { + if (entityName.kind === 65 /* Identifier */ || entityName.parent.kind === 128 /* QualifiedName */) { return resolveEntityName(entityName, 1536 /* Namespace */); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 209 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 211 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); } } @@ -12551,9 +12906,9 @@ var ts; return undefined; } } - else if (name.kind === 127 /* QualifiedName */ || name.kind === 156 /* PropertyAccessExpression */) { - var left = name.kind === 127 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 127 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 128 /* QualifiedName */ || name.kind === 158 /* PropertyAccessExpression */) { + var left = name.kind === 128 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 128 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1536 /* Namespace */); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -12714,7 +13069,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 136 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 137 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -12784,17 +13139,17 @@ var ts; } } switch (location_1.kind) { - case 228 /* SourceFile */: + case 230 /* SourceFile */: if (!ts.isExternalModule(location_1)) { break; } - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -12943,8 +13298,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 206 /* ModuleDeclaration */ && declaration.name.kind === 8 /* StringLiteral */) || - (declaration.kind === 228 /* SourceFile */ && ts.isExternalModule(declaration)); + return (declaration.kind === 208 /* ModuleDeclaration */ && declaration.name.kind === 8 /* StringLiteral */) || + (declaration.kind === 230 /* SourceFile */ && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -12980,12 +13335,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 145 /* TypeQuery */) { + if (entityName.parent.kind === 147 /* TypeQuery */) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 127 /* QualifiedName */ || entityName.kind === 156 /* PropertyAccessExpression */ || - entityName.parent.kind === 209 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 128 /* QualifiedName */ || entityName.kind === 158 /* PropertyAccessExpression */ || + entityName.parent.kind === 211 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1536 /* Namespace */; @@ -13019,6 +13374,13 @@ var ts; ts.releaseStringWriter(writer); return result; } + function signatureToString(signature, enclosingDeclaration, flags) { + var writer = ts.getSingleLineStringWriter(); + getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); + var result = writer.string(); + ts.releaseStringWriter(writer); + return result; + } function typeToString(type, enclosingDeclaration, flags) { var writer = ts.getSingleLineStringWriter(); getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); @@ -13033,10 +13395,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 150 /* ParenthesizedType */) { + while (node.kind === 152 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 204 /* TypeAliasDeclaration */) { + if (node.kind === 206 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -13286,7 +13648,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 228 /* SourceFile */ || declaration.parent.kind === 207 /* ModuleBlock */; + return declaration.parent.kind === 230 /* SourceFile */ || declaration.parent.kind === 209 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -13364,7 +13726,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, "x")); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 122 /* StringKeyword */); + writeKeyword(writer, 123 /* StringKeyword */); writePunctuation(writer, 19 /* CloseBracketToken */); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); @@ -13378,7 +13740,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, "x")); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 120 /* NumberKeyword */); + writeKeyword(writer, 121 /* NumberKeyword */); writePunctuation(writer, 19 /* CloseBracketToken */); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); @@ -13421,7 +13783,7 @@ var ts; function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { var targetSymbol = getTargetSymbol(symbol); if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */) { - buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterface(symbol), writer, enclosingDeclaraiton, flags); + buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); } } function buildTypeParameterDisplay(tp, writer, enclosingDeclaration, flags, symbolStack) { @@ -13525,12 +13887,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 206 /* ModuleDeclaration */) { + if (node.kind === 208 /* ModuleDeclaration */) { if (node.name.kind === 8 /* StringLiteral */) { return node; } } - else if (node.kind === 228 /* SourceFile */) { + else if (node.kind === 230 /* SourceFile */) { return ts.isExternalModule(node) ? node : undefined; } } @@ -13579,69 +13941,69 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 153 /* BindingElement */: + case 155 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 199 /* VariableDeclaration */: + case 201 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // Otherwise fall through - case 206 /* ModuleDeclaration */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 201 /* FunctionDeclaration */: - case 205 /* EnumDeclaration */: - case 209 /* ImportEqualsDeclaration */: + case 208 /* ModuleDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 203 /* FunctionDeclaration */: + case 207 /* EnumDeclaration */: + case 211 /* ImportEqualsDeclaration */: var parent_4 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && - !(node.kind !== 209 /* ImportEqualsDeclaration */ && parent_4.kind !== 228 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 211 /* ImportEqualsDeclaration */ && parent_4.kind !== 230 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent_4); - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: if (node.flags & (32 /* Private */ | 64 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so let it fall into next case statement - case 136 /* Constructor */: - case 140 /* ConstructSignature */: - case 139 /* CallSignature */: - case 141 /* IndexSignature */: - case 130 /* Parameter */: - case 207 /* ModuleBlock */: - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 146 /* TypeLiteral */: - case 142 /* TypeReference */: - case 147 /* ArrayType */: - case 148 /* TupleType */: - case 149 /* UnionType */: - case 150 /* ParenthesizedType */: + case 137 /* Constructor */: + case 141 /* ConstructSignature */: + case 140 /* CallSignature */: + case 142 /* IndexSignature */: + case 131 /* Parameter */: + case 209 /* ModuleBlock */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 148 /* TypeLiteral */: + case 144 /* TypeReference */: + case 149 /* ArrayType */: + case 150 /* TupleType */: + case 151 /* UnionType */: + case 152 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 211 /* ImportClause */: - case 212 /* NamespaceImport */: - case 214 /* ImportSpecifier */: + case 213 /* ImportClause */: + case 214 /* NamespaceImport */: + case 216 /* ImportSpecifier */: return false; // Type parameters are always visible - case 129 /* TypeParameter */: + case 130 /* TypeParameter */: // Source file is always visible - case 228 /* SourceFile */: + case 230 /* SourceFile */: return true; // Export assignements do not create name bindings outside the module - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -13657,10 +14019,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 215 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 217 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 218 /* ExportSpecifier */) { + else if (node.parent.kind === 220 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent); } var result = []; @@ -13718,7 +14080,7 @@ var ts; node = ts.getRootDeclaration(node); // Parent chain: // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' - return node.kind === 199 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; + return node.kind === 201 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 @@ -13754,7 +14116,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 151 /* ObjectBindingPattern */) { + if (pattern.kind === 153 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name_9 = declaration.propertyName || declaration.name; // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, @@ -13801,10 +14163,10 @@ var ts; // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration) { // A variable declared in a for..in statement is always of type any - if (declaration.parent.parent.kind === 188 /* ForInStatement */) { + if (declaration.parent.parent.kind === 190 /* ForInStatement */) { return anyType; } - if (declaration.parent.parent.kind === 189 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 191 /* ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -13818,11 +14180,11 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 130 /* Parameter */) { + if (declaration.kind === 131 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 138 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 137 /* GetAccessor */); + if (func.kind === 139 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 138 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -13838,7 +14200,7 @@ var ts; return checkExpressionCached(declaration.initializer); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 226 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 228 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // No type specified and nothing can be inferred @@ -13873,7 +14235,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 176 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 178 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -13896,7 +14258,7 @@ var ts; // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. function getTypeFromBindingPattern(pattern) { - return pattern.kind === 151 /* ObjectBindingPattern */ + return pattern.kind === 153 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -13918,7 +14280,7 @@ var ts; // During a normal type check we'll never get to here with a property assignment (the check of the containing // object literal uses a different path). We exclude widening only so that language services and type verification // tools see the actual type. - return declaration.kind !== 225 /* PropertyAssignment */ ? getWidenedType(type) : type; + return declaration.kind !== 227 /* PropertyAssignment */ ? getWidenedType(type) : type; } // If no type was specified and nothing could be inferred, and if the declaration specifies a binding pattern, use // the type implied by the binding pattern @@ -13930,7 +14292,7 @@ var ts; // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 130 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 131 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -13945,11 +14307,11 @@ var ts; } // Handle catch clause variables var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 224 /* CatchClause */) { + if (declaration.parent.kind === 226 /* CatchClause */) { return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 215 /* ExportAssignment */) { + if (declaration.kind === 217 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle variable, parameter or property @@ -13980,7 +14342,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 137 /* GetAccessor */) { + if (accessor.kind === 138 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -13996,8 +14358,8 @@ var ts; if (!pushTypeResolution(symbol)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 137 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 138 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 138 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 139 /* SetAccessor */); var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); @@ -14026,7 +14388,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 137 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 138 /* GetAccessor */); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -14126,9 +14488,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 202 /* ClassDeclaration */ || node.kind === 201 /* FunctionDeclaration */ || - node.kind === 163 /* FunctionExpression */ || node.kind === 135 /* MethodDeclaration */ || - node.kind === 164 /* ArrowFunction */) { + if (node.kind === 204 /* ClassDeclaration */ || node.kind === 203 /* FunctionDeclaration */ || + node.kind === 165 /* FunctionExpression */ || node.kind === 136 /* MethodDeclaration */ || + node.kind === 166 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -14138,15 +14500,16 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var kind = symbol.flags & 32 /* Class */ ? 202 /* ClassDeclaration */ : 203 /* InterfaceDeclaration */; + var kind = symbol.flags & 32 /* Class */ ? 204 /* ClassDeclaration */ : 205 /* InterfaceDeclaration */; return appendOuterTypeParameters(undefined, ts.getDeclarationOfKind(symbol, kind)); } - // The local type parameters are the combined set of type parameters from all declarations of the class or interface. - function getLocalTypeParametersOfClassOrInterface(symbol) { + // The local type parameters are the combined set of type parameters from all declarations of the class, + // interface, or type alias. + function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 203 /* InterfaceDeclaration */ || node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 205 /* InterfaceDeclaration */ || node.kind === 204 /* ClassDeclaration */ || node.kind === 206 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -14158,56 +14521,122 @@ var ts; // The full set of type parameters for a generic class or interface type consists of its outer type parameters plus // its locally declared type parameters. function getTypeParametersOfClassOrInterface(symbol) { - return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterface(symbol)); + return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); + } + function isConstructorType(type) { + return type.flags & 48128 /* ObjectType */ && getSignaturesOfType(type, 1 /* Construct */).length > 0; + } + function getBaseTypeNodeOfClass(type) { + return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); + } + function getConstructorsForTypeArguments(type, typeArgumentNodes) { + var typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; + return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount; }); + } + function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { + var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); + if (typeArgumentNodes) { + var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); + signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments); }); + } + return signatures; + } + // The base constructor of a class can resolve to + // undefinedType if the class has no extends clause, + // unknownType if an error occurred during resolution of the extends expression, + // nullType if the extends expression is the null value, or + // an object type with at least one construct signature. + function getBaseConstructorTypeOfClass(type) { + if (!type.resolvedBaseConstructorType) { + var baseTypeNode = getBaseTypeNodeOfClass(type); + if (!baseTypeNode) { + return type.resolvedBaseConstructorType = undefinedType; + } + if (!pushTypeResolution(type)) { + return unknownType; + } + var baseConstructorType = checkExpression(baseTypeNode.expression); + if (baseConstructorType.flags & 48128 /* ObjectType */) { + // Resolving the members of a class requires us to resolve the base class of that class. + // We force resolution here such that we catch circularities now. + resolveObjectOrUnionTypeMembers(baseConstructorType); + } + if (!popTypeResolution()) { + error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); + return type.resolvedBaseConstructorType = unknownType; + } + if (baseConstructorType !== unknownType && baseConstructorType !== nullType && !isConstructorType(baseConstructorType)) { + error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); + return type.resolvedBaseConstructorType = unknownType; + } + type.resolvedBaseConstructorType = baseConstructorType; + } + return type.resolvedBaseConstructorType; } function getBaseTypes(type) { - var typeWithBaseTypes = type; - if (!typeWithBaseTypes.baseTypes) { + if (!type.resolvedBaseTypes) { if (type.symbol.flags & 32 /* Class */) { - resolveBaseTypesOfClass(typeWithBaseTypes); + resolveBaseTypesOfClass(type); } else if (type.symbol.flags & 64 /* Interface */) { - resolveBaseTypesOfInterface(typeWithBaseTypes); + resolveBaseTypesOfInterface(type); } else { ts.Debug.fail("type must be class or interface"); } } - return typeWithBaseTypes.baseTypes; + return type.resolvedBaseTypes; } function resolveBaseTypesOfClass(type) { - type.baseTypes = []; - var declaration = ts.getDeclarationOfKind(type.symbol, 202 /* ClassDeclaration */); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(declaration); - if (baseTypeNode) { - var baseType = getTypeFromTypeNode(baseTypeNode); - if (baseType !== unknownType) { - if (getTargetType(baseType).flags & 1024 /* Class */) { - if (type !== baseType && !hasBaseType(baseType, type)) { - type.baseTypes.push(baseType); - } - else { - error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); - } - } - else { - error(baseTypeNode, ts.Diagnostics.A_class_may_only_extend_another_class); - } - } + type.resolvedBaseTypes = emptyArray; + var baseContructorType = getBaseConstructorTypeOfClass(type); + if (!(baseContructorType.flags & 48128 /* ObjectType */)) { + return; } + var baseTypeNode = getBaseTypeNodeOfClass(type); + var baseType; + if (baseContructorType.symbol && baseContructorType.symbol.flags & 32 /* Class */) { + // When base constructor type is a class we know that the constructors all have the same type parameters as the + // class and all return the instance type of the class. There is no need for further checks and we can apply the + // type arguments in the same manner as a type reference to get the same error reporting experience. + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseContructorType.symbol); + } + else { + // The class derives from a "class-like" constructor function, check that we have at least one construct signature + // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere + // we check that all instantiated signatures return the same type. + var constructors = getInstantiatedConstructorsForTypeArguments(baseContructorType, baseTypeNode.typeArguments); + if (!constructors.length) { + error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); + return; + } + baseType = getReturnTypeOfSignature(constructors[0]); + } + if (baseType === unknownType) { + return; + } + if (!(getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */))) { + error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); + return; + } + if (type === baseType || hasBaseType(baseType, type)) { + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); + return; + } + type.resolvedBaseTypes = [baseType]; } function resolveBaseTypesOfInterface(type) { - type.baseTypes = []; + type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 203 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 205 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { if (getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */)) { if (type !== baseType && !hasBaseType(baseType, type)) { - type.baseTypes.push(baseType); + type.resolvedBaseTypes.push(baseType); } else { error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); @@ -14227,7 +14656,7 @@ var ts; var kind = symbol.flags & 32 /* Class */ ? 1024 /* Class */ : 2048 /* Interface */; var type = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); - var localTypeParameters = getLocalTypeParametersOfClassOrInterface(symbol); + var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (outerTypeParameters || localTypeParameters) { type.flags |= 4096 /* Reference */; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); @@ -14249,9 +14678,18 @@ var ts; if (!pushTypeResolution(links)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 204 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 206 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); - if (!popTypeResolution()) { + if (popTypeResolution()) { + links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + if (links.typeParameters) { + // Initialize the instantiation cache for generic type aliases. The declared type corresponds to + // an instantiation of the type alias with the type parameters supplied as type arguments. + links.instantiations = {}; + links.instantiations[getTypeListId(links.typeParameters)] = type; + } + } + else { type = unknownType; error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } @@ -14273,7 +14711,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 129 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 130 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -14388,34 +14826,42 @@ var ts; }); setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } - function createSignature(declaration, typeParameters, parameters, resolvedReturnType, minArgumentCount, hasRestParameter, hasStringLiterals) { + function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); sig.declaration = declaration; sig.typeParameters = typeParameters; sig.parameters = parameters; sig.resolvedReturnType = resolvedReturnType; + sig.typePredicate = typePredicate; sig.minArgumentCount = minArgumentCount; sig.hasRestParameter = hasRestParameter; sig.hasStringLiterals = hasStringLiterals; return sig; } function cloneSignature(sig) { - return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); + return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); } function getDefaultConstructSignatures(classType) { - var baseTypes = getBaseTypes(classType); - if (baseTypes.length) { - var baseType = baseTypes[0]; - var baseSignatures = getSignaturesOfType(getTypeOfSymbol(baseType.symbol), 1 /* Construct */); - return ts.map(baseSignatures, function (baseSignature) { - var signature = baseType.flags & 4096 /* Reference */ ? - getSignatureInstantiation(baseSignature, baseType.typeArguments) : cloneSignature(baseSignature); - signature.typeParameters = classType.localTypeParameters; - signature.resolvedReturnType = classType; - return signature; - }); + if (!getBaseTypes(classType).length) { + return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)]; } - return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, 0, false, false)]; + var baseConstructorType = getBaseConstructorTypeOfClass(classType); + var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); + var baseTypeNode = getBaseTypeNodeOfClass(classType); + var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); + var typeArgCount = typeArguments ? typeArguments.length : 0; + var result = []; + for (var _i = 0; _i < baseSignatures.length; _i++) { + var baseSig = baseSignatures[_i]; + var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; + if (typeParamCount === typeArgCount) { + var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + sig.typeParameters = classType.localTypeParameters; + sig.resolvedReturnType = classType; + result.push(sig); + } + } + return result; } function createTupleTypeMemberSymbols(memberTypes) { var members = {}; @@ -14521,10 +14967,10 @@ var ts; if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); } - var baseTypes = getBaseTypes(classType); - if (baseTypes.length) { + var baseConstructorType = getBaseConstructorTypeOfClass(classType); + if (baseConstructorType.flags & 48128 /* ObjectType */) { members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(getTypeOfSymbol(baseTypes[0].symbol))); + addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); } } stringIndexType = undefined; @@ -14745,7 +15191,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 136 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 137 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -14767,24 +15213,33 @@ var ts; minArgumentCount = declaration.parameters.length; } var returnType; + var typePredicate; if (classType) { returnType = classType; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); + if (declaration.type.kind === 143 /* TypePredicate */) { + var typePredicateNode = declaration.type; + typePredicate = { + parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, + parameterIndex: typePredicateNode.parameterName ? getTypePredicateParameterIndex(declaration.parameters, typePredicateNode.parameterName) : undefined, + type: getTypeFromTypeNode(typePredicateNode.type) + }; + } } else { // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 137 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 138 /* SetAccessor */); + if (declaration.kind === 138 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 139 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { returnType = anyType; } } - links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); + links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); } return links.resolvedSignature; } @@ -14795,19 +15250,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: // Don't include signature if node is the implementation of an overloaded function. A node is considered // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). @@ -14884,7 +15339,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 136 /* Constructor */ || signature.declaration.kind === 140 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 137 /* Constructor */ || signature.declaration.kind === 141 /* ConstructSignature */; var type = createObjectType(32768 /* Anonymous */ | 131072 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; @@ -14898,7 +15353,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 120 /* NumberKeyword */ : 122 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 121 /* NumberKeyword */ : 123 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { var len = indexSymbol.declarations.length; @@ -14928,13 +15383,13 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 129 /* TypeParameter */).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 130 /* TypeParameter */).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 129 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 130 /* TypeParameter */).parent); } function getTypeListId(types) { switch (types.length) { @@ -14987,13 +15442,13 @@ var ts; currentNode = currentNode.parent; } // if last step was made from the type parameter this means that path has started somewhere in constraint which is illegal - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 129 /* TypeParameter */; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 130 /* TypeParameter */; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 142 /* TypeReference */ && n.typeName.kind === 65 /* Identifier */) { + if (n.kind === 144 /* TypeReference */ && n.typeName.kind === 65 /* Identifier */) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, undefined, undefined); @@ -15005,7 +15460,7 @@ var ts; // -> typeParameter and symbol.declaration originate from the same type parameter list // -> illegal for all declarations in symbol // forEach === exists - links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent == typeParameter.parent; }); + links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent === typeParameter.parent; }); } } if (links.isIllegalTypeReferenceInConstraint) { @@ -15019,62 +15474,82 @@ var ts; check(typeParameter.constraint); } } - function getTypeFromTypeReferenceOrExpressionWithTypeArguments(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - var type; - // We don't currently support heritage clauses with complex expressions in them. - // For these cases, we just set the type to be the unknownType. - if (node.kind !== 177 /* ExpressionWithTypeArguments */ || ts.isSupportedExpressionWithTypeArguments(node)) { - var typeNameOrExpression = node.kind === 142 /* TypeReference */ - ? node.typeName - : node.expression; - var symbol = resolveEntityName(typeNameOrExpression, 793056 /* Type */); - if (symbol) { - if ((symbol.flags & 262144 /* TypeParameter */) && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { - // TypeScript 1.0 spec (April 2014): 3.4.1 - // Type parameters declared in a particular type parameter list - // may not be referenced in constraints in that type parameter list - // Implementation: such type references are resolved to 'unknown' type that usually denotes error - type = unknownType; - } - else { - type = createTypeReferenceIfGeneric(getDeclaredTypeOfSymbol(symbol), node, node.typeArguments); - } - } + // Get type from reference to class or interface + function getTypeFromClassOrInterfaceReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var typeParameters = type.localTypeParameters; + if (typeParameters) { + if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */), typeParameters.length); + return unknownType; } - links.resolvedType = type || unknownType; - } - return links.resolvedType; - } - function createTypeReferenceIfGeneric(type, node, typeArguments) { - if (type.flags & (1024 /* Class */ | 2048 /* Interface */) && type.flags & 4096 /* Reference */) { // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - var localTypeParameters = type.localTypeParameters; - var expectedTypeArgCount = localTypeParameters ? localTypeParameters.length : 0; - var typeArgCount = typeArguments ? typeArguments.length : 0; - if (typeArgCount === expectedTypeArgCount) { - // When no type arguments are expected we already have the right type because all outer type parameters - // have themselves as default type arguments. - if (typeArgCount) { - return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(typeArguments, getTypeFromTypeNode))); - } - } - else { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */), expectedTypeArgCount); - return undefined; - } + return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); } - else { - if (typeArguments) { - error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); - return undefined; - } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); + return unknownType; } return type; } + // Get type from reference to type alias. When a type alias is generic, the declared type of the type alias may include + // references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the + // declared type. Instantiations are cached using the type identities of the type arguments as the key. + function getTypeFromTypeAliasReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var links = getSymbolLinks(symbol); + var typeParameters = links.typeParameters; + if (typeParameters) { + if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); + return unknownType; + } + var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); + var id = getTypeListId(typeArguments); + return links.instantiations[id] || (links.instantiations[id] = instantiateType(type, createTypeMapper(typeParameters, typeArguments))); + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); + return unknownType; + } + return type; + } + // Get type from reference to named type that cannot be generic (enum or type parameter) + function getTypeFromNonGenericTypeReference(node, symbol) { + if (symbol.flags & 262144 /* TypeParameter */ && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { + // TypeScript 1.0 spec (April 2014): 3.4.1 + // Type parameters declared in a particular type parameter list + // may not be referenced in constraints in that type parameter list + // Implementation: such type references are resolved to 'unknown' type that usually denotes error + return unknownType; + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); + return unknownType; + } + return getDeclaredTypeOfSymbol(symbol); + } + function getTypeFromTypeReference(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + // We only support expressions that are simple qualified names. For other expressions this produces undefined. + var typeNameOrExpression = node.kind === 144 /* TypeReference */ ? node.typeName : + ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : + undefined; + var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; + var type = symbol === unknownSymbol ? unknownType : + symbol.flags & (32 /* Class */ | 64 /* Interface */) ? getTypeFromClassOrInterfaceReference(node, symbol) : + symbol.flags & 524288 /* TypeAlias */ ? getTypeFromTypeAliasReference(node, symbol) : + getTypeFromNonGenericTypeReference(node, symbol); + // Cache both the resolved symbol and the resolved type. The resolved symbol is needed in when we check the + // type reference in checkTypeReferenceOrExpressionWithTypeArguments. + links.resolvedSymbol = symbol; + links.resolvedType = type; + } + return links.resolvedType; + } function getTypeFromTypeQueryNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { @@ -15082,7 +15557,7 @@ var ts; // The expression is processed as an identifier expression (section 4.3) // or property access expression(section 4.10), // the widened type(section 3.9) of which becomes the result. - links.resolvedType = getWidenedType(checkExpressionOrQualifiedName(node.exprName)); + links.resolvedType = getWidenedType(checkExpression(node.exprName)); } return links.resolvedType; } @@ -15092,9 +15567,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: return declaration; } } @@ -15307,40 +15782,42 @@ var ts; switch (node.kind) { case 112 /* AnyKeyword */: return anyType; - case 122 /* StringKeyword */: + case 123 /* StringKeyword */: return stringType; - case 120 /* NumberKeyword */: + case 121 /* NumberKeyword */: return numberType; case 113 /* BooleanKeyword */: return booleanType; - case 123 /* SymbolKeyword */: + case 124 /* SymbolKeyword */: return esSymbolType; case 99 /* VoidKeyword */: return voidType; case 8 /* StringLiteral */: return getTypeFromStringLiteral(node); - case 142 /* TypeReference */: - return getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); - case 177 /* ExpressionWithTypeArguments */: - return getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); - case 145 /* TypeQuery */: + case 144 /* TypeReference */: + return getTypeFromTypeReference(node); + case 143 /* TypePredicate */: + return booleanType; + case 179 /* ExpressionWithTypeArguments */: + return getTypeFromTypeReference(node); + case 147 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 147 /* ArrayType */: + case 149 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 148 /* TupleType */: + case 150 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 149 /* UnionType */: + case 151 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 150 /* ParenthesizedType */: + case 152 /* ParenthesizedType */: return getTypeFromTypeNode(node.type); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 146 /* TypeLiteral */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 148 /* TypeLiteral */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode case 65 /* Identifier */: - case 127 /* QualifiedName */: + case 128 /* QualifiedName */: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -15430,11 +15907,19 @@ var ts; } function instantiateSignature(signature, mapper, eraseTypeParameters) { var freshTypeParameters; + var freshTypePredicate; if (signature.typeParameters && !eraseTypeParameters) { freshTypeParameters = instantiateList(signature.typeParameters, mapper, instantiateTypeParameter); mapper = combineTypeMappers(createTypeMapper(signature.typeParameters, freshTypeParameters), mapper); } - var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + if (signature.typePredicate) { + freshTypePredicate = { + parameterName: signature.typePredicate.parameterName, + parameterIndex: signature.typePredicate.parameterIndex, + type: instantiateType(signature.typePredicate.type, mapper) + }; + } + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -15499,27 +15984,27 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 135 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 155 /* ObjectLiteralExpression */: + case 157 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return node.operatorToken.kind === 49 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 225 /* PropertyAssignment */: + case 227 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -15527,14 +16012,14 @@ var ts; function isContextSensitiveFunctionLikeDeclaration(node) { return !node.typeParameters && node.parameters.length && !ts.forEach(node.parameters, function (p) { return p.type; }); } - function getTypeWithoutConstructors(type) { + function getTypeWithoutSignatures(type) { if (type.flags & 48128 /* ObjectType */) { var resolved = resolveObjectOrUnionTypeMembers(type); if (resolved.constructSignatures.length) { var result = createObjectType(32768 /* Anonymous */, type.symbol); result.members = resolved.members; result.properties = resolved.properties; - result.callSignatures = resolved.callSignatures; + result.callSignatures = emptyArray; result.constructSignatures = emptyArray; type = result; } @@ -15542,9 +16027,6 @@ var ts; return type; } // TYPE CHECKING - var subtypeRelation = {}; - var assignableRelation = {}; - var identityRelation = {}; function isTypeIdenticalTo(source, target) { return checkTypeRelatedTo(source, target, identityRelation, undefined); } @@ -15821,9 +16303,9 @@ var ts; maybeStack[depth][id] = 1 /* Succeeded */; depth++; var saveExpandingFlags = expandingFlags; - if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack)) + if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) expandingFlags |= 1; - if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack)) + if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth)) expandingFlags |= 2; var result; if (expandingFlags === 3) { @@ -15859,27 +16341,6 @@ var ts; } return result; } - // Return true if the given type is part of a deeply nested chain of generic instantiations. We consider this to be the case - // when structural type comparisons have been started for 10 or more instantiations of the same generic type. It is possible, - // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely expanding. - // Effectively, we will generate a false positive when two types are structurally equal to at least 10 levels, but unequal at - // some level beyond that. - function isDeeplyNestedGeneric(type, stack) { - // We track type references (created by createTypeReference) and instantiated types (created by instantiateType) - if (type.flags & (4096 /* Reference */ | 65536 /* Instantiated */) && depth >= 10) { - var symbol = type.symbol; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (t.flags & (4096 /* Reference */ | 65536 /* Instantiated */) && t.symbol === symbol) { - count++; - if (count >= 10) - return true; - } - } - } - return false; - } function propertiesRelatedTo(source, target, reportErrors) { if (relation === identityRelation) { return propertiesIdenticalTo(source, target); @@ -16060,6 +16521,33 @@ var ts; } result &= related; } + if (source.typePredicate && target.typePredicate) { + var hasDifferentParameterIndex = source.typePredicate.parameterIndex !== target.typePredicate.parameterIndex; + var hasDifferentTypes; + if (hasDifferentParameterIndex || + (hasDifferentTypes = !isTypeIdenticalTo(source.typePredicate.type, target.typePredicate.type))) { + if (reportErrors) { + var sourceParamText = source.typePredicate.parameterName; + var targetParamText = target.typePredicate.parameterName; + var sourceTypeText = typeToString(source.typePredicate.type); + var targetTypeText = typeToString(target.typePredicate.type); + if (hasDifferentParameterIndex) { + reportError(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceParamText, targetParamText); + } + else if (hasDifferentTypes) { + reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceTypeText, targetTypeText); + } + reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, sourceParamText + " is " + sourceTypeText, targetParamText + " is " + targetTypeText); + } + return 0 /* False */; + } + } + else if (!source.typePredicate && target.typePredicate) { + if (reportErrors) { + reportError(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); + } + return 0 /* False */; + } var t = getReturnTypeOfSignature(target); if (t === voidType) return result; @@ -16150,6 +16638,27 @@ var ts; return 0 /* False */; } } + // Return true if the given type is part of a deeply nested chain of generic instantiations. We consider this to be the case + // when structural type comparisons have been started for 10 or more instantiations of the same generic type. It is possible, + // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely expanding. + // Effectively, we will generate a false positive when two types are structurally equal to at least 10 levels, but unequal at + // some level beyond that. + function isDeeplyNestedGeneric(type, stack, depth) { + // We track type references (created by createTypeReference) and instantiated types (created by instantiateType) + if (type.flags & (4096 /* Reference */ | 65536 /* Instantiated */) && depth >= 5) { + var symbol = type.symbol; + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (t.flags & (4096 /* Reference */ | 65536 /* Instantiated */) && t.symbol === symbol) { + count++; + if (count >= 5) + return true; + } + } + } + return false; + } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypes) !== 0 /* False */; } @@ -16356,22 +16865,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 130 /* Parameter */: + case 131 /* Parameter */: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -16444,20 +16953,6 @@ var ts; } return false; } - function isWithinDepthLimit(type, stack) { - if (depth >= 5) { - var target_1 = type.target; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (t.flags & 4096 /* Reference */ && t.target === target_1) { - count++; - } - } - return count < 5; - } - return true; - } function inferFromTypes(source, target) { if (source === anyFunctionType) { return; @@ -16527,22 +17022,26 @@ var ts; else if (source.flags & 48128 /* ObjectType */ && (target.flags & (4096 /* Reference */ | 8192 /* Tuple */) || (target.flags & 32768 /* Anonymous */) && target.symbol && target.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */))) { // If source is an object type, and target is a type reference, a tuple type, the type of a method, or a type literal, infer from members - if (!isInProcess(source, target) && isWithinDepthLimit(source, sourceStack) && isWithinDepthLimit(target, targetStack)) { - if (depth === 0) { - sourceStack = []; - targetStack = []; - } - sourceStack[depth] = source; - targetStack[depth] = target; - depth++; - inferFromProperties(source, target); - inferFromSignatures(source, target, 0 /* Call */); - inferFromSignatures(source, target, 1 /* Construct */); - inferFromIndexTypes(source, target, 0 /* String */, 0 /* String */); - inferFromIndexTypes(source, target, 1 /* Number */, 1 /* Number */); - inferFromIndexTypes(source, target, 0 /* String */, 1 /* Number */); - depth--; + if (isInProcess(source, target)) { + return; } + if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { + return; + } + if (depth === 0) { + sourceStack = []; + targetStack = []; + } + sourceStack[depth] = source; + targetStack[depth] = target; + depth++; + inferFromProperties(source, target); + inferFromSignatures(source, target, 0 /* Call */); + inferFromSignatures(source, target, 1 /* Construct */); + inferFromIndexTypes(source, target, 0 /* String */, 0 /* String */); + inferFromIndexTypes(source, target, 1 /* Number */, 1 /* Number */); + inferFromIndexTypes(source, target, 0 /* String */, 1 /* Number */); + depth--; } } function inferFromProperties(source, target) { @@ -16567,7 +17066,17 @@ var ts; } function inferFromSignature(source, target) { forEachMatchingParameterType(source, target, inferFromTypes); - inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + if (source.typePredicate && target.typePredicate) { + if (target.typePredicate.parameterIndex === source.typePredicate.parameterIndex) { + // Return types from type predicates are treated as booleans. In order to infer types + // from type predicates we would need to infer using the type within the type predicate + // (i.e. 'Foo' from 'x is Foo'). + inferFromTypes(source.typePredicate.type, target.typePredicate.type); + } + } + else { + inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + } } function inferFromIndexTypes(source, target, sourceKind, targetKind) { var targetIndexType = getIndexTypeOfType(target, targetKind); @@ -16640,10 +17149,10 @@ var ts; // The expression is restricted to a single identifier or a sequence of identifiers separated by periods while (node) { switch (node.kind) { - case 145 /* TypeQuery */: + case 147 /* TypeQuery */: return true; case 65 /* Identifier */: - case 127 /* QualifiedName */: + case 128 /* QualifiedName */: node = node.parent; continue; default: @@ -16691,7 +17200,7 @@ var ts; function isAssignedInBinaryExpression(node) { if (node.operatorToken.kind >= 53 /* FirstAssignment */ && node.operatorToken.kind <= 64 /* LastAssignment */) { var n = node.left; - while (n.kind === 162 /* ParenthesizedExpression */) { + while (n.kind === 164 /* ParenthesizedExpression */) { n = n.expression; } if (n.kind === 65 /* Identifier */ && getResolvedSymbol(n) === symbol) { @@ -16708,46 +17217,46 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: return isAssignedInVariableDeclaration(node); - case 151 /* ObjectBindingPattern */: - case 152 /* ArrayBindingPattern */: - case 154 /* ArrayLiteralExpression */: - case 155 /* ObjectLiteralExpression */: - case 156 /* PropertyAccessExpression */: - case 157 /* ElementAccessExpression */: - case 158 /* CallExpression */: - case 159 /* NewExpression */: - case 161 /* TypeAssertionExpression */: - case 162 /* ParenthesizedExpression */: - case 168 /* PrefixUnaryExpression */: - case 165 /* DeleteExpression */: - case 166 /* TypeOfExpression */: - case 167 /* VoidExpression */: - case 169 /* PostfixUnaryExpression */: - case 171 /* ConditionalExpression */: - case 174 /* SpreadElementExpression */: - case 180 /* Block */: - case 181 /* VariableStatement */: - case 183 /* ExpressionStatement */: - case 184 /* IfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 192 /* ReturnStatement */: - case 193 /* WithStatement */: - case 194 /* SwitchStatement */: - case 221 /* CaseClause */: - case 222 /* DefaultClause */: - case 195 /* LabeledStatement */: - case 196 /* ThrowStatement */: - case 197 /* TryStatement */: - case 224 /* CatchClause */: + case 153 /* ObjectBindingPattern */: + case 154 /* ArrayBindingPattern */: + case 156 /* ArrayLiteralExpression */: + case 157 /* ObjectLiteralExpression */: + case 158 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: + case 163 /* TypeAssertionExpression */: + case 164 /* ParenthesizedExpression */: + case 170 /* PrefixUnaryExpression */: + case 167 /* DeleteExpression */: + case 168 /* TypeOfExpression */: + case 169 /* VoidExpression */: + case 171 /* PostfixUnaryExpression */: + case 173 /* ConditionalExpression */: + case 176 /* SpreadElementExpression */: + case 182 /* Block */: + case 183 /* VariableStatement */: + case 185 /* ExpressionStatement */: + case 186 /* IfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 194 /* ReturnStatement */: + case 195 /* WithStatement */: + case 196 /* SwitchStatement */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: + case 197 /* LabeledStatement */: + case 198 /* ThrowStatement */: + case 199 /* TryStatement */: + case 226 /* CatchClause */: return ts.forEachChild(node, isAssignedIn); } return false; @@ -16800,19 +17309,19 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 184 /* IfStatement */: + case 186 /* IfStatement */: // In a branch of an if statement, narrow based on controlling expression if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: // In a branch of a conditional expression, narrow based on controlling condition if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: // In the right operand of an && or ||, narrow based on left operand if (child === node.right) { if (node.operatorToken.kind === 48 /* AmpersandAmpersandToken */) { @@ -16823,14 +17332,14 @@ var ts; } } break; - case 228 /* SourceFile */: - case 206 /* ModuleDeclaration */: - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 136 /* Constructor */: + case 230 /* SourceFile */: + case 208 /* ModuleDeclaration */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 137 /* Constructor */: // Stop at the first containing function or module declaration break loop; } @@ -16847,7 +17356,7 @@ var ts; return type; function narrowTypeByEquality(type, expr, assumeTrue) { // Check that we have 'typeof ' on the left and string literal on the right - if (expr.left.kind !== 166 /* TypeOfExpression */ || expr.right.kind !== 8 /* StringLiteral */) { + if (expr.left.kind !== 168 /* TypeOfExpression */ || expr.right.kind !== 8 /* StringLiteral */) { return type; } var left = expr.left; @@ -16923,7 +17432,7 @@ var ts; var targetType; var prototypeProperty = getPropertyOfType(rightType, "prototype"); if (prototypeProperty) { - // Target type is type of the protoype property + // Target type is type of the prototype property var prototypePropertyType = getTypeOfSymbol(prototypeProperty); if (!isTypeAny(prototypePropertyType)) { targetType = prototypePropertyType; @@ -16943,14 +17452,36 @@ var ts; } } if (targetType) { - // Narrow to the target type if it's a subtype of the current type - if (isTypeSubtypeOf(targetType, type)) { - return targetType; - } - // If the current type is a union type, remove all constituents that aren't subtypes of the target. - if (type.flags & 16384 /* Union */) { - return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); })); + return getNarrowedType(type, targetType); + } + return type; + } + function getNarrowedType(originalType, narrowedTypeCandidate) { + // Narrow to the target type if it's a subtype of the current type + if (isTypeSubtypeOf(narrowedTypeCandidate, originalType)) { + return narrowedTypeCandidate; + } + // If the current type is a union type, remove all constituents that aren't subtypes of the target. + if (originalType.flags & 16384 /* Union */) { + return getUnionType(ts.filter(originalType.types, function (t) { return isTypeSubtypeOf(t, narrowedTypeCandidate); })); + } + return originalType; + } + function narrowTypeByTypePredicate(type, expr, assumeTrue) { + if (type.flags & 1 /* Any */) { + return type; + } + var signature = getResolvedSignature(expr); + if (signature.typePredicate && + expr.arguments[signature.typePredicate.parameterIndex] && + getSymbolAtLocation(expr.arguments[signature.typePredicate.parameterIndex]) === symbol) { + if (!assumeTrue) { + if (type.flags & 16384 /* Union */) { + return getUnionType(ts.filter(type.types, function (t) { return !isTypeSubtypeOf(t, signature.typePredicate.type); })); + } + return type; } + return getNarrowedType(type, signature.typePredicate.type); } return type; } @@ -16958,9 +17489,11 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 162 /* ParenthesizedExpression */: + case 160 /* CallExpression */: + return narrowTypeByTypePredicate(type, expr, assumeTrue); + case 164 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: var operator = expr.operatorToken.kind; if (operator === 30 /* EqualsEqualsEqualsToken */ || operator === 31 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -16975,7 +17508,7 @@ var ts; return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 168 /* PrefixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: if (expr.operator === 46 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -16992,7 +17525,7 @@ var ts; // will be bound to non-arrow function that contain this arrow function. This results in inconsistent behavior. // To avoid that we will give an error to users if they use arguments objects in arrow function so that they // can explicitly bound arguments objects - if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 164 /* ArrowFunction */ && languageVersion < 2 /* ES6 */) { + if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 166 /* ArrowFunction */ && languageVersion < 2 /* ES6 */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } if (symbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { @@ -17016,7 +17549,7 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 /* ES6 */ || (symbol.flags & 2 /* BlockScopedVariable */) === 0 || - symbol.valueDeclaration.parent.kind === 224 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 226 /* CatchClause */) { return; } // - check if binding is used in some function @@ -17025,12 +17558,12 @@ var ts; // nesting structure: // (variable declaration or binding element) -> variable declaration list -> container var container = symbol.valueDeclaration; - while (container.kind !== 200 /* VariableDeclarationList */) { + while (container.kind !== 202 /* VariableDeclarationList */) { container = container.parent; } // get the parent of variable declaration list container = container.parent; - if (container.kind === 181 /* VariableStatement */) { + if (container.kind === 183 /* VariableStatement */) { // if parent is variable statement - get its parent container = container.parent; } @@ -17049,9 +17582,9 @@ var ts; } } function captureLexicalThis(node, container) { - var classNode = container.parent && container.parent.kind === 202 /* ClassDeclaration */ ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 204 /* ClassDeclaration */ ? container.parent : undefined; getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 133 /* PropertyDeclaration */ || container.kind === 136 /* Constructor */) { + if (container.kind === 134 /* PropertyDeclaration */ || container.kind === 137 /* Constructor */) { getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } else { @@ -17064,39 +17597,39 @@ var ts; var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 164 /* ArrowFunction */) { + if (container.kind === 166 /* ArrowFunction */) { container = ts.getThisContainer(container, false); // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code needToCaptureLexicalThis = (languageVersion < 2 /* ES6 */); } switch (container.kind) { - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 136 /* Constructor */: + case 137 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: if (container.flags & 128 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } if (needToCaptureLexicalThis) { captureLexicalThis(node, container); } - var classNode = container.parent && container.parent.kind === 202 /* ClassDeclaration */ ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 204 /* ClassDeclaration */ ? container.parent : undefined; if (classNode) { var symbol = getSymbolOfNode(classNode); return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); @@ -17105,23 +17638,21 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 130 /* Parameter */) { + if (n.kind === 131 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 158 /* CallExpression */ && node.parent.expression === node; - var enclosingClass = ts.getAncestor(node, 202 /* ClassDeclaration */); - var baseClass; - if (enclosingClass && ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); - var baseTypes = getBaseTypes(classType); - baseClass = baseTypes.length && baseTypes[0]; - } - if (!baseClass) { - error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); + var isCallExpression = node.parent.kind === 160 /* CallExpression */ && node.parent.expression === node; + var classDeclaration = ts.getAncestor(node, 204 /* ClassDeclaration */); + var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); + var baseClassType = classType && getBaseTypes(classType)[0]; + if (!baseClassType) { + if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { + error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); + } return unknownType; } var container = ts.getSuperContainer(node, true); @@ -17131,7 +17662,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - canUseSuperExpression = container.kind === 136 /* Constructor */; + canUseSuperExpression = container.kind === 137 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -17140,28 +17671,28 @@ var ts; // - In a static member function or static member accessor // super property access might appear in arrow functions with arbitrary deep nesting needToCaptureLexicalThis = false; - while (container && container.kind === 164 /* ArrowFunction */) { + while (container && container.kind === 166 /* ArrowFunction */) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; } // topmost container must be something that is directly nested in the class declaration - if (container && container.parent && container.parent.kind === 202 /* ClassDeclaration */) { + if (container && container.parent && container.parent.kind === 204 /* ClassDeclaration */) { if (container.flags & 128 /* Static */) { canUseSuperExpression = - container.kind === 135 /* MethodDeclaration */ || - container.kind === 134 /* MethodSignature */ || - container.kind === 137 /* GetAccessor */ || - container.kind === 138 /* SetAccessor */; + container.kind === 136 /* MethodDeclaration */ || + container.kind === 135 /* MethodSignature */ || + container.kind === 138 /* GetAccessor */ || + container.kind === 139 /* SetAccessor */; } else { canUseSuperExpression = - container.kind === 135 /* MethodDeclaration */ || - container.kind === 134 /* MethodSignature */ || - container.kind === 137 /* GetAccessor */ || - container.kind === 138 /* SetAccessor */ || - container.kind === 133 /* PropertyDeclaration */ || - container.kind === 132 /* PropertySignature */ || - container.kind === 136 /* Constructor */; + container.kind === 136 /* MethodDeclaration */ || + container.kind === 135 /* MethodSignature */ || + container.kind === 138 /* GetAccessor */ || + container.kind === 139 /* SetAccessor */ || + container.kind === 134 /* PropertyDeclaration */ || + container.kind === 133 /* PropertySignature */ || + container.kind === 137 /* Constructor */; } } } @@ -17169,13 +17700,13 @@ var ts; var returnType; if ((container.flags & 128 /* Static */) || isCallExpression) { getNodeLinks(node).flags |= 32 /* SuperStatic */; - returnType = getTypeOfSymbol(baseClass.symbol); + returnType = getBaseConstructorTypeOfClass(classType); } else { getNodeLinks(node).flags |= 16 /* SuperInstance */; - returnType = baseClass; + returnType = baseClassType; } - if (container.kind === 136 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 137 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); returnType = unknownType; @@ -17189,7 +17720,7 @@ var ts; return returnType; } } - if (container && container.kind === 128 /* ComputedPropertyName */) { + if (container && container.kind === 129 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -17234,7 +17765,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 130 /* Parameter */) { + if (declaration.kind === 131 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -17269,8 +17800,8 @@ var ts; // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed if (functionDecl.type || - functionDecl.kind === 136 /* Constructor */ || - functionDecl.kind === 137 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 138 /* SetAccessor */))) { + functionDecl.kind === 137 /* Constructor */ || + functionDecl.kind === 138 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 139 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -17292,7 +17823,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 160 /* TaggedTemplateExpression */) { + if (template.parent.kind === 162 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -17423,34 +17954,34 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 199 /* VariableDeclaration */: - case 130 /* Parameter */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 153 /* BindingElement */: + case 201 /* VariableDeclaration */: + case 131 /* Parameter */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 155 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 164 /* ArrowFunction */: - case 192 /* ReturnStatement */: + case 166 /* ArrowFunction */: + case 194 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 173 /* YieldExpression */: + case 175 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: return getTypeFromTypeNode(parent.type); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 225 /* PropertyAssignment */: + case 227 /* PropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 178 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 172 /* TemplateExpression */); + case 180 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 174 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return getContextualType(parent); } return undefined; @@ -17467,7 +17998,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 163 /* FunctionExpression */ || node.kind === 164 /* ArrowFunction */; + return node.kind === 165 /* FunctionExpression */ || node.kind === 166 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -17481,7 +18012,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 135 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -17537,13 +18068,13 @@ var ts; // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 170 /* BinaryExpression */ && parent.operatorToken.kind === 53 /* EqualsToken */ && parent.left === node) { + if (parent.kind === 172 /* BinaryExpression */ && parent.operatorToken.kind === 53 /* EqualsToken */ && parent.left === node) { return true; } - if (parent.kind === 225 /* PropertyAssignment */) { + if (parent.kind === 227 /* PropertyAssignment */) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 154 /* ArrayLiteralExpression */) { + if (parent.kind === 156 /* ArrayLiteralExpression */) { return isAssignmentTarget(parent); } return false; @@ -17568,7 +18099,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 174 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 176 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -17592,7 +18123,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 174 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 176 /* SpreadElementExpression */; } if (!hasSpreadElement) { var contextualType = getContextualType(node); @@ -17603,7 +18134,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 128 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 129 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, @@ -17662,18 +18193,18 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 225 /* PropertyAssignment */ || - memberDecl.kind === 226 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 227 /* PropertyAssignment */ || + memberDecl.kind === 228 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 225 /* PropertyAssignment */) { + if (memberDecl.kind === 227 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 135 /* MethodDeclaration */) { + else if (memberDecl.kind === 136 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 226 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 228 /* ShorthandPropertyAssignment */); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -17693,7 +18224,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 137 /* GetAccessor */ || memberDecl.kind === 138 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 138 /* GetAccessor */ || memberDecl.kind === 139 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -17732,7 +18263,7 @@ var ts; // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 133 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 134 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; @@ -17745,7 +18276,7 @@ var ts; } // Property is known to be private or protected at this point // Get the declaring and enclosing class instance types - var enclosingClassDeclaration = ts.getAncestor(node, 202 /* ClassDeclaration */); + var enclosingClassDeclaration = ts.getAncestor(node, 204 /* ClassDeclaration */); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; var declaringClass = getDeclaredTypeOfSymbol(prop.parent); // Private property is accessible if declaring and enclosing class are the same @@ -17781,7 +18312,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { - var type = checkExpressionOrQualifiedName(left); + var type = checkExpression(left); if (isTypeAny(type)) { return type; } @@ -17806,7 +18337,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 135 /* MethodDeclaration */) { + if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 136 /* MethodDeclaration */) { error(right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); } else { @@ -17816,14 +18347,14 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 156 /* PropertyAccessExpression */ + var left = node.kind === 158 /* PropertyAccessExpression */ ? node.expression : node.left; - var type = checkExpressionOrQualifiedName(left); + var type = checkExpression(left); if (type !== unknownType && !isTypeAny(type)) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32 /* Class */) { - if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 135 /* MethodDeclaration */) { + if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 136 /* MethodDeclaration */) { return false; } else { @@ -17839,7 +18370,7 @@ var ts; // Grammar checking if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 159 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 161 /* NewExpression */ && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -17968,7 +18499,7 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 160 /* TaggedTemplateExpression */) { + if (node.kind === 162 /* TaggedTemplateExpression */) { checkExpression(node.template); } else { @@ -18036,7 +18567,7 @@ var ts; } function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { - if (args[i].kind === 174 /* SpreadElementExpression */) { + if (args[i].kind === 176 /* SpreadElementExpression */) { return i; } } @@ -18046,13 +18577,13 @@ var ts; var adjustedArgCount; // Apparent number of arguments we will have in this call var typeArguments; // Type arguments (undefined if none) var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments - if (node.kind === 160 /* TaggedTemplateExpression */) { + if (node.kind === 162 /* TaggedTemplateExpression */) { var tagExpression = node; // Even if the call is incomplete, we'll have a missing expression as our last argument, // so we can say the count is just the arg list length adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 172 /* TemplateExpression */) { + if (tagExpression.template.kind === 174 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var templateExpression = tagExpression.template; @@ -18073,7 +18604,7 @@ var ts; var callExpression = node; if (!callExpression.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(callExpression.kind === 159 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 161 /* NewExpression */); return signature.minArgumentCount === 0; } // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. @@ -18150,10 +18681,10 @@ var ts; // wildcards for all context sensitive function expressions. for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg.kind !== 176 /* OmittedExpression */) { + if (arg.kind !== 178 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = void 0; - if (i === 0 && args[i].parent.kind === 160 /* TaggedTemplateExpression */) { + if (i === 0 && args[i].parent.kind === 162 /* TaggedTemplateExpression */) { argType = globalTemplateStringsArrayType; } else { @@ -18200,12 +18731,12 @@ var ts; function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg.kind !== 176 /* OmittedExpression */) { + if (arg.kind !== 178 /* OmittedExpression */) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) var paramType = getTypeAtPosition(signature, i); // A tagged template expression provides a special first argument, and string literals get string literal types // unless we're reporting errors - var argType = i === 0 && node.kind === 160 /* TaggedTemplateExpression */ + var argType = i === 0 && node.kind === 162 /* TaggedTemplateExpression */ ? globalTemplateStringsArrayType : arg.kind === 8 /* StringLiteral */ && !reportErrors ? getStringLiteralType(arg) @@ -18227,10 +18758,10 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 160 /* TaggedTemplateExpression */) { + if (node.kind === 162 /* TaggedTemplateExpression */) { var template = node.template; args = [template]; - if (template.kind === 172 /* TemplateExpression */) { + if (template.kind === 174 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); @@ -18241,32 +18772,11 @@ var ts; } return args; } - /** - * In a 'super' call, type arguments are not provided within the CallExpression node itself. - * Instead, they must be fetched from the class declaration's base type node. - * - * If 'node' is a 'super' call (e.g. super(...), new super(...)), then we attempt to fetch - * the type arguments off the containing class's first heritage clause (if one exists). Note that if - * type arguments are supplied on the 'super' call, they are ignored (though this is syntactically incorrect). - * - * In all other cases, the call's explicit type arguments are returned. - */ - function getEffectiveTypeArguments(callExpression) { - if (callExpression.expression.kind === 91 /* SuperKeyword */) { - var containingClass = ts.getAncestor(callExpression, 202 /* ClassDeclaration */); - var baseClassTypeNode = containingClass && ts.getClassExtendsHeritageClauseElement(containingClass); - return baseClassTypeNode && baseClassTypeNode.typeArguments; - } - else { - // Ordinary case - simple function invocation. - return callExpression.typeArguments; - } - } function resolveCall(node, signatures, candidatesOutArray) { - var isTaggedTemplate = node.kind === 160 /* TaggedTemplateExpression */; + var isTaggedTemplate = node.kind === 162 /* TaggedTemplateExpression */; var typeArguments; if (!isTaggedTemplate) { - typeArguments = getEffectiveTypeArguments(node); + typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. if (node.expression.kind !== 91 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); @@ -18361,8 +18871,8 @@ var ts; checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); } else if (candidateForTypeArgumentError) { - if (!isTaggedTemplate && node.typeArguments) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], true); + if (!isTaggedTemplate && typeArguments) { + checkTypeArguments(candidateForTypeArgumentError, typeArguments, [], true); } else { ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); @@ -18456,7 +18966,11 @@ var ts; if (node.expression.kind === 91 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { - return resolveCall(node, getSignaturesOfType(superType, 1 /* Construct */), candidatesOutArray); + // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated + // with the type arguments specified in the extends clause. + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getAncestor(node, 204 /* ClassDeclaration */)); + var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + return resolveCall(node, baseConstructors, candidatesOutArray); } return resolveUntypedCall(node); } @@ -18578,13 +19092,13 @@ var ts; // to correctly fill the candidatesOutArray. if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 158 /* CallExpression */) { + if (node.kind === 160 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 159 /* NewExpression */) { + else if (node.kind === 161 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 160 /* TaggedTemplateExpression */) { + else if (node.kind === 162 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } else { @@ -18600,12 +19114,12 @@ var ts; if (node.expression.kind === 91 /* SuperKeyword */) { return voidType; } - if (node.kind === 159 /* NewExpression */) { + if (node.kind === 161 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 136 /* Constructor */ && - declaration.kind !== 140 /* ConstructSignature */ && - declaration.kind !== 144 /* ConstructorType */) { + declaration.kind !== 137 /* Constructor */ && + declaration.kind !== 141 /* ConstructSignature */ && + declaration.kind !== 146 /* ConstructorType */) { // When resolved signature is a call signature (and not a construct signature) the result type is any if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); @@ -18653,7 +19167,7 @@ var ts; return unknownType; } var type; - if (func.body.kind !== 180 /* Block */) { + if (func.body.kind !== 182 /* Block */) { type = checkExpressionCached(func.body, contextualMapper); } else { @@ -18733,7 +19247,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 196 /* ThrowStatement */); + return (body.statements.length === 1) && (body.statements[0].kind === 198 /* ThrowStatement */); } // TypeScript Specification 1.0 (6.3) - July 2014 // An explicitly typed function whose return type isn't the Void or the Any type @@ -18748,7 +19262,7 @@ var ts; return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. - if (ts.nodeIsMissing(func.body) || func.body.kind !== 180 /* Block */) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 182 /* Block */) { return; } var bodyBlock = func.body; @@ -18766,11 +19280,11 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 135 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking - var hasGrammarError = checkGrammarDeclarationNameInStrictMode(node) || checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 163 /* FunctionExpression */) { - checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node); + var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); + if (!hasGrammarError && node.kind === 165 /* FunctionExpression */) { + checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -18801,14 +19315,14 @@ var ts; checkSignatureDeclaration(node); } } - if (produceDiagnostics && node.kind !== 135 /* MethodDeclaration */ && node.kind !== 134 /* MethodSignature */) { + if (produceDiagnostics && node.kind !== 136 /* MethodDeclaration */ && node.kind !== 135 /* MethodSignature */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 135 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); if (node.type && !node.asteriskToken) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); } @@ -18821,7 +19335,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 180 /* Block */) { + if (node.body.kind === 182 /* Block */) { checkSourceElement(node.body); } else { @@ -18863,17 +19377,17 @@ var ts; // An identifier expression that references any other kind of entity is classified as a value(and therefore cannot be the target of an assignment). return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; } - case 156 /* PropertyAccessExpression */: { + case 158 /* PropertyAccessExpression */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.10 // A property access expression is always classified as a reference. // NOTE (not in spec): assignment to enum members should not be allowed return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; } - case 157 /* ElementAccessExpression */: + case 159 /* ElementAccessExpression */: // old compiler doesn't check indexed assess return true; - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -18882,11 +19396,11 @@ var ts; function isConstVariableReference(n) { switch (n.kind) { case 65 /* Identifier */: - case 156 /* PropertyAccessExpression */: { + case 158 /* PropertyAccessExpression */: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 8192 /* Const */) !== 0; } - case 157 /* ElementAccessExpression */: { + case 159 /* ElementAccessExpression */: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 8 /* StringLiteral */) { @@ -18896,7 +19410,7 @@ var ts; } return false; } - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return isConstVariableReference(n.expression); default: return false; @@ -18913,13 +19427,7 @@ var ts; return true; } function checkDeleteExpression(node) { - // Grammar checking - if (node.parserContextFlags & 1 /* StrictMode */ && node.expression.kind === 65 /* Identifier */) { - // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its - // UnaryExpression is a direct reference to a variable, function argument, or function name - grammarErrorOnNode(node.expression, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); - } - var operandType = checkExpression(node.expression); + checkExpression(node.expression); return booleanType; } function checkTypeOfExpression(node) { @@ -18931,13 +19439,6 @@ var ts; return undefinedType; } function checkPrefixUnaryExpression(node) { - // Grammar checking - // The identifier eval or arguments may not appear as the LeftHandSideExpression of an - // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression - // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator - if ((node.operator === 38 /* PlusPlusToken */ || node.operator === 39 /* MinusMinusToken */)) { - checkGrammarEvalOrArgumentsInStrictMode(node, node.operand); - } var operandType = checkExpression(node.operand); switch (node.operator) { case 33 /* PlusToken */: @@ -18961,11 +19462,6 @@ var ts; return unknownType; } function checkPostfixUnaryExpression(node) { - // Grammar checking - // The identifier eval or arguments may not appear as the LeftHandSideExpression of an - // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression - // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator. - checkGrammarEvalOrArgumentsInStrictMode(node, node.operand); var operandType = checkExpression(node.operand); var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { @@ -19047,7 +19543,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 225 /* PropertyAssignment */ || p.kind === 226 /* ShorthandPropertyAssignment */) { + if (p.kind === 227 /* PropertyAssignment */ || p.kind === 228 /* ShorthandPropertyAssignment */) { // TODO(andersh): Computed property support var name_12 = p.name; var type = isTypeAny(sourceType) @@ -19076,8 +19572,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 176 /* OmittedExpression */) { - if (e.kind !== 174 /* SpreadElementExpression */) { + if (e.kind !== 178 /* OmittedExpression */) { + if (e.kind !== 176 /* SpreadElementExpression */) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -19102,7 +19598,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 170 /* BinaryExpression */ && restExpression.operatorToken.kind === 53 /* EqualsToken */) { + if (restExpression.kind === 172 /* BinaryExpression */ && restExpression.operatorToken.kind === 53 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -19115,14 +19611,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 170 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { + if (target.kind === 172 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 155 /* ObjectLiteralExpression */) { + if (target.kind === 157 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 154 /* ArrayLiteralExpression */) { + if (target.kind === 156 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -19135,14 +19631,8 @@ var ts; return sourceType; } function checkBinaryExpression(node, contextualMapper) { - // Grammar checking - if (ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) { - // ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an - // Assignment operator(11.13) or of a PostfixExpression(11.3) - checkGrammarEvalOrArgumentsInStrictMode(node, node.left); - } var operator = node.operatorToken.kind; - if (operator === 53 /* EqualsToken */ && (node.left.kind === 155 /* ObjectLiteralExpression */ || node.left.kind === 154 /* ArrayLiteralExpression */)) { + if (operator === 53 /* EqualsToken */ && (node.left.kind === 157 /* ObjectLiteralExpression */ || node.left.kind === 156 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); @@ -19317,7 +19807,7 @@ var ts; if (ts.isFunctionLike(parent) && current === parent.body) { return false; } - else if (current.kind === 202 /* ClassDeclaration */ || current.kind === 175 /* ClassExpression */) { + else if (current.kind === 204 /* ClassDeclaration */ || current.kind === 177 /* ClassExpression */) { return true; } current = parent; @@ -19393,7 +19883,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 128 /* ComputedPropertyName */) { + if (node.name.kind === 129 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); @@ -19404,7 +19894,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 128 /* ComputedPropertyName */) { + if (node.name.kind === 129 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -19425,10 +19915,6 @@ var ts; } return type; } - function checkExpression(node, contextualMapper) { - checkGrammarIdentifierInStrictMode(node); - return checkExpressionOrQualifiedName(node, contextualMapper); - } // Checks an expression and returns its type. The contextualMapper parameter serves two purposes: When // contextualMapper is not undefined and not equal to the identityMapper function object it indicates that the // expression is being inferentially typed (section 4.12.2 in spec) and provides the type mapper to use in @@ -19436,9 +19922,9 @@ var ts; // object, it serves as an indicator that all contained function and arrow expressions should be considered to // have the wildcard function type; this form of type check is used during overload resolution to exclude // contextually typed function and arrow expressions in the initial phase. - function checkExpressionOrQualifiedName(node, contextualMapper) { + function checkExpression(node, contextualMapper) { var type; - if (node.kind == 127 /* QualifiedName */) { + if (node.kind === 128 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -19450,9 +19936,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 156 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 157 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 65 /* Identifier */ || node.kind === 127 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 158 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 159 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 65 /* Identifier */ || node.kind === 128 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -19479,61 +19965,60 @@ var ts; return booleanType; case 7 /* NumericLiteral */: return checkNumericLiteral(node); - case 172 /* TemplateExpression */: + case 174 /* TemplateExpression */: return checkTemplateExpression(node); case 8 /* StringLiteral */: case 10 /* NoSubstitutionTemplateLiteral */: return stringType; case 9 /* RegularExpressionLiteral */: return globalRegExpType; - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 155 /* ObjectLiteralExpression */: + case 157 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 156 /* PropertyAccessExpression */: + case 158 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 157 /* ElementAccessExpression */: + case 159 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: return checkCallExpression(node); - case 160 /* TaggedTemplateExpression */: + case 162 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: return checkTypeAssertion(node); - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 175 /* ClassExpression */: + case 177 /* ClassExpression */: return checkClassExpression(node); - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 166 /* TypeOfExpression */: + case 168 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 165 /* DeleteExpression */: + case 167 /* DeleteExpression */: return checkDeleteExpression(node); - case 167 /* VoidExpression */: + case 169 /* VoidExpression */: return checkVoidExpression(node); - case 168 /* PrefixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 169 /* PostfixUnaryExpression */: + case 171 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 174 /* SpreadElementExpression */: + case 176 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 176 /* OmittedExpression */: + case 178 /* OmittedExpression */: return undefinedType; - case 173 /* YieldExpression */: + case 175 /* YieldExpression */: return checkYieldExpression(node); } return unknownType; } // DECLARATION AND STATEMENT TYPE CHECKING function checkTypeParameter(node) { - checkGrammarDeclarationNameInStrictMode(node); // Grammar Checking if (node.expression) { grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); @@ -19550,15 +20035,13 @@ var ts; // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the // Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code // or if its FunctionBody is strict code(11.1.5). - // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a - // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEvalOrArgumentsInStrictMode(node, node.name); + checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (node.flags & 112 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 136 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 137 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -19575,33 +20058,107 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 135 /* MethodDeclaration */ || - node.kind === 201 /* FunctionDeclaration */ || - node.kind === 163 /* FunctionExpression */; + return node.kind === 136 /* MethodDeclaration */ || + node.kind === 203 /* FunctionDeclaration */ || + node.kind === 165 /* FunctionExpression */; + } + function getTypePredicateParameterIndex(parameterList, parameter) { + if (parameterList) { + for (var i = 0; i < parameterList.length; i++) { + var param = parameterList[i]; + if (param.name.kind === 65 /* Identifier */ && + param.name.text === parameter.text) { + return i; + } + } + } + return -1; + } + function isInLegalTypePredicatePosition(node) { + switch (node.parent.kind) { + case 166 /* ArrowFunction */: + case 140 /* CallSignature */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 145 /* FunctionType */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + return node === node.parent.type; + } + return false; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 141 /* IndexSignature */) { + if (node.kind === 142 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 143 /* FunctionType */ || node.kind === 201 /* FunctionDeclaration */ || node.kind === 144 /* ConstructorType */ || - node.kind === 139 /* CallSignature */ || node.kind === 136 /* Constructor */ || - node.kind === 140 /* ConstructSignature */) { + else if (node.kind === 145 /* FunctionType */ || node.kind === 203 /* FunctionDeclaration */ || node.kind === 146 /* ConstructorType */ || + node.kind === 140 /* CallSignature */ || node.kind === 137 /* Constructor */ || + node.kind === 141 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - checkSourceElement(node.type); + if (node.type.kind === 143 /* TypePredicate */) { + var typePredicate = getSignatureFromDeclaration(node).typePredicate; + var typePredicateNode = node.type; + if (isInLegalTypePredicatePosition(typePredicateNode)) { + if (typePredicate.parameterIndex >= 0) { + if (node.parameters[typePredicate.parameterIndex].dotDotDotToken) { + error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); + } + else { + checkTypeAssignableTo(typePredicate.type, getTypeAtLocation(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); + } + } + else if (typePredicateNode.parameterName) { + var hasReportedError = false; + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var param = _a[_i]; + if (hasReportedError) { + break; + } + if (param.name.kind === 153 /* ObjectBindingPattern */ || + param.name.kind === 154 /* ArrayBindingPattern */) { + (function checkBindingPattern(pattern) { + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.name.kind === 65 /* Identifier */ && + element.name.text === typePredicate.parameterName) { + error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); + hasReportedError = true; + break; + } + else if (element.name.kind === 154 /* ArrayBindingPattern */ || + element.name.kind === 153 /* ObjectBindingPattern */) { + checkBindingPattern(element.name); + } + } + })(param.name); + } + } + if (!hasReportedError) { + error(typePredicateNode.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName); + } + } + } + else { + error(typePredicateNode, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + } + } + else { + checkSourceElement(node.type); + } } if (produceDiagnostics) { checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 140 /* ConstructSignature */: + case 141 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 139 /* CallSignature */: + case 140 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -19629,7 +20186,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 203 /* InterfaceDeclaration */) { + if (node.kind === 205 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -19649,7 +20206,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 122 /* StringKeyword */: + case 123 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -19657,7 +20214,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 120 /* NumberKeyword */: + case 121 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -19701,17 +20258,17 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 158 /* CallExpression */ && n.expression.kind === 91 /* SuperKeyword */; + return n.kind === 160 /* CallExpression */ && n.expression.kind === 91 /* SuperKeyword */; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 163 /* FunctionExpression */: - case 201 /* FunctionDeclaration */: - case 164 /* ArrowFunction */: - case 155 /* ObjectLiteralExpression */: return false; + case 165 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: + case 166 /* ArrowFunction */: + case 157 /* ObjectLiteralExpression */: return false; default: return ts.forEachChild(n, containsSuperCall); } } @@ -19719,12 +20276,12 @@ var ts; if (n.kind === 93 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 163 /* FunctionExpression */ && n.kind !== 201 /* FunctionDeclaration */) { + else if (n.kind !== 165 /* FunctionExpression */ && n.kind !== 203 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 133 /* PropertyDeclaration */ && + return n.kind === 134 /* PropertyDeclaration */ && !(n.flags & 128 /* Static */) && !!n.initializer; } @@ -19741,7 +20298,7 @@ var ts; ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 183 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 185 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -19759,7 +20316,7 @@ var ts; if (produceDiagnostics) { // Grammar checking accessors checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 137 /* GetAccessor */) { + if (node.kind === 138 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } @@ -19767,7 +20324,7 @@ var ts; if (!ts.hasDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 137 /* GetAccessor */ ? 138 /* SetAccessor */ : 137 /* GetAccessor */; + var otherKind = node.kind === 138 /* GetAccessor */ ? 139 /* SetAccessor */ : 138 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { @@ -19791,28 +20348,27 @@ var ts; function checkMissingDeclaration(node) { checkDecorators(node); } + function checkTypeArgumentConstraints(typeParameters, typeArguments) { + var result = true; + for (var i = 0; i < typeParameters.length; i++) { + var constraint = getConstraintOfTypeParameter(typeParameters[i]); + if (constraint) { + var typeArgument = typeArguments[i]; + result = result && checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, typeArgument, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + } + } + return result; + } function checkTypeReferenceNode(node) { - checkGrammarTypeReferenceInStrictMode(node.typeName); - return checkTypeReferenceOrExpressionWithTypeArguments(node); - } - function checkExpressionWithTypeArguments(node) { - checkGrammarExpressionWithTypeArgumentsInStrictMode(node.expression); - return checkTypeReferenceOrExpressionWithTypeArguments(node); - } - function checkTypeReferenceOrExpressionWithTypeArguments(node) { - // Grammar checking checkGrammarTypeArguments(node, node.typeArguments); - var type = getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); + var type = getTypeFromTypeReference(node); if (type !== unknownType && node.typeArguments) { // Do type argument local checks only if referenced type is successfully resolved - var len = node.typeArguments.length; - for (var i = 0; i < len; i++) { - checkSourceElement(node.typeArguments[i]); - var constraint = getConstraintOfTypeParameter(type.target.typeParameters[i]); - if (produceDiagnostics && constraint) { - var typeArgument = type.typeArguments[i]; - checkTypeAssignableTo(typeArgument, constraint, node, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); - } + ts.forEach(node.typeArguments, checkSourceElement); + if (produceDiagnostics) { + var symbol = getNodeLinks(node).resolvedSymbol; + var typeParameters = symbol.flags & 524288 /* TypeAlias */ ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; + checkTypeArgumentConstraints(typeParameters, node.typeArguments); } } } @@ -19864,9 +20420,9 @@ var ts; var signaturesToCheck; // Unnamed (call\construct) signatures in interfaces are inherited and not shadowed so examining just node symbol won't give complete answer. // Use declaring type to obtain full list of signatures. - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 203 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 139 /* CallSignature */ || signatureDeclarationNode.kind === 140 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 139 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 205 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 140 /* CallSignature */ || signatureDeclarationNode.kind === 141 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 140 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -19884,7 +20440,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 203 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 205 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported flags |= 1 /* Export */; @@ -19967,7 +20523,7 @@ var ts; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members - ts.Debug.assert(node.kind === 135 /* MethodDeclaration */ || node.kind === 134 /* MethodSignature */); + ts.Debug.assert(node.kind === 136 /* MethodDeclaration */ || node.kind === 135 /* MethodSignature */); ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -19996,7 +20552,7 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 203 /* InterfaceDeclaration */ || node.parent.kind === 146 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 205 /* InterfaceDeclaration */ || node.parent.kind === 148 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -20007,7 +20563,7 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 201 /* FunctionDeclaration */ || node.kind === 135 /* MethodDeclaration */ || node.kind === 134 /* MethodSignature */ || node.kind === 136 /* Constructor */) { + if (node.kind === 203 /* FunctionDeclaration */ || node.kind === 136 /* MethodDeclaration */ || node.kind === 135 /* MethodSignature */ || node.kind === 137 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -20130,16 +20686,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return d.name.kind === 8 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -20154,23 +20710,23 @@ var ts; var expression = node.expression; var exprType = checkExpression(expression); switch (node.parent.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); var classDecoratorType = instantiateSingleCallFunctionType(getGlobalClassDecoratorType(), [classConstructorType]); checkTypeAssignableTo(exprType, classDecoratorType, node); break; - case 133 /* PropertyDeclaration */: + case 134 /* PropertyDeclaration */: checkTypeAssignableTo(exprType, getGlobalPropertyDecoratorType(), node); break; - case 135 /* MethodDeclaration */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 136 /* MethodDeclaration */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var methodDecoratorType = instantiateSingleCallFunctionType(getGlobalMethodDecoratorType(), [methodType]); checkTypeAssignableTo(exprType, methodDecoratorType, node); break; - case 130 /* Parameter */: + case 131 /* Parameter */: checkTypeAssignableTo(exprType, getGlobalParameterDecoratorType(), node); break; } @@ -20180,14 +20736,14 @@ var ts; // When we are emitting type metadata for decorators, we need to try to check the type // as if it were an expression so that we can emit the type in a value position when we // serialize the type metadata. - if (node && node.kind === 142 /* TypeReference */) { + if (node && node.kind === 144 /* TypeReference */) { var type = getTypeFromTypeNode(node); var shouldCheckIfUnknownType = type === unknownType && compilerOptions.isolatedModules; if (!type || (!shouldCheckIfUnknownType && type.flags & (2097279 /* Intrinsic */ | 132 /* NumberLike */ | 258 /* StringLike */))) { return; } if (shouldCheckIfUnknownType || type.symbol.valueDeclaration) { - checkExpressionOrQualifiedName(node.typeName); + checkExpression(node.typeName); } } } @@ -20197,19 +20753,19 @@ var ts; */ function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 133 /* PropertyDeclaration */: + case 134 /* PropertyDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 130 /* Parameter */: + case 131 /* Parameter */: checkTypeNodeAsExpression(node.type); break; - case 135 /* MethodDeclaration */: + case 136 /* MethodDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 137 /* GetAccessor */: + case 138 /* GetAccessor */: checkTypeNodeAsExpression(node.type); break; - case 138 /* SetAccessor */: + case 139 /* SetAccessor */: checkTypeNodeAsExpression(getSetAccessorTypeAnnotationNode(node)); break; } @@ -20238,47 +20794,44 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 135 /* MethodDeclaration */: + case 136 /* MethodDeclaration */: checkParameterTypeAnnotationsAsExpressions(node); // fall-through - case 138 /* SetAccessor */: - case 137 /* GetAccessor */: - case 133 /* PropertyDeclaration */: - case 130 /* Parameter */: + case 139 /* SetAccessor */: + case 138 /* GetAccessor */: + case 134 /* PropertyDeclaration */: + case 131 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 130 /* Parameter */) { + if (node.kind === 131 /* Parameter */) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); } function checkFunctionDeclaration(node) { if (produceDiagnostics) { - checkFunctionLikeDeclaration(node) || - checkGrammarFunctionName(node.name) || - checkGrammarForGenerator(node); + checkFunctionLikeDeclaration(node) || checkGrammarForGenerator(node); checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); } } function checkFunctionLikeDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSignatureDeclaration(node); // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 128 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 129 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -20322,11 +20875,11 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 180 /* Block */) { + if (node.kind === 182 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 207 /* ModuleBlock */) { + if (ts.isFunctionBlock(node) || node.kind === 209 /* ModuleBlock */) { checkFunctionExpressionBodies(node); } } @@ -20345,12 +20898,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 133 /* PropertyDeclaration */ || - node.kind === 132 /* PropertySignature */ || - node.kind === 135 /* MethodDeclaration */ || - node.kind === 134 /* MethodSignature */ || - node.kind === 137 /* GetAccessor */ || - node.kind === 138 /* SetAccessor */) { + if (node.kind === 134 /* PropertyDeclaration */ || + node.kind === 133 /* PropertySignature */ || + node.kind === 136 /* MethodDeclaration */ || + node.kind === 135 /* MethodSignature */ || + node.kind === 138 /* GetAccessor */ || + node.kind === 139 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -20359,7 +20912,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 130 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 131 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -20392,7 +20945,7 @@ var ts; return; } // bubble up and find containing type - var enclosingClass = ts.getAncestor(node, 202 /* ClassDeclaration */); + var enclosingClass = ts.getAncestor(node, 204 /* ClassDeclaration */); // if containing type was not found or it is ambient - exit (no codegen) if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { return; @@ -20412,12 +20965,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 206 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 208 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 228 /* SourceFile */ && ts.isExternalModule(parent)) { + if (parent.kind === 230 /* SourceFile */ && ts.isExternalModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -20452,7 +21005,7 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 199 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 201 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -20462,17 +21015,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 12288 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 200 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 181 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 202 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 183 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 180 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 207 /* ModuleBlock */ || - container.kind === 206 /* ModuleDeclaration */ || - container.kind === 228 /* SourceFile */); + (container.kind === 182 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 209 /* ModuleBlock */ || + container.kind === 208 /* ModuleDeclaration */ || + container.kind === 230 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -20487,7 +21040,7 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 130 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 131 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -20498,7 +21051,7 @@ var ts; // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name and if this entry matches the resolved symbol if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 130 /* Parameter */) { + if (referencedSymbol.valueDeclaration.kind === 131 /* Parameter */) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -20518,14 +21071,13 @@ var ts; } // Check variable, parameter, or property declaration function checkVariableLikeDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSourceElement(node.type); // For a computed property, just check the initializer and exit // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 128 /* ComputedPropertyName */) { + if (node.name.kind === 129 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -20536,7 +21088,7 @@ var ts; ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 130 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 131 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -20568,10 +21120,10 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 133 /* PropertyDeclaration */ && node.kind !== 132 /* PropertySignature */) { + if (node.kind !== 134 /* PropertyDeclaration */ && node.kind !== 133 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 199 /* VariableDeclaration */ || node.kind === 153 /* BindingElement */) { + if (node.kind === 201 /* VariableDeclaration */ || node.kind === 155 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -20601,7 +21153,7 @@ var ts; } function inBlockOrObjectLiteralExpression(node) { while (node) { - if (node.kind === 180 /* Block */ || node.kind === 155 /* ObjectLiteralExpression */) { + if (node.kind === 182 /* Block */ || node.kind === 157 /* ObjectLiteralExpression */) { return true; } node = node.parent; @@ -20634,12 +21186,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind == 200 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 202 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 200 /* VariableDeclarationList */) { + if (node.initializer.kind === 202 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -20659,14 +21211,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 200 /* VariableDeclarationList */) { + if (node.initializer.kind === 202 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); // There may be a destructuring assignment on the left side - if (varExpr.kind === 154 /* ArrayLiteralExpression */ || varExpr.kind === 155 /* ObjectLiteralExpression */) { + if (varExpr.kind === 156 /* ArrayLiteralExpression */ || varExpr.kind === 157 /* ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -20695,7 +21247,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 200 /* VariableDeclarationList */) { + if (node.initializer.kind === 202 /* VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -20709,7 +21261,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 154 /* ArrayLiteralExpression */ || varExpr.kind === 155 /* ObjectLiteralExpression */) { + if (varExpr.kind === 156 /* ArrayLiteralExpression */ || varExpr.kind === 157 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */)) { @@ -20948,7 +21500,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 137 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 138 /* SetAccessor */))); + return !!(node.kind === 138 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 139 /* SetAccessor */))); } function checkReturnStatement(node) { // Grammar checking @@ -20961,7 +21513,8 @@ var ts; if (node.expression) { var func = ts.getContainingFunction(node); if (func) { - var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); + var signature = getSignatureFromDeclaration(func); + var returnType = getReturnTypeOfSignature(signature); var exprType = checkExpressionCached(node.expression); if (func.asteriskToken) { // A generator does not need its return expressions checked against its return type. @@ -20970,27 +21523,22 @@ var ts; // for generators. return; } - if (func.kind === 138 /* SetAccessor */) { + if (func.kind === 139 /* SetAccessor */) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 136 /* Constructor */) { + else if (func.kind === 137 /* Constructor */) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } - else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func)) { + else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { checkTypeAssignableTo(exprType, returnType, node.expression, undefined); } } } } function checkWithStatement(node) { - // Grammar checking for withStatement - if (!checkGrammarStatementInAmbientContext(node)) { - if (node.parserContextFlags & 1 /* StrictMode */) { - grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); - } - } + checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); } @@ -21002,7 +21550,7 @@ var ts; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 222 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 224 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -21014,7 +21562,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 221 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 223 /* CaseClause */) { var caseClause = clause; // TypeScript 1.0 spec (April 2014):5.9 // In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from the type of the 'switch' expression. @@ -21035,7 +21583,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 195 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 197 /* LabeledStatement */ && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -21083,9 +21631,6 @@ var ts; grammarErrorOnNode(localSymbol.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); } } - // It is a SyntaxError if a TryStatement with a Catch occurs within strict code and the Identifier of the - // Catch production is eval or arguments - checkGrammarEvalOrArgumentsInStrictMode(node, catchClause.variableDeclaration.name); } } checkBlock(catchClause.block); @@ -21105,7 +21650,7 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); }); - if (type.flags & 1024 /* Class */ && type.symbol.valueDeclaration.kind === 202 /* ClassDeclaration */) { + if (type.flags & 1024 /* Class */ && type.symbol.valueDeclaration.kind === 204 /* ClassDeclaration */) { var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -21143,7 +21688,7 @@ var ts; // perform property check if property or indexer is declared in 'type' // this allows to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (prop.valueDeclaration.name.kind === 128 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 129 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -21199,7 +21744,6 @@ var ts; return unknownType; } function checkClassDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node); // Grammar checking if (!node.name && !(node.flags & 256 /* Default */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); @@ -21218,36 +21762,42 @@ var ts; var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - if (!ts.isSupportedExpressionWithTypeArguments(baseTypeNode)) { - error(baseTypeNode.expression, ts.Diagnostics.Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses); - } emitExtends = emitExtends || !ts.isInAmbientContext(node); - checkExpressionWithTypeArguments(baseTypeNode); - } - var baseTypes = getBaseTypes(type); - if (baseTypes.length) { - if (produceDiagnostics) { + var baseTypes = getBaseTypes(type); + if (baseTypes.length && produceDiagnostics) { var baseType = baseTypes[0]; + var staticBaseType = getBaseConstructorTypeOfClass(type); + if (baseTypeNode.typeArguments) { + ts.forEach(baseTypeNode.typeArguments, checkSourceElement); + for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { + var constructor = _a[_i]; + if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { + break; + } + } + } checkTypeAssignableTo(type, baseType, node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); - var staticBaseType = getTypeOfSymbol(baseType.symbol); - checkTypeAssignableTo(staticType, getTypeWithoutConstructors(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseType.symbol !== resolveEntityName(baseTypeNode.expression, 107455 /* Value */)) { - error(baseTypeNode, ts.Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType)); + checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */)) { + // When the static base type is a "class-like" constructor function (but not actually a class), we verify + // that all instantiated base constructor signatures return the same type. We can simply compare the type + // references (as opposed to checking the structure of the types) because elsewhere we have already checked + // that the base type is a class or interface type (and not, for example, an anonymous object type). + var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); + if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType; })) { + error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); + } } checkKindsOfPropertyMemberOverrides(type, baseType); } } - if (baseTypes.length || (baseTypeNode && compilerOptions.isolatedModules)) { - // Check that base type can be evaluated as expression - checkExpressionOrQualifiedName(baseTypeNode.expression); - } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { ts.forEach(implementedTypeNodes, function (typeRefNode) { if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } - checkExpressionWithTypeArguments(typeRefNode); + checkTypeReferenceNode(typeRefNode); if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { @@ -21335,7 +21885,7 @@ var ts; } } function isAccessor(kind) { - return kind === 137 /* GetAccessor */ || kind === 138 /* SetAccessor */; + return kind === 138 /* GetAccessor */ || kind === 139 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -21399,13 +21949,13 @@ var ts; } function checkInterfaceDeclaration(node) { // Grammar checking - checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); checkTypeParameters(node.typeParameters); if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 203 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 205 /* InterfaceDeclaration */); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -21427,7 +21977,7 @@ var ts; if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) { error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments); } - checkExpressionWithTypeArguments(heritageElement); + checkTypeReferenceNode(heritageElement); }); ts.forEach(node.members, checkSourceElement); if (produceDiagnostics) { @@ -21449,7 +21999,7 @@ var ts; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 128 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 129 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; @@ -21489,7 +22039,7 @@ var ts; return evalConstant(initializer); function evalConstant(e) { switch (e.kind) { - case 168 /* PrefixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: var value = evalConstant(e.operand); if (value === undefined) { return undefined; @@ -21500,7 +22050,7 @@ var ts; case 47 /* TildeToken */: return ~value; } return undefined; - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -21525,11 +22075,11 @@ var ts; return undefined; case 7 /* NumericLiteral */: return +e.text; - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return evalConstant(e.expression); case 65 /* Identifier */: - case 157 /* ElementAccessExpression */: - case 156 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + case 158 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType; @@ -21542,7 +22092,7 @@ var ts; } else { var expression; - if (e.kind === 157 /* ElementAccessExpression */) { + if (e.kind === 159 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 8 /* StringLiteral */) { return undefined; @@ -21560,7 +22110,7 @@ var ts; if (current.kind === 65 /* Identifier */) { break; } - else if (current.kind === 156 /* PropertyAccessExpression */) { + else if (current.kind === 158 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -21599,7 +22149,7 @@ var ts; return; } // Grammar checking - checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -21629,7 +22179,7 @@ var ts; var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 205 /* EnumDeclaration */) { + if (declaration.kind !== 207 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -21652,8 +22202,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 202 /* ClassDeclaration */ || - (declaration.kind === 201 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 204 /* ClassDeclaration */ || + (declaration.kind === 203 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -21676,7 +22226,15 @@ var ts; function checkModuleDeclaration(node) { if (produceDiagnostics) { // Grammar checking - if (!checkGrammarDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { + var isAmbientExternalModule = node.name.kind === 8 /* StringLiteral */; + var contextErrorMessage = isAmbientExternalModule + ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file + : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; + if (checkGrammarModuleElementContext(node, contextErrorMessage)) { + // If we hit a module declaration in an illegal context, just bail out to avoid cascading errors. + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { if (!ts.isInAmbientContext(node) && node.name.kind === 8 /* StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } @@ -21701,14 +22259,14 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 202 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 204 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 2048 /* LexicalModuleMergesWithClass */; } } // Checks for ambient external modules. - if (node.name.kind === 8 /* StringLiteral */) { + if (isAmbientExternalModule) { if (!isGlobalSourceFile(node.parent)) { error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules); } @@ -21721,10 +22279,10 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 127 /* QualifiedName */) { + if (node.kind === 128 /* QualifiedName */) { node = node.left; } - else if (node.kind === 156 /* PropertyAccessExpression */) { + else if (node.kind === 158 /* PropertyAccessExpression */) { node = node.expression; } else { @@ -21740,9 +22298,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 207 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 228 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 216 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 209 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; + if (node.parent.kind !== 230 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 218 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -21765,7 +22323,7 @@ var ts; (symbol.flags & 793056 /* Type */ ? 793056 /* Type */ : 0) | (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 218 /* ExportSpecifier */ ? + var message = node.kind === 220 /* ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -21778,7 +22336,11 @@ var ts; checkAliasSymbol(node); } function checkImportDeclaration(node) { - if (!checkGrammarImportDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { + // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -21788,7 +22350,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 212 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 214 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -21799,7 +22361,11 @@ var ts; } } function checkImportEqualsDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node); + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { + // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. + return; + } + checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); if (node.flags & 1 /* Export */) { @@ -21829,6 +22395,10 @@ var ts; } } function checkExportDeclaration(node) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { + // If we hit an export in an illegal context, just bail out to avoid cascading errors. + return; + } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } @@ -21837,8 +22407,8 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 207 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 228 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 209 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; + if (node.parent.kind !== 230 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -21851,6 +22421,11 @@ var ts; } } } + function checkGrammarModuleElementContext(node, errorMessage) { + if (node.parent.kind !== 230 /* SourceFile */ && node.parent.kind !== 209 /* ModuleBlock */ && node.parent.kind !== 208 /* ModuleDeclaration */) { + return grammarErrorOnFirstToken(node, errorMessage); + } + } function checkExportSpecifier(node) { checkAliasSymbol(node); if (!node.parent.parent.moduleSpecifier) { @@ -21858,8 +22433,12 @@ var ts; } } function checkExportAssignment(node) { - var container = node.parent.kind === 228 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 206 /* ModuleDeclaration */ && container.name.kind === 65 /* Identifier */) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { + // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. + return; + } + var container = node.parent.kind === 230 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 208 /* ModuleDeclaration */ && container.name.kind === 65 /* Identifier */) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -21886,10 +22465,10 @@ var ts; } } function getModuleStatements(node) { - if (node.kind === 228 /* SourceFile */) { + if (node.kind === 230 /* SourceFile */) { return node.statements; } - if (node.kind === 206 /* ModuleDeclaration */ && node.body.kind === 207 /* ModuleBlock */) { + if (node.kind === 208 /* ModuleDeclaration */ && node.body.kind === 209 /* ModuleBlock */) { return node.body.statements; } return emptyArray; @@ -21914,111 +22493,118 @@ var ts; links.exportsChecked = true; } } + function checkTypePredicate(node) { + if (!isInLegalTypePredicatePosition(node)) { + error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + } + } function checkSourceElement(node) { if (!node) return; switch (node.kind) { - case 129 /* TypeParameter */: + case 130 /* TypeParameter */: return checkTypeParameter(node); - case 130 /* Parameter */: + case 131 /* Parameter */: return checkParameter(node); - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return checkPropertyDeclaration(node); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 141 /* IndexSignature */: + case 142 /* IndexSignature */: return checkSignatureDeclaration(node); - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return checkMethodDeclaration(node); - case 136 /* Constructor */: + case 137 /* Constructor */: return checkConstructorDeclaration(node); - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: return checkAccessorDeclaration(node); - case 142 /* TypeReference */: + case 144 /* TypeReference */: return checkTypeReferenceNode(node); - case 145 /* TypeQuery */: + case 143 /* TypePredicate */: + return checkTypePredicate(node); + case 147 /* TypeQuery */: return checkTypeQuery(node); - case 146 /* TypeLiteral */: + case 148 /* TypeLiteral */: return checkTypeLiteral(node); - case 147 /* ArrayType */: + case 149 /* ArrayType */: return checkArrayType(node); - case 148 /* TupleType */: + case 150 /* TupleType */: return checkTupleType(node); - case 149 /* UnionType */: + case 151 /* UnionType */: return checkUnionType(node); - case 150 /* ParenthesizedType */: + case 152 /* ParenthesizedType */: return checkSourceElement(node.type); - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 180 /* Block */: - case 207 /* ModuleBlock */: + case 182 /* Block */: + case 209 /* ModuleBlock */: return checkBlock(node); - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: return checkVariableStatement(node); - case 183 /* ExpressionStatement */: + case 185 /* ExpressionStatement */: return checkExpressionStatement(node); - case 184 /* IfStatement */: + case 186 /* IfStatement */: return checkIfStatement(node); - case 185 /* DoStatement */: + case 187 /* DoStatement */: return checkDoStatement(node); - case 186 /* WhileStatement */: + case 188 /* WhileStatement */: return checkWhileStatement(node); - case 187 /* ForStatement */: + case 189 /* ForStatement */: return checkForStatement(node); - case 188 /* ForInStatement */: + case 190 /* ForInStatement */: return checkForInStatement(node); - case 189 /* ForOfStatement */: + case 191 /* ForOfStatement */: return checkForOfStatement(node); - case 190 /* ContinueStatement */: - case 191 /* BreakStatement */: + case 192 /* ContinueStatement */: + case 193 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 192 /* ReturnStatement */: + case 194 /* ReturnStatement */: return checkReturnStatement(node); - case 193 /* WithStatement */: + case 195 /* WithStatement */: return checkWithStatement(node); - case 194 /* SwitchStatement */: + case 196 /* SwitchStatement */: return checkSwitchStatement(node); - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: return checkLabeledStatement(node); - case 196 /* ThrowStatement */: + case 198 /* ThrowStatement */: return checkThrowStatement(node); - case 197 /* TryStatement */: + case 199 /* TryStatement */: return checkTryStatement(node); - case 199 /* VariableDeclaration */: + case 201 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 153 /* BindingElement */: + case 155 /* BindingElement */: return checkBindingElement(node); - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: return checkClassDeclaration(node); - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 204 /* TypeAliasDeclaration */: + case 206 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: return checkImportDeclaration(node); - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: return checkExportDeclaration(node); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return checkExportAssignment(node); - case 182 /* EmptyStatement */: + case 184 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 198 /* DebuggerStatement */: + case 200 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 219 /* MissingDeclaration */: + case 221 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -22033,83 +22619,83 @@ var ts; // Delaying the type check of the body ensures foo has been assigned a type. function checkFunctionExpressionBodies(node) { switch (node.kind) { - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: ts.forEach(node.parameters, checkFunctionExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: ts.forEach(node.decorators, checkFunctionExpressionBodies); ts.forEach(node.parameters, checkFunctionExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 201 /* FunctionDeclaration */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 203 /* FunctionDeclaration */: ts.forEach(node.parameters, checkFunctionExpressionBodies); break; - case 193 /* WithStatement */: + case 195 /* WithStatement */: checkFunctionExpressionBodies(node.expression); break; - case 131 /* Decorator */: - case 130 /* Parameter */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 151 /* ObjectBindingPattern */: - case 152 /* ArrayBindingPattern */: - case 153 /* BindingElement */: - case 154 /* ArrayLiteralExpression */: - case 155 /* ObjectLiteralExpression */: - case 225 /* PropertyAssignment */: - case 156 /* PropertyAccessExpression */: - case 157 /* ElementAccessExpression */: - case 158 /* CallExpression */: - case 159 /* NewExpression */: - case 160 /* TaggedTemplateExpression */: - case 172 /* TemplateExpression */: - case 178 /* TemplateSpan */: - case 161 /* TypeAssertionExpression */: - case 162 /* ParenthesizedExpression */: - case 166 /* TypeOfExpression */: - case 167 /* VoidExpression */: - case 165 /* DeleteExpression */: - case 168 /* PrefixUnaryExpression */: - case 169 /* PostfixUnaryExpression */: - case 170 /* BinaryExpression */: - case 171 /* ConditionalExpression */: - case 174 /* SpreadElementExpression */: - case 180 /* Block */: - case 207 /* ModuleBlock */: - case 181 /* VariableStatement */: - case 183 /* ExpressionStatement */: - case 184 /* IfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 190 /* ContinueStatement */: - case 191 /* BreakStatement */: - case 192 /* ReturnStatement */: - case 194 /* SwitchStatement */: - case 208 /* CaseBlock */: - case 221 /* CaseClause */: - case 222 /* DefaultClause */: - case 195 /* LabeledStatement */: - case 196 /* ThrowStatement */: - case 197 /* TryStatement */: - case 224 /* CatchClause */: - case 199 /* VariableDeclaration */: - case 200 /* VariableDeclarationList */: - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: - case 227 /* EnumMember */: - case 215 /* ExportAssignment */: - case 228 /* SourceFile */: + case 132 /* Decorator */: + case 131 /* Parameter */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 153 /* ObjectBindingPattern */: + case 154 /* ArrayBindingPattern */: + case 155 /* BindingElement */: + case 156 /* ArrayLiteralExpression */: + case 157 /* ObjectLiteralExpression */: + case 227 /* PropertyAssignment */: + case 158 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: + case 162 /* TaggedTemplateExpression */: + case 174 /* TemplateExpression */: + case 180 /* TemplateSpan */: + case 163 /* TypeAssertionExpression */: + case 164 /* ParenthesizedExpression */: + case 168 /* TypeOfExpression */: + case 169 /* VoidExpression */: + case 167 /* DeleteExpression */: + case 170 /* PrefixUnaryExpression */: + case 171 /* PostfixUnaryExpression */: + case 172 /* BinaryExpression */: + case 173 /* ConditionalExpression */: + case 176 /* SpreadElementExpression */: + case 182 /* Block */: + case 209 /* ModuleBlock */: + case 183 /* VariableStatement */: + case 185 /* ExpressionStatement */: + case 186 /* IfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 192 /* ContinueStatement */: + case 193 /* BreakStatement */: + case 194 /* ReturnStatement */: + case 196 /* SwitchStatement */: + case 210 /* CaseBlock */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: + case 197 /* LabeledStatement */: + case 198 /* ThrowStatement */: + case 199 /* TryStatement */: + case 226 /* CatchClause */: + case 201 /* VariableDeclaration */: + case 202 /* VariableDeclarationList */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 229 /* EnumMember */: + case 217 /* ExportAssignment */: + case 230 /* SourceFile */: ts.forEachChild(node, checkFunctionExpressionBodies); break; } @@ -22123,6 +22709,11 @@ var ts; function checkSourceFileWorker(node) { var links = getNodeLinks(node); if (!(links.flags & 1 /* TypeChecked */)) { + // Check whether the file has declared it is the default lib, + // and whether the user has specifically chosen to avoid checking it. + if (node.isDefaultLib && compilerOptions.skipDefaultLibCheck) { + return; + } // Grammar checking checkGrammarSourceFile(node); emitExtends = false; @@ -22172,7 +22763,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 193 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 195 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -22195,23 +22786,23 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 228 /* SourceFile */: + case 230 /* SourceFile */: if (!ts.isExternalModule(location)) { break; } - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: if (!(memberFlags & 128 /* Static */)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 163 /* FunctionExpression */: + case 165 /* FunctionExpression */: if (location.name) { copySymbol(location.symbol, meaning); } @@ -22249,22 +22840,22 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 228 /* SourceFile */: + case 230 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: if (!(memberFlags & 128 /* Static */)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 163 /* FunctionExpression */: + case 165 /* FunctionExpression */: if (location.name) { copySymbol(location.symbol, meaning); } @@ -22277,43 +22868,43 @@ var ts; return symbolsToArray(symbols); } function isTypeDeclarationName(name) { - return name.kind == 65 /* Identifier */ && + return name.kind === 65 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 129 /* TypeParameter */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 205 /* EnumDeclaration */: + case 130 /* TypeParameter */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 207 /* EnumDeclaration */: return true; } } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 127 /* QualifiedName */) { + while (node.parent && node.parent.kind === 128 /* QualifiedName */) { node = node.parent; } - return node.parent && node.parent.kind === 142 /* TypeReference */; + return node.parent && node.parent.kind === 144 /* TypeReference */; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 156 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 158 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 177 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 179 /* ExpressionWithTypeArguments */; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 127 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 128 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 209 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 211 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 215 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 217 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -22325,11 +22916,11 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 215 /* ExportAssignment */) { + if (entityName.parent.kind === 217 /* ExportAssignment */) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 156 /* PropertyAccessExpression */) { + if (entityName.kind !== 158 /* PropertyAccessExpression */) { if (isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); @@ -22339,7 +22930,7 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 177 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 179 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } @@ -22354,14 +22945,14 @@ var ts; var meaning = 107455 /* Value */ | 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 156 /* PropertyAccessExpression */) { + else if (entityName.kind === 158 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 127 /* QualifiedName */) { + else if (entityName.kind === 128 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -22370,7 +22961,7 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 142 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 144 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. meaning |= 8388608 /* Alias */; @@ -22389,14 +22980,14 @@ var ts; return getSymbolOfNode(node.parent); } if (node.kind === 65 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 215 /* ExportAssignment */ + return node.parent.kind === 217 /* ExportAssignment */ ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } switch (node.kind) { case 65 /* Identifier */: - case 156 /* PropertyAccessExpression */: - case 127 /* QualifiedName */: + case 158 /* PropertyAccessExpression */: + case 128 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 93 /* ThisKeyword */: case 91 /* SuperKeyword */: @@ -22405,7 +22996,7 @@ var ts; case 114 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 136 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 137 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -22414,14 +23005,14 @@ var ts; var moduleName; if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 210 /* ImportDeclaration */ || node.parent.kind === 216 /* ExportDeclaration */) && + ((node.parent.kind === 212 /* ImportDeclaration */ || node.parent.kind === 218 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } // Intentional fall-through case 7 /* NumericLiteral */: // index access - if (node.parent.kind == 157 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 159 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -22438,7 +23029,7 @@ var ts; // The function returns a value symbol of an identifier in the short-hand property assignment. // This is necessary as an identifier in short-hand property assignment can contains two meaning: // property name and property value. - if (location && location.kind === 226 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 228 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */); } return undefined; @@ -22454,6 +23045,11 @@ var ts; if (ts.isExpression(node)) { return getTypeOfExpression(node); } + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(node)) { + // A SyntaxKind.ExpressionWithTypeArguments is considered a type node, except when it occurs in the + // extends clause of a class. We handle that case here. + return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; + } if (isTypeDeclaration(node)) { // In this case, we call getSymbolOfNode instead of getSymbolInfo because it is a declaration var symbol = getSymbolOfNode(node); @@ -22517,93 +23113,92 @@ var ts; return [symbol]; } // Emitter support - function isExternalModuleSymbol(symbol) { - return symbol.flags & 512 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 228 /* SourceFile */; - } - function getAliasNameSubstitution(symbol, getGeneratedNameForNode) { - // If this is es6 or higher, just use the name of the export - // no need to qualify it. - if (languageVersion >= 2 /* ES6 */) { - return undefined; - } - var node = getDeclarationOfAliasSymbol(symbol); - if (node) { - if (node.kind === 211 /* ImportClause */) { - var defaultKeyword; - if (languageVersion === 0 /* ES3 */) { - defaultKeyword = "[\"default\"]"; - } - else { - defaultKeyword = ".default"; - } - return getGeneratedNameForNode(node.parent) + defaultKeyword; - } - if (node.kind === 214 /* ImportSpecifier */) { - var moduleName = getGeneratedNameForNode(node.parent.parent.parent); - var propertyName = node.propertyName || node.name; - return moduleName + "." + ts.unescapeIdentifier(propertyName.text); - } - } - } - function getExportNameSubstitution(symbol, location, getGeneratedNameForNode) { - if (isExternalModuleSymbol(symbol.parent)) { - // 1. If this is es6 or higher, just use the name of the export - // no need to qualify it. - // 2. export mechanism for System modules is different from CJS\AMD - // and it does not need qualifications for exports - if (languageVersion >= 2 /* ES6 */ || compilerOptions.module === 4 /* System */) { - return undefined; - } - return "exports." + ts.unescapeIdentifier(symbol.name); - } - var node = location; - var containerSymbol = getParentOfSymbol(symbol); - while (node) { - if ((node.kind === 206 /* ModuleDeclaration */ || node.kind === 205 /* EnumDeclaration */) && getSymbolOfNode(node) === containerSymbol) { - return getGeneratedNameForNode(node) + "." + ts.unescapeIdentifier(symbol.name); - } - node = node.parent; - } - } - function getExpressionNameSubstitution(node, getGeneratedNameForNode) { - var symbol = getNodeLinks(node).resolvedSymbol || (ts.isDeclarationName(node) ? getSymbolOfNode(node.parent) : undefined); + // When resolved as an expression identifier, if the given node references an exported entity, return the declaration + // node of the exported entity's container. Otherwise, return undefined. + function getReferencedExportContainer(node) { + var symbol = getReferencedValueSymbol(node); if (symbol) { - // Whan an identifier resolves to a parented symbol, it references an exported entity from - // another declaration of the same internal module. - if (symbol.parent) { - return getExportNameSubstitution(symbol, node.parent, getGeneratedNameForNode); + if (symbol.flags & 1048576 /* ExportValue */) { + // If we reference an exported entity within the same module declaration, then whether + // we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the + // kinds that we do NOT prefix. + var exportSymbol = getMergedSymbol(symbol.exportSymbol); + if (exportSymbol.flags & 944 /* ExportHasLocal */) { + return undefined; + } + symbol = exportSymbol; } - // If we reference an exported entity within the same module declaration, then whether - // we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the - // kinds that we do NOT prefix. - var exportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); - if (symbol !== exportSymbol && !(exportSymbol.flags & 944 /* ExportHasLocal */)) { - return getExportNameSubstitution(exportSymbol, node.parent, getGeneratedNameForNode); - } - // Named imports from ES6 import declarations are rewritten - if (symbol.flags & 8388608 /* Alias */) { - return getAliasNameSubstitution(symbol, getGeneratedNameForNode); + var parentSymbol = getParentOfSymbol(symbol); + if (parentSymbol) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 230 /* SourceFile */) { + return parentSymbol.valueDeclaration; + } + for (var n = node.parent; n; n = n.parent) { + if ((n.kind === 208 /* ModuleDeclaration */ || n.kind === 207 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { + return n; + } + } } } } + // When resolved as an expression identifier, if the given node references an import, return the declaration of + // that import. Otherwise, return undefined. + function getReferencedImportDeclaration(node) { + var symbol = getReferencedValueSymbol(node); + return symbol && symbol.flags & 8388608 /* Alias */ ? getDeclarationOfAliasSymbol(symbol) : undefined; + } + function isStatementWithLocals(node) { + switch (node.kind) { + case 182 /* Block */: + case 210 /* CaseBlock */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + return true; + } + return false; + } + function isNestedRedeclarationSymbol(symbol) { + if (symbol.flags & 418 /* BlockScoped */) { + var links = getSymbolLinks(symbol); + if (links.isNestedRedeclaration === undefined) { + var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); + links.isNestedRedeclaration = isStatementWithLocals(container) && + !!resolveName(container.parent, symbol.name, 107455 /* Value */, undefined, undefined); + } + return links.isNestedRedeclaration; + } + return false; + } + // When resolved as an expression identifier, if the given node references a nested block scoped entity with + // a name that hides an existing name, return the declaration of that entity. Otherwise, return undefined. + function getReferencedNestedRedeclaration(node) { + var symbol = getReferencedValueSymbol(node); + return symbol && isNestedRedeclarationSymbol(symbol) ? symbol.valueDeclaration : undefined; + } + // Return true if the given node is a declaration of a nested block scoped entity with a name that hides an + // existing name. + function isNestedRedeclaration(node) { + return isNestedRedeclarationSymbol(getSymbolOfNode(node)); + } function isValueAliasDeclaration(node) { switch (node.kind) { - case 209 /* ImportEqualsDeclaration */: - case 211 /* ImportClause */: - case 212 /* NamespaceImport */: - case 214 /* ImportSpecifier */: - case 218 /* ExportSpecifier */: + case 211 /* ImportEqualsDeclaration */: + case 213 /* ImportClause */: + case 214 /* NamespaceImport */: + case 216 /* ImportSpecifier */: + case 220 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return node.expression && node.expression.kind === 65 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 228 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 230 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -22661,7 +23256,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 227 /* EnumMember */) { + if (node.kind === 229 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -22674,10 +23269,13 @@ var ts; return undefined; } /** Serializes an EntityName (with substitutions) to an appropriate JS constructor value. Used by the __metadata decorator. */ - function serializeEntityName(node, getGeneratedNameForNode, fallbackPath) { + function serializeEntityName(node, fallbackPath) { if (node.kind === 65 /* Identifier */) { - var substitution = getExpressionNameSubstitution(node, getGeneratedNameForNode); - var text = substitution || node.text; + // TODO(ron.buckton): The getExpressionNameSubstitution function has been removed, but calling it + // here has no effect anyway as an identifier in a type name is not an expression. + // var substitution = getExpressionNameSubstitution(node, getGeneratedNameForNode); + // var text = substitution || (node).text; + var text = node.text; if (fallbackPath) { fallbackPath.push(text); } @@ -22686,15 +23284,15 @@ var ts; } } else { - var left = serializeEntityName(node.left, getGeneratedNameForNode, fallbackPath); - var right = serializeEntityName(node.right, getGeneratedNameForNode, fallbackPath); + var left = serializeEntityName(node.left, fallbackPath); + var right = serializeEntityName(node.right, fallbackPath); if (!fallbackPath) { return left + "." + right; } } } /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ - function serializeTypeReferenceNode(node, getGeneratedNameForNode) { + function serializeTypeReferenceNode(node) { // serialization of a TypeReferenceNode uses the following rules: // // * The serialized type of a TypeReference that is `void` is "void 0". @@ -22727,11 +23325,11 @@ var ts; } else if (type === unknownType) { var fallbackPath = []; - serializeEntityName(node.typeName, getGeneratedNameForNode, fallbackPath); + serializeEntityName(node.typeName, fallbackPath); return fallbackPath; } else if (type.symbol && type.symbol.valueDeclaration) { - return serializeEntityName(node.typeName, getGeneratedNameForNode); + return serializeEntityName(node.typeName); } else if (typeHasCallOrConstructSignatures(type)) { return "Function"; @@ -22739,7 +23337,7 @@ var ts; return "Object"; } /** Serializes a TypeNode to an appropriate JS constructor value. Used by the __metadata decorator. */ - function serializeTypeNode(node, getGeneratedNameForNode) { + function serializeTypeNode(node) { // serialization of a TypeNode uses the following rules: // // * The serialized type of `void` is "void 0" (undefined). @@ -22754,26 +23352,26 @@ var ts; switch (node.kind) { case 99 /* VoidKeyword */: return "void 0"; - case 150 /* ParenthesizedType */: - return serializeTypeNode(node.type, getGeneratedNameForNode); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: + case 152 /* ParenthesizedType */: + return serializeTypeNode(node.type); + case 145 /* FunctionType */: + case 146 /* ConstructorType */: return "Function"; - case 147 /* ArrayType */: - case 148 /* TupleType */: + case 149 /* ArrayType */: + case 150 /* TupleType */: return "Array"; case 113 /* BooleanKeyword */: return "Boolean"; - case 122 /* StringKeyword */: + case 123 /* StringKeyword */: case 8 /* StringLiteral */: return "String"; - case 120 /* NumberKeyword */: + case 121 /* NumberKeyword */: return "Number"; - case 142 /* TypeReference */: - return serializeTypeReferenceNode(node, getGeneratedNameForNode); - case 145 /* TypeQuery */: - case 146 /* TypeLiteral */: - case 149 /* UnionType */: + case 144 /* TypeReference */: + return serializeTypeReferenceNode(node); + case 147 /* TypeQuery */: + case 148 /* TypeLiteral */: + case 151 /* UnionType */: case 112 /* AnyKeyword */: break; default: @@ -22784,7 +23382,7 @@ var ts; return "Object"; } /** Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member. */ - function serializeTypeOfNode(node, getGeneratedNameForNode) { + function serializeTypeOfNode(node) { // serialization of the type of a declaration uses the following rules: // // * The serialized type of a ClassDeclaration is "Function" @@ -22796,11 +23394,11 @@ var ts; // // For rules on serializing type annotations, see `serializeTypeNode`. switch (node.kind) { - case 202 /* ClassDeclaration */: return "Function"; - case 133 /* PropertyDeclaration */: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 130 /* Parameter */: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 137 /* GetAccessor */: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 138 /* SetAccessor */: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node), getGeneratedNameForNode); + case 204 /* ClassDeclaration */: return "Function"; + case 134 /* PropertyDeclaration */: return serializeTypeNode(node.type); + case 131 /* Parameter */: return serializeTypeNode(node.type); + case 138 /* GetAccessor */: return serializeTypeNode(node.type); + case 139 /* SetAccessor */: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node)); } if (ts.isFunctionLike(node)) { return "Function"; @@ -22808,7 +23406,7 @@ var ts; return "void 0"; } /** Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor. */ - function serializeParameterTypesOfNode(node, getGeneratedNameForNode) { + function serializeParameterTypesOfNode(node) { // serialization of parameter types uses the following rules: // // * If the declaration is a class, the parameters of the first constructor with a body are used. @@ -22817,7 +23415,7 @@ var ts; // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. if (node) { var valueDeclaration; - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -22832,19 +23430,19 @@ var ts; for (var i = 0; i < parameterCount; i++) { if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 147 /* ArrayType */) { + if (parameterType.kind === 149 /* ArrayType */) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 142 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 144 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { parameterType = undefined; } - result[i] = serializeTypeNode(parameterType, getGeneratedNameForNode); + result[i] = serializeTypeNode(parameterType); } else { - result[i] = serializeTypeOfNode(parameters[i], getGeneratedNameForNode); + result[i] = serializeTypeOfNode(parameters[i]); } } return result; @@ -22854,9 +23452,9 @@ var ts; return emptyArray; } /** Serializes the return type of function. Used by the __metadata decorator for a method. */ - function serializeReturnTypeOfNode(node, getGeneratedNameForNode) { + function serializeReturnTypeOfNode(node) { if (node && ts.isFunctionLike(node)) { - return serializeTypeNode(node.type, getGeneratedNameForNode); + return serializeTypeNode(node.type); } return "void 0"; } @@ -22879,25 +23477,25 @@ var ts; function hasGlobalName(name) { return ts.hasProperty(globals, name); } - function resolvesToSomeValue(location, name) { - ts.Debug.assert(!ts.nodeIsSynthesized(location), "resolvesToSomeValue called with a synthesized location"); - return !!resolveName(location, name, 107455 /* Value */, undefined, undefined); + function getReferencedValueSymbol(reference) { + return getNodeLinks(reference).resolvedSymbol || + resolveName(reference, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, + /*nodeNotFoundMessage*/ undefined, undefined); } function getReferencedValueDeclaration(reference) { ts.Debug.assert(!ts.nodeIsSynthesized(reference)); - var symbol = getNodeLinks(reference).resolvedSymbol || - resolveName(reference, reference.text, 107455 /* Value */ | 8388608 /* Alias */, undefined, undefined); + var symbol = getReferencedValueSymbol(reference); return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 153 /* BindingElement */ || (n.parent.kind === 199 /* VariableDeclaration */ && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 155 /* BindingElement */ || (n.parent.kind === 201 /* VariableDeclaration */ && n.parent.name === n); var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, undefined, undefined); var isLetOrConst = symbol && (symbol.flags & 2 /* BlockScopedVariable */) && - symbol.valueDeclaration.parent.kind !== 224 /* CatchClause */; + symbol.valueDeclaration.parent.kind !== 226 /* CatchClause */; if (isLetOrConst) { // side-effect of calling this method: // assign id to symbol if it was not yet set @@ -22919,7 +23517,10 @@ var ts; } function createResolver() { return { - getExpressionNameSubstitution: getExpressionNameSubstitution, + getReferencedExportContainer: getReferencedExportContainer, + getReferencedImportDeclaration: getReferencedImportDeclaration, + getReferencedNestedRedeclaration: getReferencedNestedRedeclaration, + isNestedRedeclaration: isNestedRedeclaration, isValueAliasDeclaration: isValueAliasDeclaration, hasGlobalName: hasGlobalName, isReferencedAliasDeclaration: isReferencedAliasDeclaration, @@ -22933,7 +23534,6 @@ var ts; isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, getConstantValue: getConstantValue, - resolvesToSomeValue: resolvesToSomeValue, collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, @@ -22994,137 +23594,6 @@ var ts; anyArrayType = createArrayType(anyType); } // GRAMMAR CHECKING - function isReservedWordInStrictMode(node) { - // Check that originalKeywordKind is less than LastFutureReservedWord to see if an Identifier is a strict-mode reserved word - return (node.parserContextFlags & 1 /* StrictMode */) && - (102 /* FirstFutureReservedWord */ <= node.originalKeywordKind && node.originalKeywordKind <= 110 /* LastFutureReservedWord */); - } - function reportStrictModeGrammarErrorInClassDeclaration(identifier, message, arg0, arg1, arg2) { - // We are checking if this name is inside class declaration or class expression (which are under class definitions inside ES6 spec.) - // if so, we would like to give more explicit invalid usage error. - if (ts.getAncestor(identifier, 202 /* ClassDeclaration */) || ts.getAncestor(identifier, 175 /* ClassExpression */)) { - return grammarErrorOnNode(identifier, message, arg0); - } - return false; - } - function checkGrammarImportDeclarationNameInStrictMode(node) { - // Check if the import declaration used strict-mode reserved word in its names bindings - if (node.importClause) { - var impotClause = node.importClause; - if (impotClause.namedBindings) { - var nameBindings = impotClause.namedBindings; - if (nameBindings.kind === 212 /* NamespaceImport */) { - var name_15 = nameBindings.name; - if (isReservedWordInStrictMode(name_15)) { - var nameText = ts.declarationNameToString(name_15); - return grammarErrorOnNode(name_15, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - } - } - else if (nameBindings.kind === 213 /* NamedImports */) { - var reportError = false; - for (var _i = 0, _a = nameBindings.elements; _i < _a.length; _i++) { - var element = _a[_i]; - var name_16 = element.name; - if (isReservedWordInStrictMode(name_16)) { - var nameText = ts.declarationNameToString(name_16); - reportError = reportError || grammarErrorOnNode(name_16, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - } - } - return reportError; - } - } - } - return false; - } - function checkGrammarDeclarationNameInStrictMode(node) { - var name = node.name; - if (name && name.kind === 65 /* Identifier */ && isReservedWordInStrictMode(name)) { - var nameText = ts.declarationNameToString(name); - switch (node.kind) { - case 130 /* Parameter */: - case 199 /* VariableDeclaration */: - case 201 /* FunctionDeclaration */: - case 129 /* TypeParameter */: - case 153 /* BindingElement */: - case 203 /* InterfaceDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 205 /* EnumDeclaration */: - return checkGrammarIdentifierInStrictMode(name); - case 202 /* ClassDeclaration */: - // Report an error if the class declaration uses strict-mode reserved word. - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText); - case 206 /* ModuleDeclaration */: - // Report an error if the module declaration uses strict-mode reserved word. - // TODO(yuisu): fix this when having external module in strict mode - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - case 209 /* ImportEqualsDeclaration */: - // TODO(yuisu): fix this when having external module in strict mode - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - } - } - return false; - } - function checkGrammarTypeReferenceInStrictMode(typeName) { - // Check if the type reference is using strict mode keyword - // Example: - // class C { - // foo(x: public){} // Error. - // } - if (typeName.kind === 65 /* Identifier */) { - checkGrammarTypeNameInStrictMode(typeName); - } - else if (typeName.kind === 127 /* QualifiedName */) { - // Walk from right to left and report a possible error at each Identifier in QualifiedName - // Example: - // x1: public.private.package // error at public and private - checkGrammarTypeNameInStrictMode(typeName.right); - checkGrammarTypeReferenceInStrictMode(typeName.left); - } - } - // This function will report an error for every identifier in property access expression - // whether it violates strict mode reserved words. - // Example: - // public // error at public - // public.private.package // error at public - // B.private.B // no error - function checkGrammarExpressionWithTypeArgumentsInStrictMode(expression) { - // Example: - // class C extends public // error at public - if (expression && expression.kind === 65 /* Identifier */) { - return checkGrammarIdentifierInStrictMode(expression); - } - else if (expression && expression.kind === 156 /* PropertyAccessExpression */) { - // Walk from left to right in PropertyAccessExpression until we are at the left most expression - // in PropertyAccessExpression. According to grammar production of MemberExpression, - // the left component expression is a PrimaryExpression (i.e. Identifier) while the other - // component after dots can be IdentifierName. - checkGrammarExpressionWithTypeArgumentsInStrictMode(expression.expression); - } - } - // The function takes an identifier itself or an expression which has SyntaxKind.Identifier. - function checkGrammarIdentifierInStrictMode(node, nameText) { - if (node && node.kind === 65 /* Identifier */ && isReservedWordInStrictMode(node)) { - if (!nameText) { - nameText = ts.declarationNameToString(node); - } - // TODO (yuisu): Fix when module is a strict mode - var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) || - grammarErrorOnNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - return errorReport; - } - return false; - } - // The function takes an identifier when uses as a typeName in TypeReferenceNode - function checkGrammarTypeNameInStrictMode(node) { - if (node && node.kind === 65 /* Identifier */ && isReservedWordInStrictMode(node)) { - var nameText = ts.declarationNameToString(node); - // TODO (yuisu): Fix when module is a strict mode - var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) || - grammarErrorOnNode(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode, nameText); - return errorReport; - } - return false; - } function checkGrammarDecorators(node) { if (!node.decorators) { return false; @@ -23135,7 +23604,7 @@ var ts; else if (languageVersion < 1 /* ES5 */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); } - else if (node.kind === 137 /* GetAccessor */ || node.kind === 138 /* SetAccessor */) { + else if (node.kind === 138 /* GetAccessor */ || node.kind === 139 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -23145,33 +23614,33 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 136 /* Constructor */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 141 /* IndexSignature */: - case 206 /* ModuleDeclaration */: - case 210 /* ImportDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 216 /* ExportDeclaration */: - case 215 /* ExportAssignment */: - case 130 /* Parameter */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 137 /* Constructor */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 142 /* IndexSignature */: + case 208 /* ModuleDeclaration */: + case 212 /* ImportDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 218 /* ExportDeclaration */: + case 217 /* ExportAssignment */: + case 131 /* Parameter */: break; - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 181 /* VariableStatement */: - case 201 /* FunctionDeclaration */: - case 204 /* TypeAliasDeclaration */: - if (node.modifiers && node.parent.kind !== 207 /* ModuleBlock */ && node.parent.kind !== 228 /* SourceFile */) { + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 183 /* VariableStatement */: + case 203 /* FunctionDeclaration */: + case 206 /* TypeAliasDeclaration */: + if (node.modifiers && node.parent.kind !== 209 /* ModuleBlock */ && node.parent.kind !== 230 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 70 /* ConstKeyword */) && - node.parent.kind !== 207 /* ModuleBlock */ && node.parent.kind !== 228 /* SourceFile */) { + node.parent.kind !== 209 /* ModuleBlock */ && node.parent.kind !== 230 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -23207,7 +23676,7 @@ var ts; else if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (node.parent.kind === 207 /* ModuleBlock */ || node.parent.kind === 228 /* SourceFile */) { + else if (node.parent.kind === 209 /* ModuleBlock */ || node.parent.kind === 230 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } flags |= ts.modifierToFlag(modifier.kind); @@ -23216,10 +23685,10 @@ var ts; if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (node.parent.kind === 207 /* ModuleBlock */ || node.parent.kind === 228 /* SourceFile */) { + else if (node.parent.kind === 209 /* ModuleBlock */ || node.parent.kind === 230 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 130 /* Parameter */) { + else if (node.kind === 131 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } flags |= 128 /* Static */; @@ -23232,10 +23701,10 @@ var ts; else if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (node.parent.kind === 202 /* ClassDeclaration */) { + else if (node.parent.kind === 204 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 130 /* Parameter */) { + else if (node.kind === 131 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; @@ -23244,13 +23713,13 @@ var ts; if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (node.parent.kind === 202 /* ClassDeclaration */) { + else if (node.parent.kind === 204 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 130 /* Parameter */) { + else if (node.kind === 131 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 207 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 209 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -23258,7 +23727,7 @@ var ts; break; } } - if (node.kind === 136 /* Constructor */) { + if (node.kind === 137 /* Constructor */) { if (flags & 128 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -23269,10 +23738,10 @@ var ts; return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } } - else if ((node.kind === 210 /* ImportDeclaration */ || node.kind === 209 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 212 /* ImportDeclaration */ || node.kind === 211 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 130 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 131 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } } @@ -23336,7 +23805,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 164 /* ArrowFunction */) { + if (node.kind === 166 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -23371,7 +23840,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 122 /* StringKeyword */ && parameter.type.kind !== 120 /* NumberKeyword */) { + if (parameter.type.kind !== 123 /* StringKeyword */ && parameter.type.kind !== 121 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -23404,7 +23873,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < arguments.length; _i++) { var arg = arguments[_i]; - if (arg.kind === 176 /* OmittedExpression */) { + if (arg.kind === 178 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -23478,19 +23947,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 128 /* ComputedPropertyName */) { + if (node.kind !== 129 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 170 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 23 /* CommaToken */) { + if (computedPropertyName.expression.kind === 172 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 23 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 201 /* FunctionDeclaration */ || - node.kind === 163 /* FunctionExpression */ || - node.kind === 135 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 203 /* FunctionDeclaration */ || + node.kind === 165 /* FunctionExpression */ || + node.kind === 136 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -23502,10 +23971,6 @@ var ts; } } } - function checkGrammarFunctionName(name) { - // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a strict mode FunctionDeclaration or FunctionExpression (13.1)) - return checkGrammarEvalOrArgumentsInStrictMode(name, name); - } function checkGrammarForInvalidQuestionMark(node, questionToken, message) { if (questionToken) { return grammarErrorOnNode(questionToken, message); @@ -23517,14 +23982,13 @@ var ts; var GetAccessor = 2; var SetAccesor = 4; var GetOrSetAccessor = GetAccessor | SetAccesor; - var inStrictMode = (node.parserContextFlags & 1 /* StrictMode */) !== 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_17 = prop.name; - if (prop.kind === 176 /* OmittedExpression */ || - name_17.kind === 128 /* ComputedPropertyName */) { + var name_15 = prop.name; + if (prop.kind === 178 /* OmittedExpression */ || + name_15.kind === 129 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it - checkGrammarComputedPropertyName(name_17); + checkGrammarComputedPropertyName(name_15); continue; } // ECMA-262 11.1.5 Object Initialiser @@ -23536,46 +24000,44 @@ var ts; // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; - if (prop.kind === 225 /* PropertyAssignment */ || prop.kind === 226 /* ShorthandPropertyAssignment */) { + if (prop.kind === 227 /* PropertyAssignment */ || prop.kind === 228 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_17.kind === 7 /* NumericLiteral */) { - checkGrammarNumericLiteral(name_17); + if (name_15.kind === 7 /* NumericLiteral */) { + checkGrammarNumericLiteral(name_15); } currentKind = Property; } - else if (prop.kind === 135 /* MethodDeclaration */) { + else if (prop.kind === 136 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 137 /* GetAccessor */) { + else if (prop.kind === 138 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 138 /* SetAccessor */) { + else if (prop.kind === 139 /* SetAccessor */) { currentKind = SetAccesor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, name_17.text)) { - seen[name_17.text] = currentKind; + if (!ts.hasProperty(seen, name_15.text)) { + seen[name_15.text] = currentKind; } else { - var existingKind = seen[name_17.text]; + var existingKind = seen[name_15.text]; if (currentKind === Property && existingKind === Property) { - if (inStrictMode) { - grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); - } + continue; } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_17.text] = currentKind | existingKind; + seen[name_15.text] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_15, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_15, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -23584,24 +24046,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 200 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 202 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 188 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 190 /* ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 188 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 190 /* ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 188 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 190 /* ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -23624,10 +24086,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 137 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 138 /* GetAccessor */ && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 138 /* SetAccessor */) { + else if (kind === 139 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -23652,7 +24114,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 128 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 129 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -23662,7 +24124,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 155 /* ObjectLiteralExpression */) { + if (node.parent.kind === 157 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -23670,7 +24132,7 @@ var ts; return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } - if (node.parent.kind === 202 /* ClassDeclaration */) { + if (node.parent.kind === 204 /* ClassDeclaration */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -23686,22 +24148,22 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 203 /* InterfaceDeclaration */) { + else if (node.parent.kind === 205 /* InterfaceDeclaration */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 146 /* TypeLiteral */) { + else if (node.parent.kind === 148 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: return true; - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -23713,11 +24175,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: if (node.label && current.label.text === node.label.text) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 190 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 192 /* ContinueStatement */ && !isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -23725,8 +24187,8 @@ var ts; return false; } break; - case 194 /* SwitchStatement */: - if (node.kind === 191 /* BreakStatement */ && !node.label) { + case 196 /* SwitchStatement */: + if (node.kind === 193 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -23741,13 +24203,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 191 /* BreakStatement */ + var message = node.kind === 193 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 191 /* BreakStatement */ + var message = node.kind === 193 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -23759,7 +24221,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 152 /* ArrayBindingPattern */ || node.name.kind === 151 /* ObjectBindingPattern */) { + if (node.name.kind === 154 /* ArrayBindingPattern */ || node.name.kind === 153 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -23767,12 +24229,9 @@ var ts; return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } } - // It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code - // and its Identifier is eval or arguments - return checkGrammarEvalOrArgumentsInStrictMode(node, node.name); } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 188 /* ForInStatement */ && node.parent.parent.kind !== 189 /* ForOfStatement */) { + if (node.parent.parent.kind !== 190 /* ForInStatement */ && node.parent.parent.kind !== 191 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { // Error on equals token which immediate precedes the initializer @@ -23796,8 +24255,7 @@ var ts; // It is a Syntax Error if the BoundNames of ForDeclaration contains "let". // It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code // and its Identifier is eval or arguments - return (checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name)) || - checkGrammarEvalOrArgumentsInStrictMode(node, node.name); + return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { if (name.kind === 65 /* Identifier */) { @@ -23809,7 +24267,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 176 /* OmittedExpression */) { + if (element.kind !== 178 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -23826,15 +24284,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 184 /* IfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: - case 193 /* WithStatement */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: + case 186 /* IfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: + case 195 /* WithStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: return false; - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -23850,7 +24308,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 168 /* PrefixUnaryExpression */) { + if (expression.kind === 170 /* PrefixUnaryExpression */) { var unaryExpression = expression; if (unaryExpression.operator === 33 /* PlusToken */ || unaryExpression.operator === 34 /* MinusToken */) { expression = unaryExpression.operand; @@ -23879,7 +24337,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 128 /* ComputedPropertyName */) { + if (node.name.kind === 129 /* ComputedPropertyName */) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -23921,26 +24379,6 @@ var ts; return true; } } - function checkGrammarEvalOrArgumentsInStrictMode(contextNode, name) { - if (name && name.kind === 65 /* Identifier */) { - var identifier = name; - if (contextNode && (contextNode.parserContextFlags & 1 /* StrictMode */) && isEvalOrArgumentsIdentifier(identifier)) { - var nameText = ts.declarationNameToString(identifier); - // We check first if the name is inside class declaration or class expression; if so give explicit message - // otherwise report generic error message. - // reportGrammarErrorInClassDeclaration only return true if grammar error is successfully reported and false otherwise - var reportErrorInClassDeclaration = reportStrictModeGrammarErrorInClassDeclaration(identifier, ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText); - if (!reportErrorInClassDeclaration) { - return grammarErrorOnNode(identifier, ts.Diagnostics.Invalid_use_of_0_in_strict_mode, nameText); - } - return reportErrorInClassDeclaration; - } - } - } - function isEvalOrArgumentsIdentifier(node) { - return node.kind === 65 /* Identifier */ && - (node.text === "eval" || node.text === "arguments"); - } function checkGrammarConstructorTypeParameters(node) { if (node.typeParameters) { return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); @@ -23952,18 +24390,18 @@ var ts; } } function checkGrammarProperty(node) { - if (node.parent.kind === 202 /* ClassDeclaration */) { + if (node.parent.kind === 204 /* ClassDeclaration */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 203 /* InterfaceDeclaration */) { + else if (node.parent.kind === 205 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 146 /* TypeLiteral */) { + else if (node.parent.kind === 148 /* TypeLiteral */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -23983,11 +24421,11 @@ var ts; // export_opt ExternalImportDeclaration // export_opt AmbientDeclaration // - if (node.kind === 203 /* InterfaceDeclaration */ || - node.kind === 210 /* ImportDeclaration */ || - node.kind === 209 /* ImportEqualsDeclaration */ || - node.kind === 216 /* ExportDeclaration */ || - node.kind === 215 /* ExportAssignment */ || + if (node.kind === 205 /* InterfaceDeclaration */ || + node.kind === 212 /* ImportDeclaration */ || + node.kind === 211 /* ImportEqualsDeclaration */ || + node.kind === 218 /* ExportDeclaration */ || + node.kind === 217 /* ExportAssignment */ || (node.flags & 2 /* Ambient */) || (node.flags & (1 /* Export */ | 256 /* Default */))) { return false; @@ -23997,7 +24435,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 181 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 183 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -24023,7 +24461,7 @@ var ts; // to prevent noisyness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 180 /* Block */ || node.parent.kind === 207 /* ModuleBlock */ || node.parent.kind === 228 /* SourceFile */) { + if (node.parent.kind === 182 /* Block */ || node.parent.kind === 209 /* ModuleBlock */ || node.parent.kind === 230 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -24036,13 +24474,8 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.flags & 16384 /* OctalLiteral */) { - if (node.parserContextFlags & 1 /* StrictMode */) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode); - } - else if (languageVersion >= 1 /* ES5 */) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); - } + if (node.flags & 16384 /* OctalLiteral */ && languageVersion >= 1 /* ES5 */) { + return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { @@ -24053,8 +24486,6 @@ var ts; return true; } } - initializeTypeChecker(); - return checker; } ts.createTypeChecker = createTypeChecker; })(ts || (ts = {})); @@ -24113,7 +24544,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 210 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 212 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -24189,10 +24620,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 199 /* VariableDeclaration */) { + if (declaration.kind === 201 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 213 /* NamedImports */ || declaration.kind === 214 /* ImportSpecifier */ || declaration.kind === 211 /* ImportClause */) { + else if (declaration.kind === 215 /* NamedImports */ || declaration.kind === 216 /* ImportSpecifier */ || declaration.kind === 213 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -24210,7 +24641,7 @@ var ts; // Writing of function bar would mark alias declaration foo as visible but we haven't yet visited that declaration so do nothing, // we would write alias foo declaration when we visit it since it would now be marked as visible if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 210 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 212 /* ImportDeclaration */) { // we have to create asynchronous output only after we have collected complete information // because it is possible to enable multiple bindings as asynchronously visible moduleElementEmitInfo.isVisible = true; @@ -24220,12 +24651,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 206 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 208 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 206 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 208 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -24318,41 +24749,41 @@ var ts; function emitType(type) { switch (type.kind) { case 112 /* AnyKeyword */: - case 122 /* StringKeyword */: - case 120 /* NumberKeyword */: + case 123 /* StringKeyword */: + case 121 /* NumberKeyword */: case 113 /* BooleanKeyword */: - case 123 /* SymbolKeyword */: + case 124 /* SymbolKeyword */: case 99 /* VoidKeyword */: case 8 /* StringLiteral */: return writeTextOfNode(currentSourceFile, type); - case 177 /* ExpressionWithTypeArguments */: + case 179 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 142 /* TypeReference */: + case 144 /* TypeReference */: return emitTypeReference(type); - case 145 /* TypeQuery */: + case 147 /* TypeQuery */: return emitTypeQuery(type); - case 147 /* ArrayType */: + case 149 /* ArrayType */: return emitArrayType(type); - case 148 /* TupleType */: + case 150 /* TupleType */: return emitTupleType(type); - case 149 /* UnionType */: + case 151 /* UnionType */: return emitUnionType(type); - case 150 /* ParenthesizedType */: + case 152 /* ParenthesizedType */: return emitParenType(type); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 146 /* TypeLiteral */: + case 148 /* TypeLiteral */: return emitTypeLiteral(type); case 65 /* Identifier */: return emitEntityName(type); - case 127 /* QualifiedName */: + case 128 /* QualifiedName */: return emitEntityName(type); } function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 209 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 211 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); function writeEntityName(entityName) { @@ -24360,8 +24791,8 @@ var ts; writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 127 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 127 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 128 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 128 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); @@ -24370,7 +24801,7 @@ var ts; } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 65 /* Identifier */ || node.expression.kind === 156 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 65 /* Identifier */ || node.expression.kind === 158 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -24436,9 +24867,9 @@ var ts; } var count = 0; while (true) { - var name_18 = baseName + "_" + (++count); - if (!ts.hasProperty(currentSourceFile.identifiers, name_18)) { - return name_18; + var name_16 = baseName + "_" + (++count); + if (!ts.hasProperty(currentSourceFile.identifiers, name_16)) { + return name_16; } } } @@ -24482,10 +24913,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 209 /* ImportEqualsDeclaration */ || - (node.parent.kind === 228 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 211 /* ImportEqualsDeclaration */ || + (node.parent.kind === 230 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 228 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 230 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -24495,7 +24926,7 @@ var ts; }); } else { - if (node.kind === 210 /* ImportDeclaration */) { + if (node.kind === 212 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -24513,23 +24944,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: return writeVariableStatement(node); - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: return writeClassDeclaration(node); - case 204 /* TypeAliasDeclaration */: + case 206 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -24545,7 +24976,7 @@ var ts; if (node.flags & 256 /* Default */) { write("default "); } - else if (node.kind !== 203 /* InterfaceDeclaration */) { + else if (node.kind !== 205 /* InterfaceDeclaration */) { write("declare "); } } @@ -24591,7 +25022,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 212 /* NamespaceImport */) { + if (namedBindings.kind === 214 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -24619,7 +25050,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 212 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 214 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -24670,9 +25101,14 @@ var ts; function writeModuleDeclaration(node) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - write("module "); + if (node.flags & 32768 /* Namespace */) { + write("namespace "); + } + else { + write("module "); + } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 207 /* ModuleBlock */) { + while (node.body.kind !== 209 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -24733,7 +25169,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 135 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + return node.parent.kind === 136 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -24744,15 +25180,15 @@ var ts; // If there is constraint present and this is not a type parameter of the private method emit the constraint if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 143 /* FunctionType */ || - node.parent.kind === 144 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 146 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 135 /* MethodDeclaration */ || - node.parent.kind === 134 /* MethodSignature */ || - node.parent.kind === 143 /* FunctionType */ || - node.parent.kind === 144 /* ConstructorType */ || - node.parent.kind === 139 /* CallSignature */ || - node.parent.kind === 140 /* ConstructSignature */); + if (node.parent.kind === 145 /* FunctionType */ || + node.parent.kind === 146 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 148 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 136 /* MethodDeclaration */ || + node.parent.kind === 135 /* MethodSignature */ || + node.parent.kind === 145 /* FunctionType */ || + node.parent.kind === 146 /* ConstructorType */ || + node.parent.kind === 140 /* CallSignature */ || + node.parent.kind === 141 /* ConstructSignature */); emitType(node.constraint); } else { @@ -24763,31 +25199,31 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 140 /* ConstructSignature */: + case 141 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 139 /* CallSignature */: + case 140 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 202 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 204 /* ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -24818,7 +25254,7 @@ var ts; function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 202 /* ClassDeclaration */) { + if (node.parent.parent.kind === 204 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -24899,7 +25335,7 @@ var ts; function emitVariableDeclaration(node) { // If we are emitting property it isn't moduleElement and hence we already know it needs to be emitted // so there is no check needed to see if declaration is visible - if (node.kind !== 199 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 201 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -24909,10 +25345,10 @@ var ts; // what we want, namely the name expression enclosed in brackets. writeTextOfNode(currentSourceFile, node.name); // If optional property emit ? - if ((node.kind === 133 /* PropertyDeclaration */ || node.kind === 132 /* PropertySignature */) && ts.hasQuestionToken(node)) { + if ((node.kind === 134 /* PropertyDeclaration */ || node.kind === 133 /* PropertySignature */) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 133 /* PropertyDeclaration */ || node.kind === 132 /* PropertySignature */) && node.parent.kind === 146 /* TypeLiteral */) { + if ((node.kind === 134 /* PropertyDeclaration */ || node.kind === 133 /* PropertySignature */) && node.parent.kind === 148 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32 /* Private */)) { @@ -24921,14 +25357,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 199 /* VariableDeclaration */) { + if (node.kind === 201 /* VariableDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 133 /* PropertyDeclaration */ || node.kind === 132 /* PropertySignature */) { + else if (node.kind === 134 /* PropertyDeclaration */ || node.kind === 133 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (node.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? @@ -24937,7 +25373,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 202 /* ClassDeclaration */) { + else if (node.parent.kind === 204 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -24969,7 +25405,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 176 /* OmittedExpression */) { + if (element.kind !== 178 /* OmittedExpression */) { elements.push(element); } } @@ -25039,7 +25475,7 @@ var ts; var type = getTypeAnnotationFromAccessor(node); if (!type) { // couldn't get type for the first accessor, try the another one - var anotherAccessor = node.kind === 137 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 138 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -25052,7 +25488,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 137 /* GetAccessor */ + return accessor.kind === 138 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -25061,7 +25497,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 138 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 139 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? @@ -25111,17 +25547,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 201 /* FunctionDeclaration */) { + if (node.kind === 203 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 135 /* MethodDeclaration */) { + else if (node.kind === 136 /* MethodDeclaration */) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 201 /* FunctionDeclaration */) { + if (node.kind === 203 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 136 /* Constructor */) { + else if (node.kind === 137 /* Constructor */) { write("constructor"); } else { @@ -25139,11 +25575,11 @@ var ts; } function emitSignatureDeclaration(node) { // Construct signature or constructor type write new Signature - if (node.kind === 140 /* ConstructSignature */ || node.kind === 144 /* ConstructorType */) { + if (node.kind === 141 /* ConstructSignature */ || node.kind === 146 /* ConstructorType */) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 141 /* IndexSignature */) { + if (node.kind === 142 /* IndexSignature */) { write("["); } else { @@ -25153,22 +25589,22 @@ var ts; enclosingDeclaration = node; // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 141 /* IndexSignature */) { + if (node.kind === 142 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 143 /* FunctionType */ || node.kind === 144 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 146 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 145 /* FunctionType */ || node.kind === 146 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 148 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 136 /* Constructor */ && !(node.flags & 32 /* Private */)) { + else if (node.kind !== 137 /* Constructor */ && !(node.flags & 32 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -25179,26 +25615,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 140 /* ConstructSignature */: + case 141 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 139 /* CallSignature */: + case 140 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 141 /* IndexSignature */: + case 142 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -25206,7 +25642,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 202 /* ClassDeclaration */) { + else if (node.parent.kind === 204 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -25220,7 +25656,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -25255,9 +25691,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 143 /* FunctionType */ || - node.parent.kind === 144 /* ConstructorType */ || - node.parent.parent.kind === 146 /* TypeLiteral */) { + if (node.parent.kind === 145 /* FunctionType */ || + node.parent.kind === 146 /* ConstructorType */ || + node.parent.parent.kind === 148 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32 /* Private */)) { @@ -25273,24 +25709,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 136 /* Constructor */: + case 137 /* Constructor */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 140 /* ConstructSignature */: + case 141 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 139 /* CallSignature */: + case 140 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -25298,7 +25734,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 202 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 204 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -25311,7 +25747,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -25323,12 +25759,12 @@ var ts; } function emitBindingPattern(bindingPattern) { // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node. - if (bindingPattern.kind === 151 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 153 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 152 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 154 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -25347,7 +25783,7 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 176 /* OmittedExpression */) { + if (bindingElement.kind === 178 /* OmittedExpression */) { // If bindingElement is an omittedExpression (i.e. containing elision), // we will emit blank space (although this may differ from users' original code, // it allows emitSeparatedList to write separator appropriately) @@ -25356,7 +25792,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 153 /* BindingElement */) { + else if (bindingElement.kind === 155 /* BindingElement */) { if (bindingElement.propertyName) { // bindingElement has propertyName property in the following case: // { y: [a,b,c] ...} -> bindingPattern will have a property called propertyName for "y" @@ -25397,40 +25833,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 201 /* FunctionDeclaration */: - case 206 /* ModuleDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 203 /* InterfaceDeclaration */: - case 202 /* ClassDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 205 /* EnumDeclaration */: + case 203 /* FunctionDeclaration */: + case 208 /* ModuleDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 205 /* InterfaceDeclaration */: + case 204 /* ClassDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 207 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, !node.importClause); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: return emitExportDeclaration(node); - case 136 /* Constructor */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 137 /* Constructor */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return writeFunctionDeclaration(node); - case 140 /* ConstructSignature */: - case 139 /* CallSignature */: - case 141 /* IndexSignature */: + case 141 /* ConstructSignature */: + case 140 /* CallSignature */: + case 142 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: return emitAccessorDeclaration(node); - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return emitPropertyDeclaration(node); - case 227 /* EnumMember */: + case 229 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return emitExportAssignment(node); - case 228 /* SourceFile */: + case 230 /* SourceFile */: return emitSourceFile(node); } } @@ -25491,7 +25927,7 @@ var ts; // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature function emitFiles(resolver, host, targetSourceFile) { // emit output for the __extends helper function - var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n __.prototype = b.prototype;\n d.prototype = new __();\n};"; + var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; // emit output for the __decorate helper function var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; // emit output for the __metadata helper function @@ -25567,7 +26003,6 @@ var ts; var exportFunctionForFile; var generatedNameSet = {}; var nodeToGeneratedName = []; - var blockScopedVariableToGeneratedName; var computedPropertyNamesToGeneratedNames; var extendsEmitted = false; var decorateEmitted = false; @@ -25647,9 +26082,9 @@ var ts; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { - var name_19 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_19)) { - return name_19; + var name_17 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); + if (isUniqueName(name_17)) { + return name_17; } } } @@ -25672,73 +26107,40 @@ var ts; i++; } } - function assignGeneratedName(node, name) { - nodeToGeneratedName[ts.getNodeId(node)] = ts.unescapeIdentifier(name); - } - function generateNameForFunctionOrClassDeclaration(node) { - if (!node.name) { - assignGeneratedName(node, makeUniqueName("default")); - } - } function generateNameForModuleOrEnum(node) { - if (node.name.kind === 65 /* Identifier */) { - var name_20 = node.name.text; - // Use module/enum name itself if it is unique, otherwise make a unique variation - assignGeneratedName(node, isUniqueLocalName(name_20, node) ? name_20 : makeUniqueName(name_20)); - } + var name = node.name.text; + // Use module/enum name itself if it is unique, otherwise make a unique variation + return isUniqueLocalName(name, node) ? name : makeUniqueName(name); } function generateNameForImportOrExportDeclaration(node) { var expr = ts.getExternalModuleName(node); var baseName = expr.kind === 8 /* StringLiteral */ ? ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; - assignGeneratedName(node, makeUniqueName(baseName)); + return makeUniqueName(baseName); } - function generateNameForImportDeclaration(node) { - if (node.importClause) { - generateNameForImportOrExportDeclaration(node); - } - } - function generateNameForExportDeclaration(node) { - if (node.moduleSpecifier) { - generateNameForImportOrExportDeclaration(node); - } - } - function generateNameForExportAssignment(node) { - if (node.expression && node.expression.kind !== 65 /* Identifier */) { - assignGeneratedName(node, makeUniqueName("default")); - } + function generateNameForExportDefault() { + return makeUniqueName("default"); } function generateNameForNode(node) { switch (node.kind) { - case 201 /* FunctionDeclaration */: - case 202 /* ClassDeclaration */: - case 175 /* ClassExpression */: - generateNameForFunctionOrClassDeclaration(node); - break; - case 206 /* ModuleDeclaration */: - generateNameForModuleOrEnum(node); - generateNameForNode(node.body); - break; - case 205 /* EnumDeclaration */: - generateNameForModuleOrEnum(node); - break; - case 210 /* ImportDeclaration */: - generateNameForImportDeclaration(node); - break; - case 216 /* ExportDeclaration */: - generateNameForExportDeclaration(node); - break; - case 215 /* ExportAssignment */: - generateNameForExportAssignment(node); - break; + case 65 /* Identifier */: + return makeUniqueName(node.text); + case 208 /* ModuleDeclaration */: + case 207 /* EnumDeclaration */: + return generateNameForModuleOrEnum(node); + case 212 /* ImportDeclaration */: + case 218 /* ExportDeclaration */: + return generateNameForImportOrExportDeclaration(node); + case 203 /* FunctionDeclaration */: + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: + case 217 /* ExportAssignment */: + return generateNameForExportDefault(); } } function getGeneratedNameForNode(node) { - var nodeId = ts.getNodeId(node); - if (!nodeToGeneratedName[nodeId]) { - generateNameForNode(node); - } - return nodeToGeneratedName[nodeId]; + var id = ts.getNodeId(node); + return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); } function initializeEmitterWithSourceMaps() { var sourceMapDir; // The directory in which sourcemap will be @@ -25767,7 +26169,7 @@ var ts; } var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; // Line/Comma delimiters - if (lastEncodedSourceMapSpan.emittedLine == lastRecordedSourceMapSpan.emittedLine) { + if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { // Emit comma to separate the entry if (sourceMapData.sourceMapMappings) { sourceMapData.sourceMapMappings += ","; @@ -25836,8 +26238,8 @@ var ts; var emittedColumn = writer.getColumn(); // If this location wasn't recorded or the location in source is going backwards, record the span if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine != emittedLine || - lastRecordedSourceMapSpan.emittedColumn != emittedColumn || + lastRecordedSourceMapSpan.emittedLine !== emittedLine || + lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { @@ -25903,8 +26305,8 @@ var ts; // Child scopes are always shown with a dot (even if they have no name), // unless it is a computed property. Then it is shown with brackets, // but the brackets are included in the name. - var name_21 = node.name; - if (!name_21 || name_21.kind !== 128 /* ComputedPropertyName */) { + var name_18 = node.name; + if (!name_18 || name_18.kind !== 129 /* ComputedPropertyName */) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -25922,21 +26324,21 @@ var ts; // The scope was already given a name use it recordScopeNameStart(scopeName); } - else if (node.kind === 201 /* FunctionDeclaration */ || - node.kind === 163 /* FunctionExpression */ || - node.kind === 135 /* MethodDeclaration */ || - node.kind === 134 /* MethodSignature */ || - node.kind === 137 /* GetAccessor */ || - node.kind === 138 /* SetAccessor */ || - node.kind === 206 /* ModuleDeclaration */ || - node.kind === 202 /* ClassDeclaration */ || - node.kind === 205 /* EnumDeclaration */) { + else if (node.kind === 203 /* FunctionDeclaration */ || + node.kind === 165 /* FunctionExpression */ || + node.kind === 136 /* MethodDeclaration */ || + node.kind === 135 /* MethodSignature */ || + node.kind === 138 /* GetAccessor */ || + node.kind === 139 /* SetAccessor */ || + node.kind === 208 /* ModuleDeclaration */ || + node.kind === 204 /* ClassDeclaration */ || + node.kind === 207 /* EnumDeclaration */) { // Declaration and has associated name use it if (node.name) { - var name_22 = node.name; + var name_19 = node.name; // For computed property names, the text will include the brackets - scopeName = name_22.kind === 128 /* ComputedPropertyName */ - ? ts.getTextOfNode(name_22) + scopeName = name_19.kind === 129 /* ComputedPropertyName */ + ? ts.getTextOfNode(name_19) : node.name.text; } recordScopeNameStart(scopeName); @@ -26040,19 +26442,19 @@ var ts; else { sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); } - function emitNodeWithSourceMap(node, allowGeneratedIdentifiers) { + function emitNodeWithSourceMap(node) { if (node) { if (ts.nodeIsSynthesized(node)) { - return emitNodeWithoutSourceMap(node, false); + return emitNodeWithoutSourceMap(node); } - if (node.kind != 228 /* SourceFile */) { + if (node.kind !== 230 /* SourceFile */) { recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers); + emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); } else { recordNewSourceFileStart(node); - emitNodeWithoutSourceMap(node, false); + emitNodeWithoutSourceMap(node); } } } @@ -26308,10 +26710,10 @@ var ts; write("("); emit(tempVariable); // Now we emit the expressions - if (node.template.kind === 172 /* TemplateExpression */) { + if (node.template.kind === 174 /* TemplateExpression */) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 170 /* BinaryExpression */ + var needsParens = templateSpan.expression.kind === 172 /* BinaryExpression */ && templateSpan.expression.operatorToken.kind === 23 /* CommaToken */; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -26346,7 +26748,7 @@ var ts; // ("abc" + 1) << (2 + "") // rather than // "abc" + (1 << 2) + "" - var needsParens = templateSpan.expression.kind !== 162 /* ParenthesizedExpression */ + var needsParens = templateSpan.expression.kind !== 164 /* ParenthesizedExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; if (i > 0 || headEmitted) { // If this is the first span and the head was not emitted, then this templateSpan's @@ -26388,11 +26790,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: return parent.expression === template; - case 160 /* TaggedTemplateExpression */: - case 162 /* ParenthesizedExpression */: + case 162 /* TaggedTemplateExpression */: + case 164 /* ParenthesizedExpression */: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; @@ -26413,7 +26815,7 @@ var ts; // TODO (drosen): Note that we need to account for the upcoming 'yield' and // spread ('...') unary operators that are anticipated for ES6. switch (expression.kind) { - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: switch (expression.operatorToken.kind) { case 35 /* AsteriskToken */: case 36 /* SlashToken */: @@ -26425,8 +26827,8 @@ var ts; default: return -1 /* LessThan */; } - case 173 /* YieldExpression */: - case 171 /* ConditionalExpression */: + case 175 /* YieldExpression */: + case 173 /* ConditionalExpression */: return -1 /* LessThan */; default: return 1 /* GreaterThan */; @@ -26441,11 +26843,11 @@ var ts; // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. // For example, this is utilized when feeding in a result to Object.defineProperty. function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 153 /* BindingElement */); + ts.Debug.assert(node.kind !== 155 /* BindingElement */); if (node.kind === 8 /* StringLiteral */) { emitLiteral(node); } - else if (node.kind === 128 /* ComputedPropertyName */) { + else if (node.kind === 129 /* ComputedPropertyName */) { // if this is a decorated computed property, we will need to capture the result // of the property expression so that we can apply decorators later. This is to ensure // we don't introduce unintended side effects: @@ -26486,75 +26888,126 @@ var ts; write("\""); } } - function isNotExpressionIdentifier(node) { + function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 130 /* Parameter */: - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 225 /* PropertyAssignment */: - case 226 /* ShorthandPropertyAssignment */: - case 227 /* EnumMember */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 201 /* FunctionDeclaration */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 163 /* FunctionExpression */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 206 /* ModuleDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 211 /* ImportClause */: - case 212 /* NamespaceImport */: - return parent.name === node; - case 214 /* ImportSpecifier */: - case 218 /* ExportSpecifier */: - return parent.name === node || parent.propertyName === node; - case 191 /* BreakStatement */: - case 190 /* ContinueStatement */: - case 215 /* ExportAssignment */: - return false; - case 195 /* LabeledStatement */: - return node.parent.label === node; + case 156 /* ArrayLiteralExpression */: + case 172 /* BinaryExpression */: + case 160 /* CallExpression */: + case 223 /* CaseClause */: + case 129 /* ComputedPropertyName */: + case 173 /* ConditionalExpression */: + case 132 /* Decorator */: + case 167 /* DeleteExpression */: + case 187 /* DoStatement */: + case 159 /* ElementAccessExpression */: + case 217 /* ExportAssignment */: + case 185 /* ExpressionStatement */: + case 179 /* ExpressionWithTypeArguments */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 186 /* IfStatement */: + case 161 /* NewExpression */: + case 164 /* ParenthesizedExpression */: + case 171 /* PostfixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: + case 194 /* ReturnStatement */: + case 228 /* ShorthandPropertyAssignment */: + case 176 /* SpreadElementExpression */: + case 196 /* SwitchStatement */: + case 162 /* TaggedTemplateExpression */: + case 180 /* TemplateSpan */: + case 198 /* ThrowStatement */: + case 163 /* TypeAssertionExpression */: + case 168 /* TypeOfExpression */: + case 169 /* VoidExpression */: + case 188 /* WhileStatement */: + case 195 /* WithStatement */: + case 175 /* YieldExpression */: + return true; + case 155 /* BindingElement */: + case 229 /* EnumMember */: + case 131 /* Parameter */: + case 227 /* PropertyAssignment */: + case 134 /* PropertyDeclaration */: + case 201 /* VariableDeclaration */: + return parent.initializer === node; + case 158 /* PropertyAccessExpression */: + return parent.expression === node; + case 166 /* ArrowFunction */: + case 165 /* FunctionExpression */: + return parent.body === node; + case 211 /* ImportEqualsDeclaration */: + return parent.moduleReference === node; + case 128 /* QualifiedName */: + return parent.left === node; } + return false; } function emitExpressionIdentifier(node) { - var substitution = resolver.getExpressionNameSubstitution(node, getGeneratedNameForNode); - if (substitution) { - write(substitution); + var container = resolver.getReferencedExportContainer(node); + if (container) { + if (container.kind === 230 /* SourceFile */) { + // Identifier references module export + if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 4 /* System */) { + write("exports."); + } + } + else { + // Identifier references namespace export + write(getGeneratedNameForNode(container)); + write("."); + } } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function getGeneratedNameForIdentifier(node) { - if (ts.nodeIsSynthesized(node) || !blockScopedVariableToGeneratedName) { - return undefined; - } - var variableId = resolver.getBlockScopedVariableId(node); - if (variableId === undefined) { - return undefined; - } - return blockScopedVariableToGeneratedName[variableId]; - } - function emitIdentifier(node, allowGeneratedIdentifiers) { - if (allowGeneratedIdentifiers) { - var generatedName = getGeneratedNameForIdentifier(node); - if (generatedName) { - write(generatedName); + else if (languageVersion < 2 /* ES6 */) { + var declaration = resolver.getReferencedImportDeclaration(node); + if (declaration) { + if (declaration.kind === 213 /* ImportClause */) { + // Identifier references default import + write(getGeneratedNameForNode(declaration.parent)); + write(languageVersion === 0 /* ES3 */ ? '["default"]' : ".default"); + return; + } + else if (declaration.kind === 216 /* ImportSpecifier */) { + // Identifier references named import + write(getGeneratedNameForNode(declaration.parent.parent.parent)); + write("."); + writeTextOfNode(currentSourceFile, declaration.propertyName || declaration.name); + return; + } + } + declaration = resolver.getReferencedNestedRedeclaration(node); + if (declaration) { + write(getGeneratedNameForNode(declaration.name)); return; } } + writeTextOfNode(currentSourceFile, node); + } + function isNameOfNestedRedeclaration(node) { + if (languageVersion < 2 /* ES6 */) { + var parent_7 = node.parent; + switch (parent_7.kind) { + case 155 /* BindingElement */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 201 /* VariableDeclaration */: + return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); + } + } + return false; + } + function emitIdentifier(node) { if (!node.parent) { write(node.text); } - else if (!isNotExpressionIdentifier(node)) { + else if (isExpressionIdentifier(node)) { emitExpressionIdentifier(node); } + else if (isNameOfNestedRedeclaration(node)) { + write(getGeneratedNameForNode(node)); + } else { writeTextOfNode(currentSourceFile, node); } @@ -26595,7 +27048,7 @@ var ts; } function emitBindingElement(node) { if (node.propertyName) { - emit(node.propertyName, false); + emit(node.propertyName); write(": "); } if (node.dotDotDotToken) { @@ -26626,11 +27079,11 @@ var ts; function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { case 65 /* Identifier */: - case 154 /* ArrayLiteralExpression */: - case 156 /* PropertyAccessExpression */: - case 157 /* ElementAccessExpression */: - case 158 /* CallExpression */: - case 162 /* ParenthesizedExpression */: + case 156 /* ArrayLiteralExpression */: + case 158 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + case 160 /* CallExpression */: + case 164 /* ParenthesizedExpression */: // This list is not exhaustive and only includes those cases that are relevant // to the check in emitArrayLiteral. More cases can be added as needed. return false; @@ -26650,17 +27103,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 174 /* SpreadElementExpression */) { + if (e.kind === 176 /* SpreadElementExpression */) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 154 /* ArrayLiteralExpression */) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 156 /* ArrayLiteralExpression */) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 174 /* SpreadElementExpression */) { + while (i < length && elements[i].kind !== 176 /* SpreadElementExpression */) { i++; } write("["); @@ -26683,7 +27136,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 174 /* SpreadElementExpression */; + return node.kind === 176 /* SpreadElementExpression */; } function emitArrayLiteral(node) { var elements = node.elements; @@ -26753,7 +27206,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 137 /* GetAccessor */ || property.kind === 138 /* SetAccessor */) { + if (property.kind === 138 /* GetAccessor */ || property.kind === 139 /* SetAccessor */) { // TODO (drosen): Reconcile with 'emitMemberFunctions'. var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { @@ -26805,13 +27258,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 225 /* PropertyAssignment */) { + if (property.kind === 227 /* PropertyAssignment */) { emit(property.initializer); } - else if (property.kind === 226 /* ShorthandPropertyAssignment */) { + else if (property.kind === 228 /* ShorthandPropertyAssignment */) { emitExpressionIdentifier(property.name); } - else if (property.kind === 135 /* MethodDeclaration */) { + else if (property.kind === 136 /* MethodDeclaration */) { emitFunctionDeclaration(property); } else { @@ -26845,7 +27298,7 @@ var ts; // Everything until that point can be emitted as part of the initial object literal. var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 128 /* ComputedPropertyName */) { + if (properties[i].name.kind === 129 /* ComputedPropertyName */) { numInitialNonComputedProperties = i; break; } @@ -26861,21 +27314,21 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(170 /* BinaryExpression */, startsOnNewLine); + var result = ts.createSynthesizedNode(172 /* BinaryExpression */, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(156 /* PropertyAccessExpression */); + var result = ts.createSynthesizedNode(158 /* PropertyAccessExpression */); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(20 /* DotToken */); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(157 /* ElementAccessExpression */); + var result = ts.createSynthesizedNode(159 /* ElementAccessExpression */); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; @@ -26883,7 +27336,7 @@ var ts; function parenthesizeForAccess(expr) { // When diagnosing whether the expression needs parentheses, the decision should be based // on the innermost expression in a chain of nested type assertions. - while (expr.kind === 161 /* TypeAssertionExpression */) { + while (expr.kind === 163 /* TypeAssertionExpression */) { expr = expr.expression; } // isLeftHandSideExpression is almost the correct criterion for when it is not necessary @@ -26895,11 +27348,11 @@ var ts; // 1.x -> not the same as (1).x // if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 159 /* NewExpression */ && + expr.kind !== 161 /* NewExpression */ && expr.kind !== 7 /* NumericLiteral */) { return expr; } - var node = ts.createSynthesizedNode(162 /* ParenthesizedExpression */); + var node = ts.createSynthesizedNode(164 /* ParenthesizedExpression */); node.expression = expr; return node; } @@ -26912,46 +27365,39 @@ var ts; if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { write("*"); } - emit(node.name, false); + emit(node.name); if (languageVersion < 2 /* ES6 */) { write(": function "); } emitSignatureAndBody(node); } function emitPropertyAssignment(node) { - emit(node.name, false); + emit(node.name); write(": "); emit(node.initializer); } + // Return true if identifier resolves to an exported member of a namespace + function isNamespaceExportReference(node) { + var container = resolver.getReferencedExportContainer(node); + return container && container.kind !== 230 /* SourceFile */; + } function emitShorthandPropertyAssignment(node) { - emit(node.name, false); - // If short-hand property has a prefix, then regardless of the target version, we will emit it as normal property assignment. For example: - // module m { - // export let y; - // } - // module m { - // export let obj = { y }; - // } - // The short-hand property in obj need to emit as such ... = { y : m.y } regardless of the TargetScript version - if (languageVersion < 2 /* ES6 */) { + // The name property of a short-hand property assignment is considered an expression position, so here + // we manually emit the identifier to avoid rewriting. + writeTextOfNode(currentSourceFile, node.name); + // If emitting pre-ES6 code, or if the name requires rewriting when resolved as an expression identifier, + // we emit a normal property assignment. For example: + // module m { + // export let y; + // } + // module m { + // let obj = { y }; + // } + // Here we need to emit obj = { y : m.y } regardless of the output target. + if (languageVersion < 2 /* ES6 */ || isNamespaceExportReference(node.name)) { // Emit identifier as an identifier write(": "); - var generatedName = getGeneratedNameForIdentifier(node.name); - if (generatedName) { - write(generatedName); - } - else { - // Even though this is stored as identifier treat it as an expression - // Short-hand, { x }, is equivalent of normal form { x: x } - emitExpressionIdentifier(node.name); - } - } - else if (resolver.getExpressionNameSubstitution(node.name, getGeneratedNameForNode)) { - // Emit identifier as an identifier - write(": "); - // Even though this is stored as identifier treat it as an expression - // Short-hand, { x }, is equivalent of normal form { x: x } - emitExpressionIdentifier(node.name); + emit(node.name); } } function tryEmitConstantValue(node) { @@ -26963,7 +27409,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 156 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 158 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -26997,7 +27443,7 @@ var ts; var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); write("."); var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); - emit(node.name, false); + emit(node.name); decreaseIndentIf(indentedBeforeDot, indentedAfterDot); } function emitQualifiedName(node) { @@ -27015,10 +27461,10 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 174 /* SpreadElementExpression */; }); + return ts.forEach(elements, function (e) { return e.kind === 176 /* SpreadElementExpression */; }); } function skipParentheses(node) { - while (node.kind === 162 /* ParenthesizedExpression */ || node.kind === 161 /* TypeAssertionExpression */) { + while (node.kind === 164 /* ParenthesizedExpression */ || node.kind === 163 /* TypeAssertionExpression */) { node = node.expression; } return node; @@ -27039,13 +27485,13 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 156 /* PropertyAccessExpression */) { + if (expr.kind === 158 /* PropertyAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 157 /* ElementAccessExpression */) { + else if (expr.kind === 159 /* ElementAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("["); @@ -27090,7 +27536,7 @@ var ts; } else { emit(node.expression); - superCall = node.expression.kind === 156 /* PropertyAccessExpression */ && node.expression.expression.kind === 91 /* SuperKeyword */; + superCall = node.expression.kind === 158 /* PropertyAccessExpression */ && node.expression.expression.kind === 91 /* SuperKeyword */; } if (superCall && languageVersion < 2 /* ES6 */) { write(".call("); @@ -27109,23 +27555,21 @@ var ts; } function emitNewExpression(node) { write("new "); - // Spread operator logic can be supported in new expressions in ES5 using a combination + // Spread operator logic is supported in new expressions in ES5 using a combination // of Function.prototype.bind() and Function.prototype.apply(). // // Example: // - // var arguments = [1, 2, 3, 4, 5]; - // new Array(...arguments); + // var args = [1, 2, 3, 4, 5]; + // new Array(...args); // - // Could be transpiled into ES5: + // is compiled into the following ES5: // - // var arguments = [1, 2, 3, 4, 5]; - // new (Array.bind.apply(Array, [void 0].concat(arguments))); + // var args = [1, 2, 3, 4, 5]; + // new (Array.bind.apply(Array, [void 0].concat(args))); // - // `[void 0]` is the first argument which represents `thisArg` to the bind method above. - // And `thisArg` will be set to the return value of the constructor when instantiated - // with the new operator — regardless of any value we set `thisArg` to. Thus, we set it - // to an undefined, `void 0`. + // The 'thisArg' to 'bind' is ignored when invoking the result of 'bind' with 'new', + // Thus, we set it to undefined ('void 0'). if (languageVersion === 1 /* ES5 */ && node.arguments && hasSpreadElement(node.arguments)) { @@ -27161,12 +27605,12 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 164 /* ArrowFunction */) { - if (node.expression.kind === 161 /* TypeAssertionExpression */) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 166 /* ArrowFunction */) { + if (node.expression.kind === 163 /* TypeAssertionExpression */) { var operand = node.expression.expression; // Make sure we consider all nested cast expressions, e.g.: // (-A).x; - while (operand.kind == 161 /* TypeAssertionExpression */) { + while (operand.kind === 163 /* TypeAssertionExpression */) { operand = operand.expression; } // We have an expression of the form: (SubExpr) @@ -27177,14 +27621,14 @@ var ts; // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() // new (A()) should be emitted as new (A()) and not new A() // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () - if (operand.kind !== 168 /* PrefixUnaryExpression */ && - operand.kind !== 167 /* VoidExpression */ && - operand.kind !== 166 /* TypeOfExpression */ && - operand.kind !== 165 /* DeleteExpression */ && - operand.kind !== 169 /* PostfixUnaryExpression */ && - operand.kind !== 159 /* NewExpression */ && - !(operand.kind === 158 /* CallExpression */ && node.parent.kind === 159 /* NewExpression */) && - !(operand.kind === 163 /* FunctionExpression */ && node.parent.kind === 158 /* CallExpression */)) { + if (operand.kind !== 170 /* PrefixUnaryExpression */ && + operand.kind !== 169 /* VoidExpression */ && + operand.kind !== 168 /* TypeOfExpression */ && + operand.kind !== 167 /* DeleteExpression */ && + operand.kind !== 171 /* PostfixUnaryExpression */ && + operand.kind !== 161 /* NewExpression */ && + !(operand.kind === 160 /* CallExpression */ && node.parent.kind === 161 /* NewExpression */) && + !(operand.kind === 165 /* FunctionExpression */ && node.parent.kind === 160 /* CallExpression */)) { emit(operand); return; } @@ -27213,7 +27657,7 @@ var ts; if (!isCurrentFileSystemExternalModule() || node.kind !== 65 /* Identifier */ || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 199 /* VariableDeclaration */ || node.parent.kind === 153 /* BindingElement */); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 201 /* VariableDeclaration */ || node.parent.kind === 155 /* BindingElement */); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -27243,7 +27687,7 @@ var ts; // the resulting expression a prefix increment operation. And in the second, it will make the resulting // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. - if (node.operand.kind === 168 /* PrefixUnaryExpression */) { + if (node.operand.kind === 170 /* PrefixUnaryExpression */) { var operand = node.operand; if (node.operator === 33 /* PlusToken */ && (operand.operator === 33 /* PlusToken */ || operand.operator === 38 /* PlusPlusToken */)) { write(" "); @@ -27299,10 +27743,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 228 /* SourceFile */) { + if (current.kind === 230 /* SourceFile */) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 207 /* ModuleBlock */) { + else if (ts.isFunctionLike(current) || current.kind === 209 /* ModuleBlock */) { return false; } else { @@ -27312,8 +27756,8 @@ var ts; } function emitBinaryExpression(node) { if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 53 /* EqualsToken */ && - (node.left.kind === 155 /* ObjectLiteralExpression */ || node.left.kind === 154 /* ArrayLiteralExpression */)) { - emitDestructuring(node, node.parent.kind === 183 /* ExpressionStatement */); + (node.left.kind === 157 /* ObjectLiteralExpression */ || node.left.kind === 156 /* ArrayLiteralExpression */)) { + emitDestructuring(node, node.parent.kind === 185 /* ExpressionStatement */); } else { var exportChanged = node.operatorToken.kind >= 53 /* FirstAssignment */ && @@ -27365,7 +27809,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 180 /* Block */) { + if (node && node.kind === 182 /* Block */) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -27380,12 +27824,12 @@ var ts; emitToken(14 /* OpenBraceToken */, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 207 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 206 /* ModuleDeclaration */); + if (node.kind === 209 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 208 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 207 /* ModuleBlock */) { + if (node.kind === 209 /* ModuleBlock */) { emitTempDeclarations(true); } decreaseIndent(); @@ -27394,7 +27838,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 180 /* Block */) { + if (node.kind === 182 /* Block */) { write(" "); emit(node); } @@ -27406,7 +27850,7 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 164 /* ArrowFunction */); + emitParenthesizedIf(node.expression, node.expression.kind === 166 /* ArrowFunction */); write(";"); } function emitIfStatement(node) { @@ -27419,7 +27863,7 @@ var ts; if (node.elseStatement) { writeLine(); emitToken(76 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 184 /* IfStatement */) { + if (node.elseStatement.kind === 186 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -27431,7 +27875,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 180 /* Block */) { + if (node.statement.kind === 182 /* Block */) { write(" "); } else { @@ -27506,7 +27950,7 @@ var ts; var endPos = emitToken(82 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer && node.initializer.kind === 200 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 202 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -27527,13 +27971,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 /* ES6 */ && node.kind === 189 /* ForOfStatement */) { + if (languageVersion < 2 /* ES6 */ && node.kind === 191 /* ForOfStatement */) { return emitDownLevelForOfStatement(node); } var endPos = emitToken(82 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer.kind === 200 /* VariableDeclarationList */) { + if (node.initializer.kind === 202 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -27543,7 +27987,7 @@ var ts; else { emit(node.initializer); } - if (node.kind === 188 /* ForInStatement */) { + if (node.kind === 190 /* ForInStatement */) { write(" in "); } else { @@ -27628,7 +28072,7 @@ var ts; // let v = _a[_i]; var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 200 /* VariableDeclarationList */) { + if (node.initializer.kind === 202 /* VariableDeclarationList */) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -27658,7 +28102,7 @@ var ts; // Initializer is an expression. Emit the expression in the body, so that it's // evaluated on every iteration. var assignmentExpression = createBinaryExpression(node.initializer, 53 /* EqualsToken */, rhsIterationValue, false); - if (node.initializer.kind === 154 /* ArrayLiteralExpression */ || node.initializer.kind === 155 /* ObjectLiteralExpression */) { + if (node.initializer.kind === 156 /* ArrayLiteralExpression */ || node.initializer.kind === 157 /* ObjectLiteralExpression */) { // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. emitDestructuring(assignmentExpression, true, undefined); @@ -27669,7 +28113,7 @@ var ts; } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 180 /* Block */) { + if (node.statement.kind === 182 /* Block */) { emitLines(node.statement.statements); } else { @@ -27681,7 +28125,7 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 191 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 193 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } @@ -27726,7 +28170,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 221 /* CaseClause */) { + if (node.kind === 223 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -27781,7 +28225,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 206 /* ModuleDeclaration */); + } while (node && node.kind !== 208 /* ModuleDeclaration */); return node; } function emitContainingModuleName(node) { @@ -27806,7 +28250,7 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(7 /* NumericLiteral */); zero.text = "0"; - var result = ts.createSynthesizedNode(167 /* VoidExpression */); + var result = ts.createSynthesizedNode(169 /* VoidExpression */); result.expression = zero; return result; } @@ -27882,15 +28326,15 @@ var ts; // Also temporary variables should be explicitly allocated for source level declarations when module target is system // because actual variable declarations are hoisted var canDefineTempVariablesInPlace = false; - if (root.kind === 199 /* VariableDeclaration */) { + if (root.kind === 201 /* VariableDeclaration */) { var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 130 /* Parameter */) { + else if (root.kind === 131 /* Parameter */) { canDefineTempVariablesInPlace = true; } - if (root.kind === 170 /* BinaryExpression */) { + if (root.kind === 172 /* BinaryExpression */) { emitAssignmentExpression(root); } else { @@ -27901,8 +28345,7 @@ var ts; if (emitCount++) { write(", "); } - renameNonTopLevelLetAndConst(name); - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 199 /* VariableDeclaration */ || name.parent.kind === 153 /* BindingElement */); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 201 /* VariableDeclaration */ || name.parent.kind === 155 /* BindingElement */); var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(exportFunctionForFile + "(\""); @@ -27937,14 +28380,14 @@ var ts; // we need to generate a temporary variable value = ensureIdentifier(value); // Return the expression 'value === void 0 ? defaultValue : value' - var equals = ts.createSynthesizedNode(170 /* BinaryExpression */); + var equals = ts.createSynthesizedNode(172 /* BinaryExpression */); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(30 /* EqualsEqualsEqualsToken */); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(171 /* ConditionalExpression */); + var cond = ts.createSynthesizedNode(173 /* ConditionalExpression */); cond.condition = condition; cond.questionToken = ts.createSynthesizedNode(50 /* QuestionToken */); cond.whenTrue = whenTrue; @@ -27958,13 +28401,17 @@ var ts; return node; } function createPropertyAccessForDestructuringProperty(object, propName) { - if (propName.kind !== 65 /* Identifier */) { - return createElementAccessExpression(object, propName); + // We create a synthetic copy of the identifier in order to avoid the rewriting that might + // otherwise occur when the identifier is emitted. + var syntheticName = ts.createSynthesizedNode(propName.kind); + syntheticName.text = propName.text; + if (syntheticName.kind !== 65 /* Identifier */) { + return createElementAccessExpression(object, syntheticName); } - return createPropertyAccessExpression(object, propName); + return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(158 /* CallExpression */); + var call = ts.createSynthesizedNode(160 /* CallExpression */); var sliceIdentifier = ts.createSynthesizedNode(65 /* Identifier */); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); @@ -27981,9 +28428,8 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 225 /* PropertyAssignment */ || p.kind === 226 /* ShorthandPropertyAssignment */) { - // TODO(andersh): Computed property support - var propName = (p.name); + if (p.kind === 227 /* PropertyAssignment */ || p.kind === 228 /* ShorthandPropertyAssignment */) { + var propName = p.name; emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } } @@ -27997,8 +28443,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 176 /* OmittedExpression */) { - if (e.kind !== 174 /* SpreadElementExpression */) { + if (e.kind !== 178 /* OmittedExpression */) { + if (e.kind !== 176 /* SpreadElementExpression */) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -28008,14 +28454,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 170 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { + if (target.kind === 172 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 155 /* ObjectLiteralExpression */) { + if (target.kind === 157 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 154 /* ArrayLiteralExpression */) { + else if (target.kind === 156 /* ArrayLiteralExpression */) { emitArrayLiteralAssignment(target, value); } else { @@ -28029,14 +28475,14 @@ var ts; emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 162 /* ParenthesizedExpression */) { + if (root.parent.kind !== 164 /* ParenthesizedExpression */) { write("("); } value = ensureIdentifier(value); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 162 /* ParenthesizedExpression */) { + if (root.parent.kind !== 164 /* ParenthesizedExpression */) { write(")"); } } @@ -28060,12 +28506,12 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 151 /* ObjectBindingPattern */) { + if (pattern.kind === 153 /* ObjectBindingPattern */) { // Rewrite element to a declaration with an initializer that fetches property var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 176 /* OmittedExpression */) { + else if (element.kind !== 178 /* OmittedExpression */) { if (!element.dotDotDotToken) { // Rewrite element to a declaration that accesses array element at index i emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); @@ -28092,7 +28538,6 @@ var ts; } } else { - renameNonTopLevelLetAndConst(node.name); var initializer = node.initializer; if (!initializer && languageVersion < 2 /* ES6 */) { // downlevel emit for non-initialized let bindings defined in loops @@ -28105,8 +28550,8 @@ var ts; (getCombinedFlagsForIdentifier(node.name) & 4096 /* Let */); // NOTE: default initialization should not be added to let bindings in for-in\for-of statements if (isUninitializedLet && - node.parent.parent.kind !== 188 /* ForInStatement */ && - node.parent.parent.kind !== 189 /* ForOfStatement */) { + node.parent.parent.kind !== 190 /* ForInStatement */ && + node.parent.parent.kind !== 191 /* ForOfStatement */) { initializer = createVoidZero(); } } @@ -28124,7 +28569,7 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 176 /* OmittedExpression */) { + if (node.kind === 178 /* OmittedExpression */) { return; } var name = node.name; @@ -28136,56 +28581,15 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 199 /* VariableDeclaration */ && node.parent.kind !== 153 /* BindingElement */)) { + if (!node.parent || (node.parent.kind !== 201 /* VariableDeclaration */ && node.parent.kind !== 155 /* BindingElement */)) { return 0; } return ts.getCombinedNodeFlags(node.parent); } - function renameNonTopLevelLetAndConst(node) { - // do not rename if - // - language version is ES6+ - // - node is synthesized - // - node is not identifier (can happen when tree is malformed) - // - node is definitely not name of variable declaration. - // it still can be part of parameter declaration, this check will be done next - if (languageVersion >= 2 /* ES6 */ || - ts.nodeIsSynthesized(node) || - node.kind !== 65 /* Identifier */ || - (node.parent.kind !== 199 /* VariableDeclaration */ && node.parent.kind !== 153 /* BindingElement */)) { - return; - } - var combinedFlags = getCombinedFlagsForIdentifier(node); - if (((combinedFlags & 12288 /* BlockScoped */) === 0) || combinedFlags & 1 /* Export */) { - // do not rename exported or non-block scoped variables - return; - } - // here it is known that node is a block scoped variable - var list = ts.getAncestor(node, 200 /* VariableDeclarationList */); - if (list.parent.kind === 181 /* VariableStatement */) { - var isSourceFileLevelBinding = list.parent.parent.kind === 228 /* SourceFile */; - var isModuleLevelBinding = list.parent.parent.kind === 207 /* ModuleBlock */; - var isFunctionLevelBinding = list.parent.parent.kind === 180 /* Block */ && ts.isFunctionLike(list.parent.parent.parent); - if (isSourceFileLevelBinding || isModuleLevelBinding || isFunctionLevelBinding) { - return; - } - } - var blockScopeContainer = ts.getEnclosingBlockScopeContainer(node); - var parent = blockScopeContainer.kind === 228 /* SourceFile */ - ? blockScopeContainer - : blockScopeContainer.parent; - if (resolver.resolvesToSomeValue(parent, node.text)) { - var variableId = resolver.getBlockScopedVariableId(node); - if (!blockScopedVariableToGeneratedName) { - blockScopedVariableToGeneratedName = []; - } - var generatedName = makeUniqueName(node.text); - blockScopedVariableToGeneratedName[variableId] = generatedName; - } - } function isES6ExportedDeclaration(node) { return !!(node.flags & 1 /* Export */) && languageVersion >= 2 /* ES6 */ && - node.parent.kind === 228 /* SourceFile */; + node.parent.kind === 230 /* SourceFile */; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -28236,12 +28640,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2 /* ES6 */) { if (ts.isBindingPattern(node.name)) { - var name_23 = createTempVariable(0 /* Auto */); + var name_20 = createTempVariable(0 /* Auto */); if (!tempParameters) { tempParameters = []; } - tempParameters.push(name_23); - emit(name_23); + tempParameters.push(name_20); + emit(name_20); } else { emit(node.name); @@ -28332,12 +28736,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 137 /* GetAccessor */ ? "get " : "set "); - emit(node.name, false); + write(node.kind === 138 /* GetAccessor */ ? "get " : "set "); + emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 164 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; + return node.kind === 166 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; } function emitDeclarationName(node) { if (node.name) { @@ -28348,11 +28752,11 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 163 /* FunctionExpression */) { + if (node.kind === 165 /* FunctionExpression */) { // Emit name if one is present return !!node.name; } - if (node.kind === 201 /* FunctionDeclaration */) { + if (node.kind === 203 /* FunctionDeclaration */) { // Emit name if one is present, or emit generated name in down-level case (for export default case) return !!node.name || languageVersion < 2 /* ES6 */; } @@ -28361,7 +28765,7 @@ var ts; if (ts.nodeIsMissing(node.body)) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 135 /* MethodDeclaration */ && node.kind !== 134 /* MethodSignature */) { + if (node.kind !== 136 /* MethodDeclaration */ && node.kind !== 135 /* MethodSignature */) { // Methods will emit the comments as part of emitting method declaration emitLeadingComments(node); } @@ -28384,10 +28788,10 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 /* ES6 */ && node.kind === 201 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 /* ES6 */ && node.kind === 203 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 135 /* MethodDeclaration */ && node.kind !== 134 /* MethodSignature */) { + if (node.kind !== 136 /* MethodDeclaration */ && node.kind !== 135 /* MethodSignature */) { emitTrailingComments(node); } } @@ -28438,7 +28842,7 @@ var ts; // in that case. write(" { }"); } - else if (node.body.kind === 180 /* Block */) { + else if (node.body.kind === 182 /* Block */) { emitBlockFunctionBody(node, node.body); } else { @@ -28469,10 +28873,10 @@ var ts; write(" "); // Unwrap all type assertions. var current = body; - while (current.kind === 161 /* TypeAssertionExpression */) { + while (current.kind === 163 /* TypeAssertionExpression */) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 155 /* ObjectLiteralExpression */); + emitParenthesizedIf(body, current.kind === 157 /* ObjectLiteralExpression */); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -28548,9 +28952,9 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 183 /* ExpressionStatement */) { + if (statement && statement.kind === 185 /* ExpressionStatement */) { var expr = statement.expression; - if (expr && expr.kind === 158 /* CallExpression */) { + if (expr && expr.kind === 160 /* CallExpression */) { var func = expr.expression; if (func && func.kind === 91 /* SuperKeyword */) { return statement; @@ -28582,7 +28986,7 @@ var ts; emitNodeWithoutSourceMap(memberName); write("]"); } - else if (memberName.kind === 128 /* ComputedPropertyName */) { + else if (memberName.kind === 129 /* ComputedPropertyName */) { emitComputedPropertyName(memberName); } else { @@ -28594,7 +28998,7 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 133 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { + if (member.kind === 134 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { properties.push(member); } } @@ -28634,11 +29038,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 179 /* SemicolonClassElement */) { + if (member.kind === 181 /* SemicolonClassElement */) { writeLine(); write(";"); } - else if (member.kind === 135 /* MethodDeclaration */ || node.kind === 134 /* MethodSignature */) { + else if (member.kind === 136 /* MethodDeclaration */ || node.kind === 135 /* MethodSignature */) { if (!member.body) { return emitOnlyPinnedOrTripleSlashComments(member); } @@ -28657,7 +29061,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 137 /* GetAccessor */ || member.kind === 138 /* SetAccessor */) { + else if (member.kind === 138 /* GetAccessor */ || member.kind === 139 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -28707,22 +29111,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 135 /* MethodDeclaration */ || node.kind === 134 /* MethodSignature */) && !member.body) { + if ((member.kind === 136 /* MethodDeclaration */ || node.kind === 135 /* MethodSignature */) && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - else if (member.kind === 135 /* MethodDeclaration */ || - member.kind === 137 /* GetAccessor */ || - member.kind === 138 /* SetAccessor */) { + else if (member.kind === 136 /* MethodDeclaration */ || + member.kind === 138 /* GetAccessor */ || + member.kind === 139 /* SetAccessor */) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128 /* Static */) { write("static "); } - if (member.kind === 137 /* GetAccessor */) { + if (member.kind === 138 /* GetAccessor */) { write("get "); } - else if (member.kind === 138 /* SetAccessor */) { + else if (member.kind === 139 /* SetAccessor */) { write("set "); } if (member.asteriskToken) { @@ -28733,7 +29137,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 179 /* SemicolonClassElement */) { + else if (member.kind === 181 /* SemicolonClassElement */) { writeLine(); write(";"); } @@ -28758,11 +29162,11 @@ var ts; var hasInstancePropertyWithInitializer = false; // Emit the constructor overload pinned comments ts.forEach(node.members, function (member) { - if (member.kind === 136 /* Constructor */ && !member.body) { + if (member.kind === 137 /* Constructor */ && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } // Check if there is any non-static property assignment - if (member.kind === 133 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { + if (member.kind === 134 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -28870,7 +29274,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { if (thisNodeIsDecorated) { // To preserve the correct runtime semantics when decorators are applied to the class, // the emit needs to follow one of the following rules: @@ -28950,7 +29354,7 @@ var ts; // This keeps the expression as an expression, while ensuring that the static parts // of it have been initialized by the time it is used. var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 175 /* ClassExpression */; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 177 /* ClassExpression */; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0 /* Auto */); @@ -29034,7 +29438,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { // source file level classes in system modules are hoisted so 'var's for them are already defined if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); @@ -29093,11 +29497,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { write(";"); } emitEnd(node); - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { emitExportMemberAssignment(node); } if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile && node.name) { @@ -29189,7 +29593,7 @@ var ts; else { decorators = member.decorators; // we only decorate the parameters here if this is a method - if (member.kind === 135 /* MethodDeclaration */) { + if (member.kind === 136 /* MethodDeclaration */) { functionLikeMember = member; } } @@ -29227,7 +29631,7 @@ var ts; // writeLine(); emitStart(member); - if (member.kind !== 133 /* PropertyDeclaration */) { + if (member.kind !== 134 /* PropertyDeclaration */) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -29257,7 +29661,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 133 /* PropertyDeclaration */) { + if (member.kind !== 134 /* PropertyDeclaration */) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -29299,10 +29703,10 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 135 /* MethodDeclaration */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 133 /* PropertyDeclaration */: + case 136 /* MethodDeclaration */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 134 /* PropertyDeclaration */: return true; } return false; @@ -29312,7 +29716,7 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 135 /* MethodDeclaration */: + case 136 /* MethodDeclaration */: return true; } return false; @@ -29322,9 +29726,9 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 202 /* ClassDeclaration */: - case 135 /* MethodDeclaration */: - case 138 /* SetAccessor */: + case 204 /* ClassDeclaration */: + case 136 /* MethodDeclaration */: + case 139 /* SetAccessor */: return true; } return false; @@ -29335,7 +29739,7 @@ var ts; var argumentsWritten = 0; if (compilerOptions.emitDecoratorMetadata) { if (shouldEmitTypeMetadata(node)) { - var serializedType = resolver.serializeTypeOfNode(node, getGeneratedNameForNode); + var serializedType = resolver.serializeTypeOfNode(node); if (serializedType) { if (writeComma) { write(", "); @@ -29348,7 +29752,7 @@ var ts; } } if (shouldEmitParamTypesMetadata(node)) { - var serializedTypes = resolver.serializeParameterTypesOfNode(node, getGeneratedNameForNode); + var serializedTypes = resolver.serializeParameterTypesOfNode(node); if (serializedTypes) { if (writeComma || argumentsWritten) { write(", "); @@ -29366,7 +29770,7 @@ var ts; } } if (shouldEmitReturnTypeMetadata(node)) { - var serializedType = resolver.serializeReturnTypeOfNode(node, getGeneratedNameForNode); + var serializedType = resolver.serializeReturnTypeOfNode(node); if (serializedType) { if (writeComma || argumentsWritten) { write(", "); @@ -29500,7 +29904,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 206 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 208 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -29536,7 +29940,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 207 /* ModuleBlock */) { + if (node.body.kind === 209 /* ModuleBlock */) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -29594,16 +29998,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 209 /* ImportEqualsDeclaration */) { + if (node.kind === 211 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 212 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 214 /* NamespaceImport */) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 210 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + return node.kind === 212 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -29631,7 +30035,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 212 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 214 /* NamespaceImport */) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -29657,7 +30061,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 209 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; + var isExportedImport = node.kind === 211 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2 /* AMD */) { emitLeadingComments(node); @@ -29676,7 +30080,7 @@ var ts; // import { x, y } from "foo" // import d, * as x from "foo" // import d, { x, y } from "foo" - var isNakedImport = 210 /* ImportDeclaration */ && !node.importClause; + var isNakedImport = 212 /* ImportDeclaration */ && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -29840,8 +30244,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 201 /* FunctionDeclaration */ && - expression.kind !== 202 /* ClassDeclaration */) { + if (expression.kind !== 203 /* FunctionDeclaration */ && + expression.kind !== 204 /* ClassDeclaration */) { write(";"); } emitEnd(node); @@ -29877,7 +30281,7 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { // import "mod" @@ -29887,13 +30291,13 @@ var ts; externalImports.push(node); } break; - case 209 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 220 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { + case 211 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 222 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { // import x = require("mod") where x is referenced externalImports.push(node); } break; - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -29909,12 +30313,12 @@ var ts; // export { x, y } for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; - var name_24 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_24] || (exportSpecifiers[name_24] = [])).push(specifier); + var name_21 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_21] || (exportSpecifiers[name_21] = [])).push(specifier); } } break; - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -29935,13 +30339,16 @@ var ts; write("}"); } } - function getLocalNameForExternalImport(importNode) { - var namespaceDeclaration = getNamespaceDeclarationNode(importNode); - if (namespaceDeclaration && !isDefaultImport(importNode)) { + function getLocalNameForExternalImport(node) { + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - else { - return getGeneratedNameForNode(importNode); + if (node.kind === 212 /* ImportDeclaration */ && node.importClause) { + return getGeneratedNameForNode(node); + } + if (node.kind === 218 /* ExportDeclaration */ && node.moduleSpecifier) { + return getGeneratedNameForNode(node); } } function getExternalModuleNameText(importNode) { @@ -29960,8 +30367,8 @@ var ts; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; // do not create variable declaration for exports and imports that lack import clause - var skipNode = importNode.kind === 216 /* ExportDeclaration */ || - (importNode.kind === 210 /* ImportDeclaration */ && !importNode.importClause); + var skipNode = importNode.kind === 218 /* ExportDeclaration */ || + (importNode.kind === 212 /* ImportDeclaration */ && !importNode.importClause); if (skipNode) { continue; } @@ -29994,7 +30401,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 216 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 218 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -30026,7 +30433,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 216 /* ExportDeclaration */) { + if (externalImport.kind !== 218 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -30110,12 +30517,12 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_25 = local.kind === 65 /* Identifier */ + var name_22 = local.kind === 65 /* Identifier */ ? local : local.name; - if (name_25) { + if (name_22) { // do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables - var text = ts.unescapeIdentifier(name_25.text); + var text = ts.unescapeIdentifier(name_22.text); if (ts.hasProperty(seen, text)) { continue; } @@ -30126,7 +30533,7 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 202 /* ClassDeclaration */ || local.kind === 206 /* ModuleDeclaration */ || local.kind === 205 /* EnumDeclaration */) { + if (local.kind === 204 /* ClassDeclaration */ || local.kind === 208 /* ModuleDeclaration */ || local.kind === 207 /* EnumDeclaration */) { emitDeclarationName(local); } else { @@ -30160,21 +30567,21 @@ var ts; if (node.flags & 2 /* Ambient */) { return; } - if (node.kind === 201 /* FunctionDeclaration */) { + if (node.kind === 203 /* FunctionDeclaration */) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 205 /* EnumDeclaration */) { + if (node.kind === 207 /* EnumDeclaration */) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -30183,7 +30590,7 @@ var ts; } return; } - if (node.kind === 206 /* ModuleDeclaration */) { + if (node.kind === 208 /* ModuleDeclaration */) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -30192,17 +30599,17 @@ var ts; } return; } - if (node.kind === 199 /* VariableDeclaration */ || node.kind === 153 /* BindingElement */) { + if (node.kind === 201 /* VariableDeclaration */ || node.kind === 155 /* BindingElement */) { if (shouldHoistVariable(node, false)) { - var name_26 = node.name; - if (name_26.kind === 65 /* Identifier */) { + var name_23 = node.name; + if (name_23.kind === 65 /* Identifier */) { if (!hoistedVars) { hoistedVars = []; } - hoistedVars.push(name_26); + hoistedVars.push(name_23); } else { - ts.forEachChild(name_26, visit); + ts.forEachChild(name_23, visit); } } return; @@ -30226,7 +30633,7 @@ var ts; // if block scoped variables are nested in some another block then // no other functions can use them except ones that are defined at least in the same block return (ts.getCombinedNodeFlags(node) & 12288 /* BlockScoped */) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 228 /* SourceFile */; + ts.getEnclosingBlockScopeContainer(node).kind === 230 /* SourceFile */; } function isCurrentFileSystemExternalModule() { return compilerOptions.module === 4 /* System */ && ts.isExternalModule(currentSourceFile); @@ -30279,10 +30686,10 @@ var ts; emitSetters(exportStarFunction); writeLine(); emitExecute(node, startIndex); - emitTempDeclarations(true); decreaseIndent(); writeLine(); write("}"); // return + emitTempDeclarations(true); } function emitSetters(exportStarFunction) { write("setters:["); @@ -30297,21 +30704,21 @@ var ts; var parameterName = "_" + importVariableName; write("function (" + parameterName + ") {"); switch (importNode.kind) { - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: if (!importNode.importClause) { // 'import "..."' case // module is imported only for side-effects, setter body will be empty break; } // fall-through - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== ""); increaseIndent(); writeLine(); // save import into the local write(importVariableName + " = " + parameterName + ";"); writeLine(); - var defaultName = importNode.kind === 210 /* ImportDeclaration */ + var defaultName = importNode.kind === 212 /* ImportDeclaration */ ? importNode.importClause.name : importNode.name; if (defaultName) { @@ -30323,10 +30730,10 @@ var ts; emitExportMemberAssignments(defaultName); writeLine(); } - if (importNode.kind === 210 /* ImportDeclaration */ && + if (importNode.kind === 212 /* ImportDeclaration */ && importNode.importClause.namedBindings) { var namedBindings = importNode.importClause.namedBindings; - if (namedBindings.kind === 212 /* NamespaceImport */) { + if (namedBindings.kind === 214 /* NamespaceImport */) { // emit re-export for namespace // import * as n from 'foo' // export {n} @@ -30346,7 +30753,7 @@ var ts; } decreaseIndent(); break; - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== ""); increaseIndent(); if (importNode.exportClause) { @@ -30389,10 +30796,10 @@ var ts; // - imports/exports are not emitted for system modules // - function declarations are not emitted because they were already hoisted switch (statement.kind) { - case 216 /* ExportDeclaration */: - case 210 /* ImportDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 201 /* FunctionDeclaration */: + case 218 /* ExportDeclaration */: + case 212 /* ImportDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 203 /* FunctionDeclaration */: continue; } writeLine(); @@ -30415,7 +30822,11 @@ var ts; ts.Debug.assert(!exportFunctionForFile); // make sure that name of 'exports' function does not conflict with existing identifiers exportFunctionForFile = makeUniqueName("exports"); - write("System.register(["); + write("System.register("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + write("["); for (var i = 0; i < externalImports.length; ++i) { var text = getExternalModuleNameText(externalImports[i]); if (i !== 0) { @@ -30495,8 +30906,8 @@ var ts; collectExternalModuleInfo(node); writeLine(); write("define("); - if (node.amdModuleName) { - write("\"" + node.amdModuleName + "\", "); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); } emitAMDDependencies(node, true); write(") {"); @@ -30634,7 +31045,7 @@ var ts; } emitLeadingComments(node.endOfFileToken); } - function emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers) { + function emitNodeWithoutSourceMap(node) { if (!node) { return; } @@ -30645,7 +31056,7 @@ var ts; if (emitComments) { emitLeadingComments(node); } - emitJavaScriptWorker(node, allowGeneratedIdentifiers); + emitJavaScriptWorker(node); if (emitComments) { emitTrailingComments(node); } @@ -30654,20 +31065,20 @@ var ts; switch (node.kind) { // All of these entities are emitted in a specialized fashion. As such, we allow // the specialized methods for each to handle the comments on the nodes. - case 203 /* InterfaceDeclaration */: - case 201 /* FunctionDeclaration */: - case 210 /* ImportDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 215 /* ExportAssignment */: + case 205 /* InterfaceDeclaration */: + case 203 /* FunctionDeclaration */: + case 212 /* ImportDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 217 /* ExportAssignment */: return false; - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: // Only emit the leading/trailing comments for a module if we're actually // emitting the module as well. return shouldEmitModuleDeclaration(node); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: // Only emit the leading/trailing comments for an enum if we're actually // emitting the module as well. return shouldEmitEnumDeclaration(node); @@ -30676,9 +31087,9 @@ var ts; // then we don't want to emit comments when we emit the body. It will have already // been taken care of when we emitted the 'return' statement for the function // expression body. - if (node.kind !== 180 /* Block */ && + if (node.kind !== 182 /* Block */ && node.parent && - node.parent.kind === 164 /* ArrowFunction */ && + node.parent.kind === 166 /* ArrowFunction */ && node.parent.body === node && compilerOptions.target <= 1 /* ES5 */) { return false; @@ -30686,19 +31097,18 @@ var ts; // Emit comments for everything else. return true; } - function emitJavaScriptWorker(node, allowGeneratedIdentifiers) { - if (allowGeneratedIdentifiers === void 0) { allowGeneratedIdentifiers = true; } + function emitJavaScriptWorker(node) { // Check if the node can be emitted regardless of the ScriptTarget switch (node.kind) { case 65 /* Identifier */: - return emitIdentifier(node, allowGeneratedIdentifiers); - case 130 /* Parameter */: + return emitIdentifier(node); + case 131 /* Parameter */: return emitParameter(node); - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return emitMethod(node); - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: return emitAccessor(node); case 93 /* ThisKeyword */: return emitThis(node); @@ -30718,131 +31128,131 @@ var ts; case 12 /* TemplateMiddle */: case 13 /* TemplateTail */: return emitLiteral(node); - case 172 /* TemplateExpression */: + case 174 /* TemplateExpression */: return emitTemplateExpression(node); - case 178 /* TemplateSpan */: + case 180 /* TemplateSpan */: return emitTemplateSpan(node); - case 127 /* QualifiedName */: + case 128 /* QualifiedName */: return emitQualifiedName(node); - case 151 /* ObjectBindingPattern */: + case 153 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 152 /* ArrayBindingPattern */: + case 154 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 153 /* BindingElement */: + case 155 /* BindingElement */: return emitBindingElement(node); - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: return emitArrayLiteral(node); - case 155 /* ObjectLiteralExpression */: + case 157 /* ObjectLiteralExpression */: return emitObjectLiteral(node); - case 225 /* PropertyAssignment */: + case 227 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 226 /* ShorthandPropertyAssignment */: + case 228 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: return emitComputedPropertyName(node); - case 156 /* PropertyAccessExpression */: + case 158 /* PropertyAccessExpression */: return emitPropertyAccess(node); - case 157 /* ElementAccessExpression */: + case 159 /* ElementAccessExpression */: return emitIndexedAccess(node); - case 158 /* CallExpression */: + case 160 /* CallExpression */: return emitCallExpression(node); - case 159 /* NewExpression */: + case 161 /* NewExpression */: return emitNewExpression(node); - case 160 /* TaggedTemplateExpression */: + case 162 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: return emit(node.expression); - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return emitParenExpression(node); - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 165 /* DeleteExpression */: + case 167 /* DeleteExpression */: return emitDeleteExpression(node); - case 166 /* TypeOfExpression */: + case 168 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 167 /* VoidExpression */: + case 169 /* VoidExpression */: return emitVoidExpression(node); - case 168 /* PrefixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 169 /* PostfixUnaryExpression */: + case 171 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return emitBinaryExpression(node); - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: return emitConditionalExpression(node); - case 174 /* SpreadElementExpression */: + case 176 /* SpreadElementExpression */: return emitSpreadElementExpression(node); - case 173 /* YieldExpression */: + case 175 /* YieldExpression */: return emitYieldExpression(node); - case 176 /* OmittedExpression */: + case 178 /* OmittedExpression */: return; - case 180 /* Block */: - case 207 /* ModuleBlock */: + case 182 /* Block */: + case 209 /* ModuleBlock */: return emitBlock(node); - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: return emitVariableStatement(node); - case 182 /* EmptyStatement */: + case 184 /* EmptyStatement */: return write(";"); - case 183 /* ExpressionStatement */: + case 185 /* ExpressionStatement */: return emitExpressionStatement(node); - case 184 /* IfStatement */: + case 186 /* IfStatement */: return emitIfStatement(node); - case 185 /* DoStatement */: + case 187 /* DoStatement */: return emitDoStatement(node); - case 186 /* WhileStatement */: + case 188 /* WhileStatement */: return emitWhileStatement(node); - case 187 /* ForStatement */: + case 189 /* ForStatement */: return emitForStatement(node); - case 189 /* ForOfStatement */: - case 188 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 190 /* ForInStatement */: return emitForInOrForOfStatement(node); - case 190 /* ContinueStatement */: - case 191 /* BreakStatement */: + case 192 /* ContinueStatement */: + case 193 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 192 /* ReturnStatement */: + case 194 /* ReturnStatement */: return emitReturnStatement(node); - case 193 /* WithStatement */: + case 195 /* WithStatement */: return emitWithStatement(node); - case 194 /* SwitchStatement */: + case 196 /* SwitchStatement */: return emitSwitchStatement(node); - case 221 /* CaseClause */: - case 222 /* DefaultClause */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: return emitLabelledStatement(node); - case 196 /* ThrowStatement */: + case 198 /* ThrowStatement */: return emitThrowStatement(node); - case 197 /* TryStatement */: + case 199 /* TryStatement */: return emitTryStatement(node); - case 224 /* CatchClause */: + case 226 /* CatchClause */: return emitCatchClause(node); - case 198 /* DebuggerStatement */: + case 200 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 199 /* VariableDeclaration */: + case 201 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 175 /* ClassExpression */: + case 177 /* ClassExpression */: return emitClassExpression(node); - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: return emitClassDeclaration(node); - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 227 /* EnumMember */: + case 229 /* EnumMember */: return emitEnumMember(node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: return emitImportDeclaration(node); - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: return emitExportDeclaration(node); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return emitExportAssignment(node); - case 228 /* SourceFile */: + case 230 /* SourceFile */: return emitSourceFileNode(node); } } @@ -30874,7 +31284,7 @@ var ts; function getLeadingCommentsToEmit(node) { // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 228 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 230 /* SourceFile */ || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { // get comments without detached comments return getLeadingCommentsWithoutDetachedComments(); @@ -30889,7 +31299,7 @@ var ts; function getTrailingCommentsToEmit(node) { // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 228 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 230 /* SourceFile */ || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } @@ -31086,7 +31496,7 @@ var ts; } ts.createCompilerHost = createCompilerHost; function getPreEmitDiagnostics(program, sourceFile) { - var diagnostics = program.getSyntacticDiagnostics(sourceFile).concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics(sourceFile)); + var diagnostics = program.getOptionsDiagnostics().concat(program.getSyntacticDiagnostics(sourceFile), program.getGlobalDiagnostics(), program.getSemanticDiagnostics(sourceFile)); if (program.getCompilerOptions().declaration) { diagnostics.concat(program.getDeclarationDiagnostics(sourceFile)); } @@ -31119,16 +31529,21 @@ var ts; function createProgram(rootNames, options, host) { var program; var files = []; - var filesByName = {}; var diagnostics = ts.createDiagnosticCollection(); - var seenNoDefaultLib = options.noLib; var commonSourceDirectory; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; + var classifiableNames; + var skipDefaultLib = options.noLib; var start = new Date().getTime(); host = host || createCompilerHost(options); + var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); }); ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - if (!seenNoDefaultLib) { + // Do not process the default library if: + // - The '--noLib' flag is used. + // - A 'no-default-lib' reference comment is encountered in + // processing the root files. + if (!skipDefaultLib) { processRootFile(host.getDefaultLibFileName(options), true); } verifyCompilerOptions(); @@ -31138,11 +31553,12 @@ var ts; getSourceFiles: function () { return files; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, + getOptionsDiagnostics: getOptionsDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, getSemanticDiagnostics: getSemanticDiagnostics, getDeclarationDiagnostics: getDeclarationDiagnostics, - getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics, getTypeChecker: getTypeChecker, + getClassifiableNames: getClassifiableNames, getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker, getCommonSourceDirectory: function () { return commonSourceDirectory; }, emit: emit, @@ -31153,6 +31569,18 @@ var ts; getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); } }; return program; + function getClassifiableNames() { + if (!classifiableNames) { + // Initialize a checker so that all our files are bound. + getTypeChecker(); + classifiableNames = {}; + for (var _i = 0; _i < files.length; _i++) { + var sourceFile = files[_i]; + ts.copyMap(sourceFile.classifiableNames, classifiableNames); + } + } + return classifiableNames; + } function getEmitHost(writeFileCallback) { return { getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, @@ -31192,8 +31620,7 @@ var ts; return emitResult; } function getSourceFile(fileName) { - fileName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - return ts.hasProperty(filesByName, fileName) ? filesByName[fileName] : undefined; + return filesByName.get(fileName); } function getDiagnosticsHelper(sourceFile, getDiagnostics) { if (sourceFile) { @@ -31233,16 +31660,14 @@ var ts; return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); } } - function getCompilerOptionsDiagnostics() { + function getOptionsDiagnostics() { var allDiagnostics = []; ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function getGlobalDiagnostics() { - var typeChecker = getDiagnosticsProducingTypeChecker(); var allDiagnostics = []; - ts.addRange(allDiagnostics, typeChecker.getGlobalDiagnostics()); - ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); + ts.addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function hasExtension(fileName) { @@ -31276,14 +31701,17 @@ var ts; } } else { - if (options.allowNonTsExtensions && !findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd)) { - diagnostic = ts.Diagnostics.File_0_not_found; - diagnosticArgument = [fileName]; - } - else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, isDefaultLib, refFile, refPos, refEnd); })) { - diagnostic = ts.Diagnostics.File_0_not_found; - fileName += ".ts"; - diagnosticArgument = [fileName]; + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd); + if (!nonTsFile) { + if (options.allowNonTsExtensions) { + diagnostic = ts.Diagnostics.File_0_not_found; + diagnosticArgument = [fileName]; + } + else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, isDefaultLib, refFile, refPos, refEnd); })) { + diagnostic = ts.Diagnostics.File_0_not_found; + fileName += ".ts"; + diagnosticArgument = [fileName]; + } } } if (diagnostic) { @@ -31298,18 +31726,18 @@ var ts; // Get source file from normalized fileName function findSourceFile(fileName, isDefaultLib, refFile, refStart, refLength) { var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - if (ts.hasProperty(filesByName, canonicalName)) { + if (filesByName.contains(canonicalName)) { // We've already looked for this file, use cached result return getSourceFileFromCache(fileName, canonicalName, false); } else { var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); - if (ts.hasProperty(filesByName, canonicalAbsolutePath)) { + if (filesByName.contains(canonicalAbsolutePath)) { return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); } // We haven't looked for this file, do so now and cache result - var file = filesByName[canonicalName] = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { if (refFile) { diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } @@ -31317,16 +31745,18 @@ var ts; diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } }); + filesByName.set(canonicalName, file); if (file) { - seenNoDefaultLib = seenNoDefaultLib || file.hasNoDefaultLib; + skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; // Set the source file for normalized absolute path - filesByName[canonicalAbsolutePath] = file; + filesByName.set(canonicalAbsolutePath, file); if (!options.noResolve) { var basePath = ts.getDirectoryPath(fileName); processReferencedFiles(file, basePath); processImportedModules(file, basePath); } if (isDefaultLib) { + file.isDefaultLib = true; files.unshift(file); } else { @@ -31336,7 +31766,7 @@ var ts; return file; } function getSourceFileFromCache(fileName, canonicalName, useAbsolutePath) { - var file = filesByName[canonicalName]; + var file = filesByName.get(canonicalName); if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { @@ -31354,7 +31784,7 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 210 /* ImportDeclaration */ || node.kind === 209 /* ImportEqualsDeclaration */ || node.kind === 216 /* ExportDeclaration */) { + if (node.kind === 212 /* ImportDeclaration */ || node.kind === 211 /* ImportEqualsDeclaration */ || node.kind === 218 /* ExportDeclaration */) { var moduleNameExpr = ts.getExternalModuleName(node); if (moduleNameExpr && moduleNameExpr.kind === 8 /* StringLiteral */) { var moduleNameText = moduleNameExpr.text; @@ -31375,7 +31805,7 @@ var ts; } } } - else if (node.kind === 206 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { + else if (node.kind === 208 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { // TypeScript 1.0 spec (April 2014): 12.1.6 // An AmbientExternalModuleDeclaration declares an external module. // This type of declaration is permitted only in the global module. @@ -31656,9 +32086,14 @@ var ts; name: "noResolve", type: "boolean" }, + { + name: "skipDefaultLibCheck", + type: "boolean" + }, { name: "out", type: "string", + isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: ts.Diagnostics.FILE }, @@ -32033,7 +32468,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 164 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 166 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -32045,30 +32480,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 180 /* Block */: + case 182 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_7 = n.parent; + var parent_8 = n.parent; var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collaps the block, but consider its hint span // to be the entire span of the parent. - if (parent_7.kind === 185 /* DoStatement */ || - parent_7.kind === 188 /* ForInStatement */ || - parent_7.kind === 189 /* ForOfStatement */ || - parent_7.kind === 187 /* ForStatement */ || - parent_7.kind === 184 /* IfStatement */ || - parent_7.kind === 186 /* WhileStatement */ || - parent_7.kind === 193 /* WithStatement */ || - parent_7.kind === 224 /* CatchClause */) { - addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); + if (parent_8.kind === 187 /* DoStatement */ || + parent_8.kind === 190 /* ForInStatement */ || + parent_8.kind === 191 /* ForOfStatement */ || + parent_8.kind === 189 /* ForStatement */ || + parent_8.kind === 186 /* IfStatement */ || + parent_8.kind === 188 /* WhileStatement */ || + parent_8.kind === 195 /* WithStatement */ || + parent_8.kind === 226 /* CatchClause */) { + addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_7.kind === 197 /* TryStatement */) { + if (parent_8.kind === 199 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_7; + var tryStatement = parent_8; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -32091,23 +32526,23 @@ var ts; break; } // Fallthrough. - case 207 /* ModuleBlock */: { + case 209 /* ModuleBlock */: { var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 155 /* ObjectLiteralExpression */: - case 208 /* CaseBlock */: { + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 157 /* ObjectLiteralExpression */: + case 210 /* CaseBlock */: { var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 18 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -32135,12 +32570,12 @@ var ts; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_27 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_27); + for (var name_24 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_24); if (declarations) { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_27); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_24); if (!matches) { continue; } @@ -32153,14 +32588,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_27); + matches = patternMatcher.getMatches(containers, name_24); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_27, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_24, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -32198,7 +32633,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 128 /* ComputedPropertyName */) { + else if (declaration.name.kind === 129 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -32219,7 +32654,7 @@ var ts; } return true; } - if (expression.kind === 156 /* PropertyAccessExpression */) { + if (expression.kind === 158 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -32232,7 +32667,7 @@ var ts; var containers = []; // First, if we started with a computed property name, then add all but the last // portion into the container array. - if (declaration.name.kind === 128 /* ComputedPropertyName */) { + if (declaration.name.kind === 129 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -32308,17 +32743,17 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: // If we have a module declared as A.B.C, it is more "intuitive" // to say it only has a single layer of depth do { current = current.parent; - } while (current.kind === 206 /* ModuleDeclaration */); + } while (current.kind === 208 /* ModuleDeclaration */); // fall through - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: - case 203 /* InterfaceDeclaration */: - case 201 /* FunctionDeclaration */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 205 /* InterfaceDeclaration */: + case 203 /* FunctionDeclaration */: indent++; } current = current.parent; @@ -32329,21 +32764,21 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: ts.forEach(node.declarationList.declarations, visit); break; - case 151 /* ObjectBindingPattern */: - case 152 /* ArrayBindingPattern */: + case 153 /* ObjectBindingPattern */: + case 154 /* ArrayBindingPattern */: ts.forEach(node.elements, visit); break; - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -32355,7 +32790,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 212 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 214 /* NamespaceImport */) { childNodes.push(importClause.namedBindings); } else { @@ -32364,21 +32799,21 @@ var ts; } } break; - case 153 /* BindingElement */: - case 199 /* VariableDeclaration */: + case 155 /* BindingElement */: + case 201 /* VariableDeclaration */: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } // Fall through - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: - case 203 /* InterfaceDeclaration */: - case 206 /* ModuleDeclaration */: - case 201 /* FunctionDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 214 /* ImportSpecifier */: - case 218 /* ExportSpecifier */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 205 /* InterfaceDeclaration */: + case 208 /* ModuleDeclaration */: + case 203 /* FunctionDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 216 /* ImportSpecifier */: + case 220 /* ExportSpecifier */: childNodes.push(node); break; } @@ -32426,17 +32861,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: - case 203 /* InterfaceDeclaration */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 205 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -32447,12 +32882,12 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 201 /* FunctionDeclaration */) { + if (functionDeclaration.kind === 203 /* FunctionDeclaration */) { // A function declaration is 'top level' if it contains any function declarations // within it. - if (functionDeclaration.body && functionDeclaration.body.kind === 180 /* Block */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 182 /* Block */) { // Proper function declarations can only have identifier names - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 201 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 203 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { return true; } // Or if it is not parented by another function. i.e all functions @@ -32512,7 +32947,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 130 /* Parameter */: + case 131 /* Parameter */: if (ts.isBindingPattern(node.name)) { break; } @@ -32520,36 +32955,36 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 137 /* GetAccessor */: + case 138 /* GetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 138 /* SetAccessor */: + case 139 /* SetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 141 /* IndexSignature */: + case 142 /* IndexSignature */: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 227 /* EnumMember */: + case 229 /* EnumMember */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 139 /* CallSignature */: + case 140 /* CallSignature */: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 140 /* ConstructSignature */: + case 141 /* ConstructSignature */: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: var variableDeclarationNode; - var name_28; - if (node.kind === 153 /* BindingElement */) { - name_28 = node.name; + var name_25; + if (node.kind === 155 /* BindingElement */) { + name_25 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration - while (variableDeclarationNode && variableDeclarationNode.kind !== 199 /* VariableDeclaration */) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 201 /* VariableDeclaration */) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -32557,24 +32992,24 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_28 = node.name; + name_25 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_28), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_28), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_28), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.variableElement); } - case 136 /* Constructor */: + case 137 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 218 /* ExportSpecifier */: - case 214 /* ImportSpecifier */: - case 209 /* ImportEqualsDeclaration */: - case 211 /* ImportClause */: - case 212 /* NamespaceImport */: + case 220 /* ExportSpecifier */: + case 216 /* ImportSpecifier */: + case 211 /* ImportEqualsDeclaration */: + case 213 /* ImportClause */: + case 214 /* NamespaceImport */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -32604,17 +33039,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 228 /* SourceFile */: + case 230 /* SourceFile */: return createSourceFileItem(node); - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: return createClassItem(node); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return createEnumItem(node); - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return createIterfaceItem(node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return createModuleItem(node); - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: return createFunctionItem(node); } return undefined; @@ -32626,7 +33061,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 206 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 208 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -32638,7 +33073,7 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.body && node.body.kind === 180 /* Block */) { + if (node.body && node.body.kind === 182 /* Block */) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -32659,7 +33094,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 136 /* Constructor */ && member; + return member.kind === 137 /* Constructor */ && member; }); // Add the constructor parameters in as children of the class (for property parameters). // Note that *all non-binding pattern named* parameters will be added to the nodes array, but parameters that @@ -32683,7 +33118,7 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 128 /* ComputedPropertyName */; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 129 /* ComputedPropertyName */; }); } /** * Like removeComputedProperties, but retains the properties with well known symbol names @@ -32692,13 +33127,13 @@ var ts; return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 206 /* ModuleDeclaration */) { + while (node.body.kind === 208 /* ModuleDeclaration */) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 228 /* SourceFile */ + return node.kind === 230 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -33213,7 +33648,7 @@ var ts; var hasTransitionFromUpperToLower = transitionFromUpperToLower(identifier, word, i, wordStart); if (charIsPunctuation(identifier.charCodeAt(i - 1)) || charIsPunctuation(identifier.charCodeAt(i)) || - lastIsDigit != currentIsDigit || + lastIsDigit !== currentIsDigit || hasTransitionFromLowerToUpper || hasTransitionFromUpperToLower) { if (!isAllPunctuation(identifier, wordStart, i)) { @@ -33274,7 +33709,7 @@ var ts; // 3) HTMLDocument -> HTML, Document // // etc. - if (index != wordStart && + if (index !== wordStart && index + 1 < identifier.length) { var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index)); var nextIsLower = isLowerCaseLetter(identifier.charCodeAt(index + 1)); @@ -33493,7 +33928,7 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 158 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 160 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. @@ -33501,7 +33936,7 @@ var ts; var expression = callExpression.expression; var name = expression.kind === 65 /* Identifier */ ? expression - : expression.kind === 156 /* PropertyAccessExpression */ + : expression.kind === 158 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -33534,7 +33969,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 158 /* CallExpression */ || node.parent.kind === 159 /* NewExpression */) { + if (node.parent.kind === 160 /* CallExpression */ || node.parent.kind === 161 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -33587,25 +34022,25 @@ var ts; }; } } - else if (node.kind === 10 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 160 /* TaggedTemplateExpression */) { + else if (node.kind === 10 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 162 /* TaggedTemplateExpression */) { // Check if we're actually inside the template; // otherwise we'll fall out and return undefined. if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0); } } - else if (node.kind === 11 /* TemplateHead */ && node.parent.parent.kind === 160 /* TaggedTemplateExpression */) { + else if (node.kind === 11 /* TemplateHead */ && node.parent.parent.kind === 162 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 172 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 174 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 178 /* TemplateSpan */ && node.parent.parent.parent.kind === 160 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 180 /* TemplateSpan */ && node.parent.parent.parent.kind === 162 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 172 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 174 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. if (node.kind === 13 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; @@ -33723,7 +34158,7 @@ var ts; // // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 172 /* TemplateExpression */) { + if (template.kind === 174 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -33732,7 +34167,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 228 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 230 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -33933,40 +34368,40 @@ var ts; return false; } switch (n.kind) { - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 155 /* ObjectLiteralExpression */: - case 151 /* ObjectBindingPattern */: - case 146 /* TypeLiteral */: - case 180 /* Block */: - case 207 /* ModuleBlock */: - case 208 /* CaseBlock */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 157 /* ObjectLiteralExpression */: + case 153 /* ObjectBindingPattern */: + case 148 /* TypeLiteral */: + case 182 /* Block */: + case 209 /* ModuleBlock */: + case 210 /* CaseBlock */: return nodeEndsWith(n, 15 /* CloseBraceToken */, sourceFile); - case 224 /* CatchClause */: + case 226 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 159 /* NewExpression */: + case 161 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 158 /* CallExpression */: - case 162 /* ParenthesizedExpression */: - case 150 /* ParenthesizedType */: + case 160 /* CallExpression */: + case 164 /* ParenthesizedExpression */: + case 152 /* ParenthesizedType */: return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 140 /* ConstructSignature */: - case 139 /* CallSignature */: - case 164 /* ArrowFunction */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 141 /* ConstructSignature */: + case 140 /* CallSignature */: + case 166 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -33976,63 +34411,63 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 17 /* CloseParenToken */, sourceFile); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 184 /* IfStatement */: + case 186 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 183 /* ExpressionStatement */: + case 185 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile); - case 154 /* ArrayLiteralExpression */: - case 152 /* ArrayBindingPattern */: - case 157 /* ElementAccessExpression */: - case 128 /* ComputedPropertyName */: - case 148 /* TupleType */: + case 156 /* ArrayLiteralExpression */: + case 154 /* ArrayBindingPattern */: + case 159 /* ElementAccessExpression */: + case 129 /* ComputedPropertyName */: + case 150 /* TupleType */: return nodeEndsWith(n, 19 /* CloseBracketToken */, sourceFile); - case 141 /* IndexSignature */: + case 142 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); - case 221 /* CaseClause */: - case 222 /* DefaultClause */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed return false; - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 186 /* WhileStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 188 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 185 /* DoStatement */: + case 187 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; var hasWhileKeyword = findChildOfKind(n, 100 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 145 /* TypeQuery */: + case 147 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 166 /* TypeOfExpression */: - case 165 /* DeleteExpression */: - case 167 /* VoidExpression */: - case 173 /* YieldExpression */: - case 174 /* SpreadElementExpression */: + case 168 /* TypeOfExpression */: + case 167 /* DeleteExpression */: + case 169 /* VoidExpression */: + case 175 /* YieldExpression */: + case 176 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 160 /* TaggedTemplateExpression */: + case 162 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 172 /* TemplateExpression */: + case 174 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 178 /* TemplateSpan */: + case 180 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 168 /* PrefixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -34088,7 +34523,7 @@ var ts; // for the position of the relevant node (or comma). var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { // find syntax list that covers the span of the node - if (c.kind === 251 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 253 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -34222,7 +34657,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 228 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 230 /* SourceFile */); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -34266,17 +34701,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 142 /* TypeReference */ || node.kind === 158 /* CallExpression */) { + if (node.kind === 144 /* TypeReference */ || node.kind === 160 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 202 /* ClassDeclaration */ || node.kind === 203 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 204 /* ClassDeclaration */ || node.kind === 205 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 126 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 127 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { @@ -34331,7 +34766,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 130 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 131 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -34744,7 +35179,7 @@ var ts; if (this.tokensAreOnSameLine === undefined) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(this.currentTokenSpan.pos).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(this.nextTokenSpan.pos).line; - this.tokensAreOnSameLine = (startLine == endLine); + this.tokensAreOnSameLine = (startLine === endLine); } return this.tokensAreOnSameLine; }; @@ -34763,7 +35198,7 @@ var ts; FormattingContext.prototype.NodeIsOnOneLine = function (node) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile)).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; - return startLine == endLine; + return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { var openBrace = ts.findChildOfKind(node, 14 /* OpenBraceToken */, this.sourceFile); @@ -34923,7 +35358,7 @@ var ts; this.customContextChecks = funcs; } RuleOperationContext.prototype.IsAny = function () { - return this == RuleOperationContext.Any; + return this === RuleOperationContext.Any; }; RuleOperationContext.prototype.InContext = function (context) { if (this.IsAny()) { @@ -35029,7 +35464,7 @@ var ts; this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([96 /* TryKeyword */, 81 /* FinallyKeyword */]), 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116 /* GetKeyword */, 121 /* SetKeyword */]), 65 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116 /* GetKeyword */, 122 /* SetKeyword */]), 65 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); @@ -35037,9 +35472,9 @@ var ts; // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(114 /* ConstructorKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Use of module as a function call. e.g.: import m2 = module("m2"); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([117 /* ModuleKeyword */, 119 /* RequireKeyword */]), 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([118 /* ModuleKeyword */, 120 /* RequireKeyword */]), 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69 /* ClassKeyword */, 115 /* DeclareKeyword */, 77 /* EnumKeyword */, 78 /* ExportKeyword */, 79 /* ExtendsKeyword */, 116 /* GetKeyword */, 102 /* ImplementsKeyword */, 85 /* ImportKeyword */, 103 /* InterfaceKeyword */, 117 /* ModuleKeyword */, 118 /* NamespaceKeyword */, 106 /* PrivateKeyword */, 108 /* PublicKeyword */, 121 /* SetKeyword */, 109 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69 /* ClassKeyword */, 115 /* DeclareKeyword */, 77 /* EnumKeyword */, 78 /* ExportKeyword */, 79 /* ExtendsKeyword */, 116 /* GetKeyword */, 102 /* ImplementsKeyword */, 85 /* ImportKeyword */, 103 /* InterfaceKeyword */, 118 /* ModuleKeyword */, 119 /* NamespaceKeyword */, 106 /* PrivateKeyword */, 108 /* PublicKeyword */, 122 /* SetKeyword */, 109 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([79 /* ExtendsKeyword */, 102 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(8 /* StringLiteral */, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); @@ -35059,7 +35494,7 @@ var ts; // decorators this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 78 /* ExportKeyword */, 73 /* DefaultKeyword */, 69 /* ClassKeyword */, 109 /* StaticKeyword */, 108 /* PublicKeyword */, 106 /* PrivateKeyword */, 107 /* ProtectedKeyword */, 116 /* GetKeyword */, 121 /* SetKeyword */, 18 /* OpenBracketToken */, 35 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 78 /* ExportKeyword */, 73 /* DefaultKeyword */, 69 /* ClassKeyword */, 109 /* StaticKeyword */, 108 /* PublicKeyword */, 106 /* PrivateKeyword */, 107 /* ProtectedKeyword */, 116 /* GetKeyword */, 122 /* SetKeyword */, 18 /* OpenBracketToken */, 35 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(83 /* FunctionKeyword */, 35 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(35 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 16 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(110 /* YieldKeyword */, 35 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); @@ -35155,9 +35590,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_29 in o) { - if (o[name_29] === rule) { - return name_29; + for (var name_26 in o) { + if (o[name_26] === rule) { + return name_26; } } throw new Error("Unknown rule"); @@ -35166,36 +35601,37 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 187 /* ForStatement */; + return context.contextNode.kind === 189 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 170 /* BinaryExpression */: - case 171 /* ConditionalExpression */: + case 172 /* BinaryExpression */: + case 173 /* ConditionalExpression */: + case 143 /* TypePredicate */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 153 /* BindingElement */: + case 155 /* BindingElement */: // equals in type X = ... - case 204 /* TypeAliasDeclaration */: + case 206 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 199 /* VariableDeclaration */: + case 201 /* VariableDeclaration */: // equal in p = 0; - case 130 /* Parameter */: - case 227 /* EnumMember */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 131 /* Parameter */: + case 229 /* EnumMember */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return context.currentTokenSpan.kind === 53 /* EqualsToken */ || context.nextTokenSpan.kind === 53 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 188 /* ForInStatement */: + case 190 /* ForInStatement */: return context.currentTokenSpan.kind === 86 /* InKeyword */ || context.nextTokenSpan.kind === 86 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 189 /* ForOfStatement */: - return context.currentTokenSpan.kind === 126 /* OfKeyword */ || context.nextTokenSpan.kind === 126 /* OfKeyword */; + case 191 /* ForOfStatement */: + return context.currentTokenSpan.kind === 127 /* OfKeyword */ || context.nextTokenSpan.kind === 127 /* OfKeyword */; } return false; }; @@ -35203,7 +35639,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 171 /* ConditionalExpression */; + return context.contextNode.kind === 173 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -35247,92 +35683,92 @@ var ts; return true; } switch (node.kind) { - case 180 /* Block */: - case 208 /* CaseBlock */: - case 155 /* ObjectLiteralExpression */: - case 207 /* ModuleBlock */: + case 182 /* Block */: + case 210 /* CaseBlock */: + case 157 /* ObjectLiteralExpression */: + case 209 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: //case SyntaxKind.MemberFunctionDeclaration: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: ///case SyntaxKind.MethodSignature: - case 139 /* CallSignature */: - case 163 /* FunctionExpression */: - case 136 /* Constructor */: - case 164 /* ArrowFunction */: + case 140 /* CallSignature */: + case 165 /* FunctionExpression */: + case 137 /* Constructor */: + case 166 /* ArrowFunction */: //case SyntaxKind.ConstructorDeclaration: //case SyntaxKind.SimpleArrowFunctionExpression: //case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 201 /* FunctionDeclaration */ || context.contextNode.kind === 163 /* FunctionExpression */; + return context.contextNode.kind === 203 /* FunctionDeclaration */ || context.contextNode.kind === 165 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 146 /* TypeLiteral */: - case 206 /* ModuleDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 148 /* TypeLiteral */: + case 208 /* ModuleDeclaration */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 202 /* ClassDeclaration */: - case 206 /* ModuleDeclaration */: - case 205 /* EnumDeclaration */: - case 180 /* Block */: - case 224 /* CatchClause */: - case 207 /* ModuleBlock */: - case 194 /* SwitchStatement */: + case 204 /* ClassDeclaration */: + case 208 /* ModuleDeclaration */: + case 207 /* EnumDeclaration */: + case 182 /* Block */: + case 226 /* CatchClause */: + case 209 /* ModuleBlock */: + case 196 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 184 /* IfStatement */: - case 194 /* SwitchStatement */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 186 /* WhileStatement */: - case 197 /* TryStatement */: - case 185 /* DoStatement */: - case 193 /* WithStatement */: + case 186 /* IfStatement */: + case 196 /* SwitchStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 188 /* WhileStatement */: + case 199 /* TryStatement */: + case 187 /* DoStatement */: + case 195 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 224 /* CatchClause */: + case 226 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 155 /* ObjectLiteralExpression */; + return context.contextNode.kind === 157 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 158 /* CallExpression */; + return context.contextNode.kind === 160 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 159 /* NewExpression */; + return context.contextNode.kind === 161 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -35356,38 +35792,38 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 131 /* Decorator */; + return node.kind === 132 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 200 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 202 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { - return context.formattingRequestKind != 2 /* FormatOnEnter */; + return context.formattingRequestKind !== 2 /* FormatOnEnter */; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 206 /* ModuleDeclaration */; + return context.contextNode.kind === 208 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 146 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 148 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameter = function (token, parent) { if (token.kind !== 24 /* LessThanToken */ && token.kind !== 25 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 142 /* TypeReference */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 144 /* TypeReference */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: return true; default: return false; @@ -35398,10 +35834,10 @@ var ts; Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 99 /* VoidKeyword */ && context.currentTokenParent.kind === 167 /* VoidExpression */; + return context.currentTokenSpan.kind === 99 /* VoidKeyword */ && context.currentTokenParent.kind === 169 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 173 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 175 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; })(); @@ -35425,7 +35861,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 126 /* LastToken */ + 1; + this.mapRowLength = 127 /* LastToken */ + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); //new Array(this.mapRowLength * this.mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(this.map.length); //new Array(this.map.length); @@ -35445,13 +35881,13 @@ var ts; }; RulesMap.prototype.FillRule = function (rule, rulesBucketConstructionStateList) { var _this = this; - var specificRule = rule.Descriptor.LeftTokenRange != formatting.Shared.TokenRange.Any && - rule.Descriptor.RightTokenRange != formatting.Shared.TokenRange.Any; + var specificRule = rule.Descriptor.LeftTokenRange !== formatting.Shared.TokenRange.Any && + rule.Descriptor.RightTokenRange !== formatting.Shared.TokenRange.Any; rule.Descriptor.LeftTokenRange.GetTokens().forEach(function (left) { rule.Descriptor.RightTokenRange.GetTokens().forEach(function (right) { var rulesBucketIndex = _this.GetRuleBucketIndex(left, right); var rulesBucket = _this.map[rulesBucketIndex]; - if (rulesBucket == undefined) { + if (rulesBucket === undefined) { rulesBucket = _this.map[rulesBucketIndex] = new RulesBucket(); } rulesBucket.AddRule(rule, specificRule, rulesBucketConstructionStateList, rulesBucketIndex); @@ -35518,7 +35954,7 @@ var ts; RulesBucketConstructionState.prototype.IncreaseInsertionIndex = function (maskPosition) { var value = (this.rulesInsertionIndexBitmap >> maskPosition) & Mask; value++; - ts.Debug.assert((value & Mask) == value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules."); + ts.Debug.assert((value & Mask) === value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules."); var temp = this.rulesInsertionIndexBitmap & ~(Mask << maskPosition); temp |= value << maskPosition; this.rulesInsertionIndexBitmap = temp; @@ -35535,7 +35971,7 @@ var ts; }; RulesBucket.prototype.AddRule = function (rule, specificTokens, constructionState, rulesBucketIndex) { var position; - if (rule.Operation.Action == 1 /* Ignore */) { + if (rule.Operation.Action === 1 /* Ignore */) { position = specificTokens ? RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny; @@ -35610,7 +36046,7 @@ var ts; return [this.token]; }; TokenSingleValueAccess.prototype.Contains = function (tokenValue) { - return tokenValue == this.token; + return tokenValue === this.token; }; return TokenSingleValueAccess; })(); @@ -35620,7 +36056,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 126 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 127 /* LastToken */; token++) { result.push(token); } return result; @@ -35662,9 +36098,9 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(66 /* FirstKeyword */, 126 /* LastKeyword */); + TokenRange.Keywords = TokenRange.FromRange(66 /* FirstKeyword */, 127 /* LastKeyword */); TokenRange.BinaryOperators = TokenRange.FromRange(24 /* FirstBinaryOperator */, 64 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([86 /* InKeyword */, 87 /* InstanceOfKeyword */, 126 /* OfKeyword */]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([86 /* InKeyword */, 87 /* InstanceOfKeyword */, 127 /* OfKeyword */, 117 /* IsKeyword */]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([38 /* PlusPlusToken */, 39 /* MinusMinusToken */, 47 /* TildeToken */, 46 /* ExclamationToken */]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7 /* NumericLiteral */, 65 /* Identifier */, 16 /* OpenParenToken */, 18 /* OpenBracketToken */, 14 /* OpenBraceToken */, 93 /* ThisKeyword */, 88 /* NewKeyword */]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 16 /* OpenParenToken */, 93 /* ThisKeyword */, 88 /* NewKeyword */]); @@ -35672,7 +36108,7 @@ var ts; TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 16 /* OpenParenToken */, 93 /* ThisKeyword */, 88 /* NewKeyword */]); TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 88 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([65 /* Identifier */, 120 /* NumberKeyword */, 122 /* StringKeyword */, 113 /* BooleanKeyword */, 123 /* SymbolKeyword */, 99 /* VoidKeyword */, 112 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([65 /* Identifier */, 121 /* NumberKeyword */, 123 /* StringKeyword */, 113 /* BooleanKeyword */, 124 /* SymbolKeyword */, 99 /* VoidKeyword */, 112 /* AnyKeyword */]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -35711,6 +36147,7 @@ var ts; return this.rulesMap; }; RulesProvider.prototype.ensureUpToDate = function (options) { + // TODO: Should this be '==='? if (this.options == null || !ts.compareDataObjects(this.options, options)) { var activeRules = this.createActiveRules(options); var rulesMap = formatting.RulesMap.create(activeRules); @@ -35875,17 +36312,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 180 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 228 /* SourceFile */: - case 180 /* Block */: - case 207 /* ModuleBlock */: + return body && body.kind === 182 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 230 /* SourceFile */: + case 182 /* Block */: + case 209 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 224 /* CatchClause */: + case 226 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -36058,9 +36495,9 @@ var ts; // - source file // - switch\default clauses if (isSomeBlock(parent.kind) || - parent.kind === 228 /* SourceFile */ || - parent.kind === 221 /* CaseClause */ || - parent.kind === 222 /* DefaultClause */) { + parent.kind === 230 /* SourceFile */ || + parent.kind === 223 /* CaseClause */ || + parent.kind === 224 /* DefaultClause */) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -36096,19 +36533,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 202 /* ClassDeclaration */: return 69 /* ClassKeyword */; - case 203 /* InterfaceDeclaration */: return 103 /* InterfaceKeyword */; - case 201 /* FunctionDeclaration */: return 83 /* FunctionKeyword */; - case 205 /* EnumDeclaration */: return 205 /* EnumDeclaration */; - case 137 /* GetAccessor */: return 116 /* GetKeyword */; - case 138 /* SetAccessor */: return 121 /* SetKeyword */; - case 135 /* MethodDeclaration */: + case 204 /* ClassDeclaration */: return 69 /* ClassKeyword */; + case 205 /* InterfaceDeclaration */: return 103 /* InterfaceKeyword */; + case 203 /* FunctionDeclaration */: return 83 /* FunctionKeyword */; + case 207 /* EnumDeclaration */: return 207 /* EnumDeclaration */; + case 138 /* GetAccessor */: return 116 /* GetKeyword */; + case 139 /* SetAccessor */: return 122 /* SetKeyword */; + case 136 /* MethodDeclaration */: if (node.asteriskToken) { return 35 /* AsteriskToken */; } // fall-through - case 133 /* PropertyDeclaration */: - case 130 /* Parameter */: + case 134 /* PropertyDeclaration */: + case 131 /* Parameter */: return node.name.kind; } } @@ -36241,7 +36678,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 131 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 132 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -36564,20 +37001,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 180 /* Block */: - case 207 /* ModuleBlock */: + case 182 /* Block */: + case 209 /* ModuleBlock */: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 136 /* Constructor */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 164 /* ArrowFunction */: + case 137 /* Constructor */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 166 /* ArrowFunction */: if (node.typeParameters === list) { return 24 /* LessThanToken */; } @@ -36585,8 +37022,8 @@ var ts; return 16 /* OpenParenToken */; } break; - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: if (node.typeArguments === list) { return 24 /* LessThanToken */; } @@ -36594,7 +37031,7 @@ var ts; return 16 /* OpenParenToken */; } break; - case 142 /* TypeReference */: + case 144 /* TypeReference */: if (node.typeArguments === list) { return 24 /* LessThanToken */; } @@ -36693,7 +37130,7 @@ var ts; return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 23 /* CommaToken */ && precedingToken.parent.kind !== 170 /* BinaryExpression */) { + if (precedingToken.kind === 23 /* CommaToken */ && precedingToken.parent.kind !== 172 /* BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { @@ -36804,7 +37241,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 228 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 230 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -36837,7 +37274,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 184 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 186 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 76 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -36849,23 +37286,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 142 /* TypeReference */: + case 144 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 155 /* ObjectLiteralExpression */: + case 157 /* ObjectLiteralExpression */: return node.parent.properties; - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: return node.parent.elements; - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: { + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -36876,8 +37313,8 @@ var ts; } break; } - case 159 /* NewExpression */: - case 158 /* CallExpression */: { + case 161 /* NewExpression */: + case 160 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -36956,28 +37393,28 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 154 /* ArrayLiteralExpression */: - case 180 /* Block */: - case 207 /* ModuleBlock */: - case 155 /* ObjectLiteralExpression */: - case 146 /* TypeLiteral */: - case 148 /* TupleType */: - case 208 /* CaseBlock */: - case 222 /* DefaultClause */: - case 221 /* CaseClause */: - case 162 /* ParenthesizedExpression */: - case 158 /* CallExpression */: - case 159 /* NewExpression */: - case 181 /* VariableStatement */: - case 199 /* VariableDeclaration */: - case 215 /* ExportAssignment */: - case 192 /* ReturnStatement */: - case 171 /* ConditionalExpression */: - case 152 /* ArrayBindingPattern */: - case 151 /* ObjectBindingPattern */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 156 /* ArrayLiteralExpression */: + case 182 /* Block */: + case 209 /* ModuleBlock */: + case 157 /* ObjectLiteralExpression */: + case 148 /* TypeLiteral */: + case 150 /* TupleType */: + case 210 /* CaseBlock */: + case 224 /* DefaultClause */: + case 223 /* CaseClause */: + case 164 /* ParenthesizedExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: + case 183 /* VariableStatement */: + case 201 /* VariableDeclaration */: + case 217 /* ExportAssignment */: + case 194 /* ReturnStatement */: + case 173 /* ConditionalExpression */: + case 154 /* ArrayBindingPattern */: + case 153 /* ObjectBindingPattern */: return true; } return false; @@ -36987,22 +37424,22 @@ var ts; return true; } switch (parent) { - case 185 /* DoStatement */: - case 186 /* WhileStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 187 /* ForStatement */: - case 184 /* IfStatement */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 139 /* CallSignature */: - case 164 /* ArrowFunction */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - return child !== 180 /* Block */; + case 187 /* DoStatement */: + case 188 /* WhileStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 189 /* ForStatement */: + case 186 /* IfStatement */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 140 /* CallSignature */: + case 166 /* ArrowFunction */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + return child !== 182 /* Block */; default: return false; } @@ -37015,8 +37452,7 @@ var ts; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; /// /// @@ -37085,7 +37521,7 @@ var ts; return this.getEnd() - this.getStart(sourceFile); }; NodeObject.prototype.getFullWidth = function () { - return this.end - this.getFullStart(); + return this.end - this.pos; }; NodeObject.prototype.getLeadingTriviaWidth = function (sourceFile) { return this.getStart(sourceFile) - this.pos; @@ -37107,7 +37543,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(251 /* SyntaxList */, nodes.pos, nodes.end, 1024 /* Synthetic */, this); + var list = createNode(253 /* SyntaxList */, nodes.pos, nodes.end, 1024 /* Synthetic */, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -37126,7 +37562,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 127 /* FirstNode */) { + if (this.kind >= 128 /* FirstNode */) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -37171,7 +37607,7 @@ var ts; var children = this.getChildren(); for (var _i = 0; _i < children.length; _i++) { var child = children[_i]; - if (child.kind < 127 /* FirstNode */) { + if (child.kind < 128 /* FirstNode */) { return child; } return child.getFirstToken(sourceFile); @@ -37181,7 +37617,7 @@ var ts; var children = this.getChildren(sourceFile); for (var i = children.length - 1; i >= 0; i--) { var child = children[i]; - if (child.kind < 127 /* FirstNode */) { + if (child.kind < 128 /* FirstNode */) { return child; } return child.getLastToken(sourceFile); @@ -37234,7 +37670,7 @@ var ts; if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); // If it is parameter - try and get the jsDoc comment with @param tag from function declaration's jsDoc comments - if (canUseParsedParamTagComments && declaration.kind === 130 /* Parameter */) { + if (canUseParsedParamTagComments && declaration.kind === 131 /* Parameter */) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -37243,15 +37679,15 @@ var ts; }); } // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === 206 /* ModuleDeclaration */ && declaration.body.kind === 206 /* ModuleDeclaration */) { + if (declaration.kind === 208 /* ModuleDeclaration */ && declaration.body.kind === 208 /* ModuleDeclaration */) { return; } // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === 206 /* ModuleDeclaration */ && declaration.parent.kind === 206 /* ModuleDeclaration */) { + while (declaration.kind === 208 /* ModuleDeclaration */ && declaration.parent.kind === 208 /* ModuleDeclaration */) { declaration = declaration.parent; } // Get the cleaned js doc comment text from the declaration - ts.forEach(getJsDocCommentTextRange(declaration.kind === 199 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 201 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { jsDocCommentParts.push.apply(jsDocCommentParts, cleanedJsDocComment); @@ -37590,9 +38026,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 128 /* ComputedPropertyName */) { + if (declaration.name.kind === 129 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 156 /* PropertyAccessExpression */) { + if (expr.kind === 158 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -37612,9 +38048,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -37634,60 +38070,60 @@ var ts; ts.forEachChild(node, visit); } break; - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 205 /* EnumDeclaration */: - case 206 /* ModuleDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 218 /* ExportSpecifier */: - case 214 /* ImportSpecifier */: - case 209 /* ImportEqualsDeclaration */: - case 211 /* ImportClause */: - case 212 /* NamespaceImport */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 146 /* TypeLiteral */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 207 /* EnumDeclaration */: + case 208 /* ModuleDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 220 /* ExportSpecifier */: + case 216 /* ImportSpecifier */: + case 211 /* ImportEqualsDeclaration */: + case 213 /* ImportClause */: + case 214 /* NamespaceImport */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 148 /* TypeLiteral */: addDeclaration(node); // fall through - case 136 /* Constructor */: - case 181 /* VariableStatement */: - case 200 /* VariableDeclarationList */: - case 151 /* ObjectBindingPattern */: - case 152 /* ArrayBindingPattern */: - case 207 /* ModuleBlock */: + case 137 /* Constructor */: + case 183 /* VariableStatement */: + case 202 /* VariableDeclarationList */: + case 153 /* ObjectBindingPattern */: + case 154 /* ArrayBindingPattern */: + case 209 /* ModuleBlock */: ts.forEachChild(node, visit); break; - case 180 /* Block */: + case 182 /* Block */: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 130 /* Parameter */: + case 131 /* Parameter */: // Only consider properties defined as constructor parameters if (!(node.flags & 112 /* AccessibilityModifier */)) { break; } // fall through - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 227 /* EnumMember */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 229 /* EnumMember */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: addDeclaration(node); break; - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -37699,7 +38135,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 212 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 214 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -37900,16 +38336,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 163 /* FunctionExpression */) { + if (declaration.kind === 165 /* FunctionExpression */) { return true; } - if (declaration.kind !== 199 /* VariableDeclaration */ && declaration.kind !== 201 /* FunctionDeclaration */) { + if (declaration.kind !== 201 /* VariableDeclaration */ && declaration.kind !== 203 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { + for (var parent_9 = declaration.parent; !ts.isFunctionBlock(parent_9); parent_9 = parent_9.parent) { // Reached source file or module block - if (parent_8.kind === 228 /* SourceFile */ || parent_8.kind === 207 /* ModuleBlock */) { + if (parent_9.kind === 230 /* SourceFile */ || parent_9.kind === 209 /* ModuleBlock */) { return false; } } @@ -37953,9 +38389,8 @@ var ts; var HostCache = (function () { function HostCache(host, getCanonicalFileName) { this.host = host; - this.getCanonicalFileName = getCanonicalFileName; // script id => script index - this.fileNameToEntry = {}; + this.fileNameToEntry = ts.createFileMap(getCanonicalFileName); // Initialize the list with the root file names var rootFileNames = host.getScriptFileNames(); for (var _i = 0; _i < rootFileNames.length; _i++) { @@ -37968,9 +38403,6 @@ var ts; HostCache.prototype.compilationSettings = function () { return this._compilationSettings; }; - HostCache.prototype.normalizeFileName = function (fileName) { - return this.getCanonicalFileName(ts.normalizeSlashes(fileName)); - }; HostCache.prototype.createEntry = function (fileName) { var entry; var scriptSnapshot = this.host.getScriptSnapshot(fileName); @@ -37981,13 +38413,14 @@ var ts; scriptSnapshot: scriptSnapshot }; } - return this.fileNameToEntry[this.normalizeFileName(fileName)] = entry; + this.fileNameToEntry.set(fileName, entry); + return entry; }; HostCache.prototype.getEntry = function (fileName) { - return ts.lookUp(this.fileNameToEntry, this.normalizeFileName(fileName)); + return this.fileNameToEntry.get(fileName); }; HostCache.prototype.contains = function (fileName) { - return ts.hasProperty(this.fileNameToEntry, this.normalizeFileName(fileName)); + return this.fileNameToEntry.contains(fileName); }; HostCache.prototype.getOrCreateEntry = function (fileName) { if (this.contains(fileName)) { @@ -37996,12 +38429,10 @@ var ts; return this.createEntry(fileName); }; HostCache.prototype.getRootFileNames = function () { - var _this = this; var fileNames = []; - ts.forEachKey(this.fileNameToEntry, function (key) { - var entry = _this.getEntry(key); - if (entry) { - fileNames.push(entry.hostFileName); + this.fileNameToEntry.forEachValue(function (value) { + if (value) { + fileNames.push(value.hostFileName); } }); return fileNames; @@ -38061,7 +38492,7 @@ var ts; * - noLib = true * - noResolve = true */ - function transpile(input, compilerOptions, fileName, diagnostics) { + function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { var options = compilerOptions ? ts.clone(compilerOptions) : getDefaultCompilerOptions(); options.isolatedModules = true; // Filename can be non-ts file. @@ -38075,9 +38506,8 @@ var ts; // Parse var inputFileName = fileName || "module.ts"; var sourceFile = ts.createSourceFile(inputFileName, input, options.target); - // Store syntactic diagnostics - if (diagnostics && sourceFile.parseDiagnostics) { - diagnostics.push.apply(diagnostics, sourceFile.parseDiagnostics); + if (moduleName) { + sourceFile.moduleName = moduleName; } var newLine = ts.getNewLineCharacter(options); // Output @@ -38096,9 +38526,8 @@ var ts; getNewLine: function () { return newLine; } }; var program = ts.createProgram([inputFileName], options, compilerHost); - if (diagnostics) { - diagnostics.push.apply(diagnostics, program.getCompilerOptionsDiagnostics()); - } + ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile)); + ts.addRange(diagnostics, program.getOptionsDiagnostics()); // Emit program.emit(); ts.Debug.assert(outputText !== undefined, "Output generation failed"); @@ -38158,10 +38587,16 @@ var ts; return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, true); } ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; - function createDocumentRegistry() { + function createGetCanonicalFileName(useCaseSensitivefileNames) { + return useCaseSensitivefileNames + ? (function (fileName) { return fileName; }) + : (function (fileName) { return fileName.toLowerCase(); }); + } + function createDocumentRegistry(useCaseSensitiveFileNames) { // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have // for those settings. var buckets = {}; + var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); function getKeyFromCompilationSettings(settings) { return "_" + settings.target; // + "|" + settings.propagateEnumConstantoString() } @@ -38169,7 +38604,7 @@ var ts; var key = getKeyFromCompilationSettings(settings); var bucket = ts.lookUp(buckets, key); if (!bucket && createIfMissing) { - buckets[key] = bucket = {}; + buckets[key] = bucket = ts.createFileMap(getCanonicalFileName); } return bucket; } @@ -38178,7 +38613,7 @@ var ts; var entries = ts.lookUp(buckets, name); var sourceFiles = []; for (var i in entries) { - var entry = entries[i]; + var entry = entries.get(i); sourceFiles.push({ name: i, refCount: entry.languageServiceRefCount, @@ -38201,16 +38636,17 @@ var ts; } function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { var bucket = getBucketForCompilationSettings(compilationSettings, true); - var entry = ts.lookUp(bucket, fileName); + var entry = bucket.get(fileName); if (!entry) { ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); // Have never seen this file with these settings. Create a new source file for it. var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, false); - bucket[fileName] = entry = { + entry = { sourceFile: sourceFile, languageServiceRefCount: 0, owners: [] }; + bucket.set(fileName, entry); } else { // We have an entry for this file. However, it may be for a different version of @@ -38233,11 +38669,11 @@ var ts; function releaseDocument(fileName, compilationSettings) { var bucket = getBucketForCompilationSettings(compilationSettings, false); ts.Debug.assert(bucket !== undefined); - var entry = ts.lookUp(bucket, fileName); + var entry = bucket.get(fileName); entry.languageServiceRefCount--; ts.Debug.assert(entry.languageServiceRefCount >= 0); if (entry.languageServiceRefCount === 0) { - delete bucket[fileName]; + bucket.remove(fileName); } } return { @@ -38300,7 +38736,7 @@ var ts; else { if (token === 65 /* Identifier */) { token = scanner.scan(); - if (token === 125 /* FromKeyword */) { + if (token === 126 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import d from "mod"; @@ -38310,7 +38746,7 @@ var ts; } else if (token === 53 /* EqualsToken */) { token = scanner.scan(); - if (token === 119 /* RequireKeyword */) { + if (token === 120 /* RequireKeyword */) { token = scanner.scan(); if (token === 16 /* OpenParenToken */) { token = scanner.scan(); @@ -38339,7 +38775,7 @@ var ts; } if (token === 15 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 125 /* FromKeyword */) { + if (token === 126 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import {a as A} from "mod"; @@ -38355,7 +38791,7 @@ var ts; token = scanner.scan(); if (token === 65 /* Identifier */) { token = scanner.scan(); - if (token === 125 /* FromKeyword */) { + if (token === 126 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import * as NS from "mod" @@ -38378,7 +38814,7 @@ var ts; } if (token === 15 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 125 /* FromKeyword */) { + if (token === 126 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // export {a as A} from "mod"; @@ -38390,7 +38826,7 @@ var ts; } else if (token === 35 /* AsteriskToken */) { token = scanner.scan(); - if (token === 125 /* FromKeyword */) { + if (token === 126 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // export * from "mod" @@ -38413,7 +38849,7 @@ var ts; /// Helpers function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 195 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 197 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -38422,12 +38858,12 @@ var ts; } function isJumpStatementTarget(node) { return node.kind === 65 /* Identifier */ && - (node.parent.kind === 191 /* BreakStatement */ || node.parent.kind === 190 /* ContinueStatement */) && + (node.parent.kind === 193 /* BreakStatement */ || node.parent.kind === 192 /* ContinueStatement */) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { return node.kind === 65 /* Identifier */ && - node.parent.kind === 195 /* LabeledStatement */ && + node.parent.kind === 197 /* LabeledStatement */ && node.parent.label === node; } /** @@ -38435,7 +38871,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 195 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 197 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -38446,25 +38882,25 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 127 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 128 /* QualifiedName */ && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 156 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 158 /* PropertyAccessExpression */ && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 158 /* CallExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 160 /* CallExpression */ && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 159 /* NewExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 161 /* NewExpression */ && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 206 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 208 /* ModuleDeclaration */ && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { return node.kind === 65 /* Identifier */ && @@ -38473,22 +38909,22 @@ var ts; /** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */ function isNameOfPropertyAssignment(node) { return (node.kind === 65 /* Identifier */ || node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) && - (node.parent.kind === 225 /* PropertyAssignment */ || node.parent.kind === 226 /* ShorthandPropertyAssignment */) && node.parent.name === node; + (node.parent.kind === 227 /* PropertyAssignment */ || node.parent.kind === 228 /* ShorthandPropertyAssignment */) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) { switch (node.parent.kind) { - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 225 /* PropertyAssignment */: - case 227 /* EnumMember */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 206 /* ModuleDeclaration */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 227 /* PropertyAssignment */: + case 229 /* EnumMember */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 208 /* ModuleDeclaration */: return node.parent.name === node; - case 157 /* ElementAccessExpression */: + case 159 /* ElementAccessExpression */: return node.parent.argumentExpression === node; } } @@ -38547,7 +38983,7 @@ var ts; })(BreakContinueSearchType || (BreakContinueSearchType = {})); // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 66 /* FirstKeyword */; i <= 126 /* LastKeyword */; i++) { + for (var i = 66 /* FirstKeyword */; i <= 127 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -38562,17 +38998,17 @@ var ts; return undefined; } switch (node.kind) { - case 228 /* SourceFile */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 206 /* ModuleDeclaration */: + case 230 /* SourceFile */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 208 /* ModuleDeclaration */: return node; } } @@ -38580,38 +39016,38 @@ var ts; ts.getContainerNode = getContainerNode; /* @internal */ function getNodeKind(node) { switch (node.kind) { - case 206 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 202 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 203 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 204 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 205 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 199 /* VariableDeclaration */: + case 208 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 204 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 205 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 206 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 207 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 201 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 201 /* FunctionDeclaration */: return ScriptElementKind.functionElement; - case 137 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 138 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 203 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 138 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 139 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return ScriptElementKind.memberFunctionElement; - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return ScriptElementKind.memberVariableElement; - case 141 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 140 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 139 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 136 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 129 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 227 /* EnumMember */: return ScriptElementKind.variableElement; - case 130 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 209 /* ImportEqualsDeclaration */: - case 214 /* ImportSpecifier */: - case 211 /* ImportClause */: - case 218 /* ExportSpecifier */: - case 212 /* NamespaceImport */: + case 142 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 141 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 140 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 137 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 130 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 229 /* EnumMember */: return ScriptElementKind.variableElement; + case 131 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 211 /* ImportEqualsDeclaration */: + case 216 /* ImportSpecifier */: + case 213 /* ImportClause */: + case 220 /* ExportSpecifier */: + case 214 /* NamespaceImport */: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -38634,9 +39070,7 @@ var ts; host.log(message); } } - function getCanonicalFileName(fileName) { - return useCaseSensitivefileNames ? fileName : fileName.toLowerCase(); - } + var getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames); function getValidSourceFile(fileName) { fileName = ts.normalizeSlashes(fileName); var sourceFile = program.getSourceFile(getCanonicalFileName(fileName)); @@ -38827,44 +39261,44 @@ var ts; return false; } switch (node.kind) { - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 223 /* HeritageClause */: + case 225 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 102 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 204 /* TypeAliasDeclaration */: + case 206 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 163 /* FunctionExpression */: - case 201 /* FunctionDeclaration */: - case 164 /* ArrowFunction */: - case 201 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 165 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: + case 166 /* ArrowFunction */: + case 203 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -38872,20 +39306,20 @@ var ts; return true; } break; - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 199 /* VariableDeclaration */: + case 201 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -38893,7 +39327,7 @@ var ts; return true; } break; - case 130 /* Parameter */: + case 131 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -38909,17 +39343,17 @@ var ts; return true; } break; - case 133 /* PropertyDeclaration */: + case 134 /* PropertyDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: var typeAssertionExpression = node; diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return true; - case 131 /* Decorator */: + case 132 /* Decorator */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -38964,7 +39398,7 @@ var ts; } function getCompilerOptionsDiagnostics() { synchronizeHostData(); - return program.getGlobalDiagnostics(); + return program.getOptionsDiagnostics().concat(program.getGlobalDiagnostics()); } /// Completion function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks) { @@ -39053,11 +39487,11 @@ var ts; // visible symbols in the scope, and the node is the current location. var node = currentToken; var isRightOfDot = false; - if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 156 /* PropertyAccessExpression */) { + if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 158 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 127 /* QualifiedName */) { + else if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 128 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -39084,7 +39518,7 @@ var ts; // Right of dot member completion list isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 65 /* Identifier */ || node.kind === 127 /* QualifiedName */ || node.kind === 156 /* PropertyAccessExpression */) { + if (node.kind === 65 /* Identifier */ || node.kind === 128 /* QualifiedName */ || node.kind === 158 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -39142,13 +39576,13 @@ var ts; symbols = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties); } } - else if (ts.getAncestor(contextToken, 211 /* ImportClause */)) { + else if (ts.getAncestor(contextToken, 213 /* ImportClause */)) { // cursor is in import clause // try to show exported member for imported module isMemberCompletion = true; isNewIdentifierLocation = true; if (showCompletionsInImportsClause(contextToken)) { - var importDeclaration = ts.getAncestor(contextToken, 210 /* ImportDeclaration */); + var importDeclaration = ts.getAncestor(contextToken, 212 /* ImportDeclaration */); ts.Debug.assert(importDeclaration !== undefined); var exports; if (importDeclaration.moduleSpecifier) { @@ -39227,7 +39661,7 @@ var ts; // import {| // import {a,| if (node.kind === 14 /* OpenBraceToken */ || node.kind === 23 /* CommaToken */) { - return node.parent.kind === 213 /* NamedImports */; + return node.parent.kind === 215 /* NamedImports */; } } return false; @@ -39237,38 +39671,38 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23 /* CommaToken */: - return containingNodeKind === 158 /* CallExpression */ // func( a, | - || containingNodeKind === 136 /* Constructor */ // constructor( a, | public, protected, private keywords are allowed here, so show completion - || containingNodeKind === 159 /* NewExpression */ // new C(a, | - || containingNodeKind === 154 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 170 /* BinaryExpression */ // let x = (a, | - || containingNodeKind === 143 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 160 /* CallExpression */ // func( a, | + || containingNodeKind === 137 /* Constructor */ // constructor( a, | public, protected, private keywords are allowed here, so show completion + || containingNodeKind === 161 /* NewExpression */ // new C(a, | + || containingNodeKind === 156 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 172 /* BinaryExpression */ // let x = (a, | + || containingNodeKind === 145 /* FunctionType */; // var x: (s: string, list| case 16 /* OpenParenToken */: - return containingNodeKind === 158 /* CallExpression */ // func( | - || containingNodeKind === 136 /* Constructor */ // constructor( | - || containingNodeKind === 159 /* NewExpression */ // new C(a| - || containingNodeKind === 162 /* ParenthesizedExpression */ // let x = (a| - || containingNodeKind === 150 /* ParenthesizedType */; // function F(pred: (a| this can become an arrow function, where 'a' is the argument + return containingNodeKind === 160 /* CallExpression */ // func( | + || containingNodeKind === 137 /* Constructor */ // constructor( | + || containingNodeKind === 161 /* NewExpression */ // new C(a| + || containingNodeKind === 164 /* ParenthesizedExpression */ // let x = (a| + || containingNodeKind === 152 /* ParenthesizedType */; // function F(pred: (a| this can become an arrow function, where 'a' is the argument case 18 /* OpenBracketToken */: - return containingNodeKind === 154 /* ArrayLiteralExpression */; // [ | - case 117 /* ModuleKeyword */: // module | - case 118 /* NamespaceKeyword */: + return containingNodeKind === 156 /* ArrayLiteralExpression */; // [ | + case 118 /* ModuleKeyword */: // module | + case 119 /* NamespaceKeyword */: return true; case 20 /* DotToken */: - return containingNodeKind === 206 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 208 /* ModuleDeclaration */; // module A.| case 14 /* OpenBraceToken */: - return containingNodeKind === 202 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 204 /* ClassDeclaration */; // class A{ | case 53 /* EqualsToken */: - return containingNodeKind === 199 /* VariableDeclaration */ // let x = a| - || containingNodeKind === 170 /* BinaryExpression */; // x = a| + return containingNodeKind === 201 /* VariableDeclaration */ // let x = a| + || containingNodeKind === 172 /* BinaryExpression */; // x = a| case 11 /* TemplateHead */: - return containingNodeKind === 172 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 174 /* TemplateExpression */; // `aa ${| case 12 /* TemplateMiddle */: - return containingNodeKind === 178 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 180 /* TemplateSpan */; // `aa ${10} dd ${| case 108 /* PublicKeyword */: case 106 /* PrivateKeyword */: case 107 /* ProtectedKeyword */: - return containingNodeKind === 133 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 134 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -39303,12 +39737,12 @@ var ts; function getContainingObjectLiteralApplicableForCompletion(previousToken) { // The locations in an object literal expression that are applicable for completion are property name definition locations. if (previousToken) { - var parent_9 = previousToken.parent; + var parent_10 = previousToken.parent; switch (previousToken.kind) { case 14 /* OpenBraceToken */: // let x = { | case 23 /* CommaToken */: - if (parent_9 && parent_9.kind === 155 /* ObjectLiteralExpression */) { - return parent_9; + if (parent_10 && parent_10.kind === 157 /* ObjectLiteralExpression */) { + return parent_10; } break; } @@ -39317,16 +39751,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: return true; } return false; @@ -39336,63 +39770,63 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23 /* CommaToken */: - return containingNodeKind === 199 /* VariableDeclaration */ || - containingNodeKind === 200 /* VariableDeclarationList */ || - containingNodeKind === 181 /* VariableStatement */ || - containingNodeKind === 205 /* EnumDeclaration */ || + return containingNodeKind === 201 /* VariableDeclaration */ || + containingNodeKind === 202 /* VariableDeclarationList */ || + containingNodeKind === 183 /* VariableStatement */ || + containingNodeKind === 207 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 202 /* ClassDeclaration */ || - containingNodeKind === 201 /* FunctionDeclaration */ || - containingNodeKind === 203 /* InterfaceDeclaration */ || - containingNodeKind === 152 /* ArrayBindingPattern */ || - containingNodeKind === 151 /* ObjectBindingPattern */; // function func({ x, y| + containingNodeKind === 204 /* ClassDeclaration */ || + containingNodeKind === 203 /* FunctionDeclaration */ || + containingNodeKind === 205 /* InterfaceDeclaration */ || + containingNodeKind === 154 /* ArrayBindingPattern */ || + containingNodeKind === 153 /* ObjectBindingPattern */; // function func({ x, y| case 20 /* DotToken */: - return containingNodeKind === 152 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 154 /* ArrayBindingPattern */; // var [.| case 51 /* ColonToken */: - return containingNodeKind === 153 /* BindingElement */; // var {x :html| + return containingNodeKind === 155 /* BindingElement */; // var {x :html| case 18 /* OpenBracketToken */: - return containingNodeKind === 152 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 154 /* ArrayBindingPattern */; // var [x| case 16 /* OpenParenToken */: - return containingNodeKind === 224 /* CatchClause */ || + return containingNodeKind === 226 /* CatchClause */ || isFunction(containingNodeKind); case 14 /* OpenBraceToken */: - return containingNodeKind === 205 /* EnumDeclaration */ || - containingNodeKind === 203 /* InterfaceDeclaration */ || - containingNodeKind === 146 /* TypeLiteral */ || - containingNodeKind === 151 /* ObjectBindingPattern */; // function func({ x| + return containingNodeKind === 207 /* EnumDeclaration */ || + containingNodeKind === 205 /* InterfaceDeclaration */ || + containingNodeKind === 148 /* TypeLiteral */ || + containingNodeKind === 153 /* ObjectBindingPattern */; // function func({ x| case 22 /* SemicolonToken */: - return containingNodeKind === 132 /* PropertySignature */ && + return containingNodeKind === 133 /* PropertySignature */ && previousToken.parent && previousToken.parent.parent && - (previousToken.parent.parent.kind === 203 /* InterfaceDeclaration */ || - previousToken.parent.parent.kind === 146 /* TypeLiteral */); // let x : { a; | + (previousToken.parent.parent.kind === 205 /* InterfaceDeclaration */ || + previousToken.parent.parent.kind === 148 /* TypeLiteral */); // let x : { a; | case 24 /* LessThanToken */: - return containingNodeKind === 202 /* ClassDeclaration */ || - containingNodeKind === 201 /* FunctionDeclaration */ || - containingNodeKind === 203 /* InterfaceDeclaration */ || + return containingNodeKind === 204 /* ClassDeclaration */ || + containingNodeKind === 203 /* FunctionDeclaration */ || + containingNodeKind === 205 /* InterfaceDeclaration */ || isFunction(containingNodeKind); case 109 /* StaticKeyword */: - return containingNodeKind === 133 /* PropertyDeclaration */; + return containingNodeKind === 134 /* PropertyDeclaration */; case 21 /* DotDotDotToken */: - return containingNodeKind === 130 /* Parameter */ || - containingNodeKind === 136 /* Constructor */ || + return containingNodeKind === 131 /* Parameter */ || + containingNodeKind === 137 /* Constructor */ || (previousToken.parent && previousToken.parent.parent && - previousToken.parent.parent.kind === 152 /* ArrayBindingPattern */); // var [...z| + previousToken.parent.parent.kind === 154 /* ArrayBindingPattern */); // var [...z| case 108 /* PublicKeyword */: case 106 /* PrivateKeyword */: case 107 /* ProtectedKeyword */: - return containingNodeKind === 130 /* Parameter */; + return containingNodeKind === 131 /* Parameter */; case 69 /* ClassKeyword */: case 77 /* EnumKeyword */: case 103 /* InterfaceKeyword */: case 83 /* FunctionKeyword */: case 98 /* VarKeyword */: case 116 /* GetKeyword */: - case 121 /* SetKeyword */: + case 122 /* SetKeyword */: case 85 /* ImportKeyword */: case 104 /* LetKeyword */: case 70 /* ConstKeyword */: case 110 /* YieldKeyword */: - case 124 /* TypeKeyword */: + case 125 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. @@ -39424,7 +39858,7 @@ var ts; return exports; } if (importDeclaration.importClause.namedBindings && - importDeclaration.importClause.namedBindings.kind === 213 /* NamedImports */) { + importDeclaration.importClause.namedBindings.kind === 215 /* NamedImports */) { ts.forEach(importDeclaration.importClause.namedBindings.elements, function (el) { var name = el.propertyName || el.name; exisingImports[name.text] = true; @@ -39441,7 +39875,7 @@ var ts; } var existingMemberNames = {}; ts.forEach(existingMembers, function (m) { - if (m.kind !== 225 /* PropertyAssignment */ && m.kind !== 226 /* ShorthandPropertyAssignment */) { + if (m.kind !== 227 /* PropertyAssignment */ && m.kind !== 228 /* ShorthandPropertyAssignment */) { // Ignore omitted expressions for missing members in the object literal return; } @@ -39491,10 +39925,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameTable = getNameTable(sourceFile); - for (var name_30 in nameTable) { - if (!allNames[name_30]) { - allNames[name_30] = name_30; - var displayName = getCompletionEntryDisplayName(name_30, target, true); + for (var name_27 in nameTable) { + if (!allNames[name_27]) { + allNames[name_27] = name_27; + var displayName = getCompletionEntryDisplayName(name_27, target, true); if (displayName) { var entry = { name: displayName, @@ -39693,7 +40127,7 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 156 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 158 /* PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -39702,7 +40136,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression; - if (location.kind === 158 /* CallExpression */ || location.kind === 159 /* NewExpression */) { + if (location.kind === 160 /* CallExpression */ || location.kind === 161 /* NewExpression */) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -39715,7 +40149,7 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 159 /* NewExpression */ || callExpression.expression.kind === 91 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 161 /* NewExpression */ || callExpression.expression.kind === 91 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { // Get the first signature if there @@ -39767,24 +40201,24 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 114 /* ConstructorKeyword */ && location.parent.kind === 136 /* Constructor */)) { + (location.kind === 114 /* ConstructorKeyword */ && location.parent.kind === 137 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 136 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 137 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 136 /* Constructor */) { + if (functionDeclaration.kind === 137 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 139 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 140 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -39807,7 +40241,7 @@ var ts; } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(124 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(125 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); @@ -39827,9 +40261,9 @@ var ts; } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 206 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 208 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 65 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 118 /* NamespaceKeyword */ : 117 /* ModuleKeyword */)); + displayParts.push(ts.keywordPart(isNamespace ? 119 /* NamespaceKeyword */ : 118 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -39850,13 +40284,13 @@ var ts; } else { // Method/function type parameter - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 129 /* TypeParameter */).parent; + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 130 /* TypeParameter */).parent; var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 140 /* ConstructSignature */) { + if (signatureDeclaration.kind === 141 /* ConstructSignature */) { displayParts.push(ts.keywordPart(88 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 139 /* CallSignature */ && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 140 /* CallSignature */ && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); @@ -39865,7 +40299,7 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 227 /* EnumMember */) { + if (declaration.kind === 229 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -39881,13 +40315,13 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 209 /* ImportEqualsDeclaration */) { + if (declaration.kind === 211 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); displayParts.push(ts.operatorPart(53 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(119 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(120 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); @@ -40014,8 +40448,8 @@ var ts; // Try getting just type at this position and show switch (node.kind) { case 65 /* Identifier */: - case 156 /* PropertyAccessExpression */: - case 127 /* QualifiedName */: + case 158 /* PropertyAccessExpression */: + case 128 /* QualifiedName */: case 93 /* ThisKeyword */: case 91 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position @@ -40073,7 +40507,7 @@ var ts; if (isNewExpressionTarget(location) || location.kind === 114 /* ConstructorKeyword */) { if (symbol.flags & 32 /* Class */) { var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 202 /* ClassDeclaration */); + ts.Debug.assert(classDeclaration && classDeclaration.kind === 204 /* ClassDeclaration */); return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); } } @@ -40089,8 +40523,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 136 /* Constructor */) || - (!selectConstructors && (d.kind === 201 /* FunctionDeclaration */ || d.kind === 135 /* MethodDeclaration */ || d.kind === 134 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 137 /* Constructor */) || + (!selectConstructors && (d.kind === 203 /* FunctionDeclaration */ || d.kind === 136 /* MethodDeclaration */ || d.kind === 135 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -40159,7 +40593,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 226 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 228 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -40193,7 +40627,7 @@ var ts; var result = []; ts.forEach(type.types, function (t) { if (t.symbol) { - result.push.apply(result, getDefinitionFromSymbol(t.symbol, node)); + ts.addRange(result, getDefinitionFromSymbol(t.symbol, node)); } }); return result; @@ -40288,74 +40722,74 @@ var ts; switch (node.kind) { case 84 /* IfKeyword */: case 76 /* ElseKeyword */: - if (hasKind(node.parent, 184 /* IfStatement */)) { + if (hasKind(node.parent, 186 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; case 90 /* ReturnKeyword */: - if (hasKind(node.parent, 192 /* ReturnStatement */)) { + if (hasKind(node.parent, 194 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; case 94 /* ThrowKeyword */: - if (hasKind(node.parent, 196 /* ThrowStatement */)) { + if (hasKind(node.parent, 198 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; case 68 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 197 /* TryStatement */)) { + if (hasKind(parent(parent(node)), 199 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 96 /* TryKeyword */: case 81 /* FinallyKeyword */: - if (hasKind(parent(node), 197 /* TryStatement */)) { + if (hasKind(parent(node), 199 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 92 /* SwitchKeyword */: - if (hasKind(node.parent, 194 /* SwitchStatement */)) { + if (hasKind(node.parent, 196 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 67 /* CaseKeyword */: case 73 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 194 /* SwitchStatement */)) { + if (hasKind(parent(parent(parent(node))), 196 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 66 /* BreakKeyword */: case 71 /* ContinueKeyword */: - if (hasKind(node.parent, 191 /* BreakStatement */) || hasKind(node.parent, 190 /* ContinueStatement */)) { + if (hasKind(node.parent, 193 /* BreakStatement */) || hasKind(node.parent, 192 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurences(node.parent); } break; case 82 /* ForKeyword */: - if (hasKind(node.parent, 187 /* ForStatement */) || - hasKind(node.parent, 188 /* ForInStatement */) || - hasKind(node.parent, 189 /* ForOfStatement */)) { + if (hasKind(node.parent, 189 /* ForStatement */) || + hasKind(node.parent, 190 /* ForInStatement */) || + hasKind(node.parent, 191 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 100 /* WhileKeyword */: case 75 /* DoKeyword */: - if (hasKind(node.parent, 186 /* WhileStatement */) || hasKind(node.parent, 185 /* DoStatement */)) { + if (hasKind(node.parent, 188 /* WhileStatement */) || hasKind(node.parent, 187 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 114 /* ConstructorKeyword */: - if (hasKind(node.parent, 136 /* Constructor */)) { + if (hasKind(node.parent, 137 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; case 116 /* GetKeyword */: - case 121 /* SetKeyword */: - if (hasKind(node.parent, 137 /* GetAccessor */) || hasKind(node.parent, 138 /* SetAccessor */)) { + case 122 /* SetKeyword */: + if (hasKind(node.parent, 138 /* GetAccessor */) || hasKind(node.parent, 139 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 181 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 183 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -40371,10 +40805,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 196 /* ThrowStatement */) { + if (node.kind === 198 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 197 /* TryStatement */) { + else if (node.kind === 199 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -40402,19 +40836,19 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_10 = child.parent; - if (ts.isFunctionBlock(parent_10) || parent_10.kind === 228 /* SourceFile */) { - return parent_10; + var parent_11 = child.parent; + if (ts.isFunctionBlock(parent_11) || parent_11.kind === 230 /* SourceFile */) { + return parent_11; } // A throw-statement is only owned by a try-statement if the try-statement has // a catch clause, and if the throw-statement occurs within the try block. - if (parent_10.kind === 197 /* TryStatement */) { - var tryStatement = parent_10; + if (parent_11.kind === 199 /* TryStatement */) { + var tryStatement = parent_11; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_10; + child = parent_11; } return undefined; } @@ -40423,7 +40857,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 191 /* BreakStatement */ || node.kind === 190 /* ContinueStatement */) { + if (node.kind === 193 /* BreakStatement */ || node.kind === 192 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -40437,25 +40871,25 @@ var ts; return actualOwner && actualOwner === owner; } function getBreakOrContinueOwner(statement) { - for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { - switch (node_1.kind) { - case 194 /* SwitchStatement */: - if (statement.kind === 190 /* ContinueStatement */) { + for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { + switch (node_2.kind) { + case 196 /* SwitchStatement */: + if (statement.kind === 192 /* ContinueStatement */) { continue; } // Fall through. - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 186 /* WhileStatement */: - case 185 /* DoStatement */: - if (!statement.label || isLabeledBy(node_1, statement.label.text)) { - return node_1; + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 188 /* WhileStatement */: + case 187 /* DoStatement */: + if (!statement.label || isLabeledBy(node_2, statement.label.text)) { + return node_2; } break; default: // Don't cross function boundaries. - if (ts.isFunctionLike(node_1)) { + if (ts.isFunctionLike(node_2)) { return undefined; } break; @@ -40467,18 +40901,18 @@ var ts; var container = declaration.parent; // Make sure we only highlight the keyword when it makes sense to do so. if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 202 /* ClassDeclaration */ || - (declaration.kind === 130 /* Parameter */ && hasKind(container, 136 /* Constructor */)))) { + if (!(container.kind === 204 /* ClassDeclaration */ || + (declaration.kind === 131 /* Parameter */ && hasKind(container, 137 /* Constructor */)))) { return undefined; } } else if (modifier === 109 /* StaticKeyword */) { - if (container.kind !== 202 /* ClassDeclaration */) { + if (container.kind !== 204 /* ClassDeclaration */) { return undefined; } } else if (modifier === 78 /* ExportKeyword */ || modifier === 115 /* DeclareKeyword */) { - if (!(container.kind === 207 /* ModuleBlock */ || container.kind === 228 /* SourceFile */)) { + if (!(container.kind === 209 /* ModuleBlock */ || container.kind === 230 /* SourceFile */)) { return undefined; } } @@ -40490,20 +40924,20 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 207 /* ModuleBlock */: - case 228 /* SourceFile */: + case 209 /* ModuleBlock */: + case 230 /* SourceFile */: nodes = container.statements; break; - case 136 /* Constructor */: + case 137 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. if (modifierFlag & 112 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 136 /* Constructor */ && member; + return member.kind === 137 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -40551,13 +40985,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 137 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 138 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 138 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 139 /* SetAccessor */); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 116 /* GetKeyword */, 121 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 116 /* GetKeyword */, 122 /* SetKeyword */); }); } } } @@ -40575,7 +41009,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 82 /* ForKeyword */, 100 /* WhileKeyword */, 75 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 185 /* DoStatement */) { + if (loopNode.kind === 187 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 100 /* WhileKeyword */)) { @@ -40596,13 +41030,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 194 /* SwitchStatement */: + case 196 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -40656,7 +41090,7 @@ var ts; function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); // If we didn't find a containing function with a block body, bail out. - if (!(func && hasKind(func.body, 180 /* Block */))) { + if (!(func && hasKind(func.body, 182 /* Block */))) { return undefined; } var keywords = []; @@ -40672,7 +41106,7 @@ var ts; function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 184 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 186 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. @@ -40685,7 +41119,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 184 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 186 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -40864,17 +41298,17 @@ var ts; } function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 214 /* ImportSpecifier */ || location.parent.kind === 218 /* ExportSpecifier */) && + (location.parent.kind === 216 /* ImportSpecifier */ || location.parent.kind === 220 /* ExportSpecifier */) && location.parent.propertyName === location; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 214 /* ImportSpecifier */ || declaration.kind === 218 /* ExportSpecifier */; + return declaration.kind === 216 /* ImportSpecifier */ || declaration.kind === 220 /* ExportSpecifier */; }); } function getDeclaredName(symbol, location) { // Special case for function expressions, whose names are solely local to their bodies. - var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 163 /* FunctionExpression */ ? d : undefined; }); + var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 165 /* FunctionExpression */ ? d : undefined; }); // When a name gets interned into a SourceFile's 'identifiers' Map, // its name is escaped and stored in the same way its symbol name/identifier // name should be stored. Function expressions, however, are a special case, @@ -40901,7 +41335,7 @@ var ts; return location.getText(); } // Special case for function expressions, whose names are solely local to their bodies. - var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 163 /* FunctionExpression */ ? d : undefined; }); + var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 165 /* FunctionExpression */ ? d : undefined; }); // When a name gets interned into a SourceFile's 'identifiers' Map, // its name is escaped and stored in the same way its symbol name/identifier // name should be stored. Function expressions, however, are a special case, @@ -40925,7 +41359,7 @@ var ts; if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 202 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 204 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -40951,7 +41385,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 228 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 230 /* SourceFile */ && !ts.isExternalModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -41139,13 +41573,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -41177,27 +41611,27 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 228 /* SourceFile */: + case 230 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. @@ -41206,7 +41640,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 228 /* SourceFile */) { + if (searchSpaceNode.kind === 230 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -41237,27 +41671,27 @@ var ts; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 163 /* FunctionExpression */: - case 201 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 228 /* SourceFile */: - if (container.kind === 228 /* SourceFile */ && !ts.isExternalModule(container)) { + case 230 /* SourceFile */: + if (container.kind === 230 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -41311,11 +41745,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 202 /* ClassDeclaration */) { + if (declaration.kind === 204 /* ClassDeclaration */) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 203 /* InterfaceDeclaration */) { + else if (declaration.kind === 205 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -41376,19 +41810,19 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_31 = node.text; + var name_28 = node.text; if (contextualType) { if (contextualType.flags & 16384 /* Union */) { // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) // if not, search the constituent types for the property - var unionProperty = contextualType.getProperty(name_31); + var unionProperty = contextualType.getProperty(name_28); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_31); + var symbol = t.getProperty(name_28); if (symbol) { result_4.push(symbol); } @@ -41397,7 +41831,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_31); + var symbol_1 = contextualType.getProperty(name_28); if (symbol_1) { return [symbol_1]; } @@ -41455,10 +41889,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 169 /* PostfixUnaryExpression */ || parent.kind === 168 /* PrefixUnaryExpression */) { + if (parent.kind === 171 /* PostfixUnaryExpression */ || parent.kind === 170 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 170 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 172 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; return 53 /* FirstAssignment */ <= operator && operator <= 64 /* LastAssignment */; } @@ -41492,33 +41926,33 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 130 /* Parameter */: - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 225 /* PropertyAssignment */: - case 226 /* ShorthandPropertyAssignment */: - case 227 /* EnumMember */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - case 224 /* CatchClause */: + case 131 /* Parameter */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 227 /* PropertyAssignment */: + case 228 /* ShorthandPropertyAssignment */: + case 229 /* EnumMember */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 226 /* CatchClause */: return 1 /* Value */; - case 129 /* TypeParameter */: - case 203 /* InterfaceDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 146 /* TypeLiteral */: + case 130 /* TypeParameter */: + case 205 /* InterfaceDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 148 /* TypeLiteral */: return 2 /* Type */; - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: if (node.name.kind === 8 /* StringLiteral */) { return 4 /* Namespace */ | 1 /* Value */; } @@ -41528,15 +41962,15 @@ var ts; else { return 4 /* Namespace */; } - case 213 /* NamedImports */: - case 214 /* ImportSpecifier */: - case 209 /* ImportEqualsDeclaration */: - case 210 /* ImportDeclaration */: - case 215 /* ExportAssignment */: - case 216 /* ExportDeclaration */: + case 215 /* NamedImports */: + case 216 /* ImportSpecifier */: + case 211 /* ImportEqualsDeclaration */: + case 212 /* ImportDeclaration */: + case 217 /* ExportAssignment */: + case 218 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 228 /* SourceFile */: + case 230 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; @@ -41546,7 +41980,8 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 142 /* TypeReference */ || node.parent.kind === 177 /* ExpressionWithTypeArguments */; + return node.parent.kind === 144 /* TypeReference */ || + (node.parent.kind === 179 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -41554,32 +41989,32 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 156 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 156 /* PropertyAccessExpression */) { + if (root.parent.kind === 158 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 158 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 177 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 223 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 179 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 225 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 202 /* ClassDeclaration */ && root.parent.parent.token === 102 /* ImplementsKeyword */) || - (decl.kind === 203 /* InterfaceDeclaration */ && root.parent.parent.token === 79 /* ExtendsKeyword */); + return (decl.kind === 204 /* ClassDeclaration */ && root.parent.parent.token === 102 /* ImplementsKeyword */) || + (decl.kind === 205 /* InterfaceDeclaration */ && root.parent.parent.token === 79 /* ExtendsKeyword */); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 127 /* QualifiedName */) { - while (root.parent && root.parent.kind === 127 /* QualifiedName */) { + if (root.parent.kind === 128 /* QualifiedName */) { + while (root.parent && root.parent.kind === 128 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 142 /* TypeReference */ && !isLastClause; + return root.parent.kind === 144 /* TypeReference */ && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 127 /* QualifiedName */) { + while (node.parent.kind === 128 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -41589,15 +42024,15 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 127 /* QualifiedName */ && + if (node.parent.kind === 128 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 209 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 211 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function getMeaningFromLocation(node) { - if (node.parent.kind === 215 /* ExportAssignment */) { + if (node.parent.kind === 217 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -41637,8 +42072,8 @@ var ts; return; } switch (node.kind) { - case 156 /* PropertyAccessExpression */: - case 127 /* QualifiedName */: + case 158 /* PropertyAccessExpression */: + case 128 /* QualifiedName */: case 8 /* StringLiteral */: case 80 /* FalseKeyword */: case 95 /* TrueKeyword */: @@ -41661,7 +42096,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 206 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 208 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -41695,6 +42130,7 @@ var ts; var sourceFile = getValidSourceFile(fileName); var typeChecker = program.getTypeChecker(); var result = []; + var classifiableNames = program.getClassifiableNames(); processNode(sourceFile); return { spans: result, endOfLineState: 0 /* None */ }; function pushClassification(start, length, type) { @@ -41704,6 +42140,9 @@ var ts; } function classifySymbol(symbol, meaningAtPosition) { var flags = symbol.getFlags(); + if ((flags & 788448 /* Classifiable */) === 0 /* None */) { + return; + } if (flags & 32 /* Class */) { return 11 /* className */; } @@ -41736,19 +42175,26 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 206 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) == 1 /* Instantiated */; + return declaration.kind === 208 /* ModuleDeclaration */ && + ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } } function processNode(node) { // Only walk into nodes that intersect the requested span. - if (node && ts.textSpanIntersectsWith(span, node.getStart(), node.getWidth())) { - if (node.kind === 65 /* Identifier */ && node.getWidth() > 0) { - var symbol = typeChecker.getSymbolAtLocation(node); - if (symbol) { - var type = classifySymbol(symbol, getMeaningFromLocation(node)); - if (type) { - pushClassification(node.getStart(), node.getWidth(), type); + if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { + if (node.kind === 65 /* Identifier */ && !ts.nodeIsMissing(node)) { + var identifier = node; + // Only bother calling into the typechecker if this is an identifier that + // could possibly resolve to a type name. This makes classification run + // in a third of the time it would normally take. + if (classifiableNames[identifier.text]) { + var symbol = typeChecker.getSymbolAtLocation(node); + if (symbol) { + var type = classifySymbol(symbol, getMeaningFromLocation(node)); + if (type) { + pushClassification(node.getStart(), node.getWidth(), type); + } } } } @@ -41795,6 +42241,8 @@ var ts; function getEncodedSyntacticClassifications(fileName, span) { // doesn't use compiler - no need to synchronize with host var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var spanStart = span.start; + var spanLength = span.length; // Make a scanner we can get trivia from. var triviaScanner = ts.createScanner(2 /* Latest */, false, sourceFile.text); var mergeConflictScanner = ts.createScanner(2 /* Latest */, false, sourceFile.text); @@ -41806,42 +42254,47 @@ var ts; result.push(length); result.push(type); } - function classifyLeadingTrivia(token) { - var tokenStart = ts.skipTrivia(sourceFile.text, token.pos, false); - if (tokenStart === token.pos) { - return; - } - // token has trivia. Classify them appropriately. + function classifyLeadingTriviaAndGetTokenStart(token) { triviaScanner.setTextPos(token.pos); while (true) { var start = triviaScanner.getTextPos(); + // only bother scanning if we have something that could be trivia. + if (!ts.couldStartTrivia(sourceFile.text, start)) { + return start; + } var kind = triviaScanner.scan(); var end = triviaScanner.getTextPos(); var width = end - start; // The moment we get something that isn't trivia, then stop processing. if (!ts.isTrivia(kind)) { - return; + return start; + } + // Don't bother with newlines/whitespace. + if (kind === 4 /* NewLineTrivia */ || kind === 5 /* WhitespaceTrivia */) { + continue; } // Only bother with the trivia if it at least intersects the span of interest. - if (ts.textSpanIntersectsWith(span, start, width)) { - if (ts.isComment(kind)) { - classifyComment(token, kind, start, width); + if (ts.isComment(kind)) { + classifyComment(token, kind, start, width); + // Classifying a comment might cause us to reuse the trivia scanner + // (because of jsdoc comments). So after we classify the comment make + // sure we set the scanner position back to where it needs to be. + triviaScanner.setTextPos(end); + continue; + } + if (kind === 6 /* ConflictMarkerTrivia */) { + var text = sourceFile.text; + var ch = text.charCodeAt(start); + // for the <<<<<<< and >>>>>>> markers, we just add them in as comments + // in the classification stream. + if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { + pushClassification(start, width, 1 /* comment */); continue; } - if (kind === 6 /* ConflictMarkerTrivia */) { - var text = sourceFile.text; - var ch = text.charCodeAt(start); - // for the <<<<<<< and >>>>>>> markers, we just add them in as comments - // in the classification stream. - if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { - pushClassification(start, width, 1 /* comment */); - continue; - } - // for the ======== add a comment for the first line, and then lex all - // subsequent lines up until the end of the conflict marker. - ts.Debug.assert(ch === 61 /* equals */); - classifyDisabledMergeCode(text, start, end); - } + // for the ======== add a comment for the first line, and then lex all + // subsequent lines up until the end of the conflict marker. + ts.Debug.assert(ch === 61 /* equals */); + classifyDisabledMergeCode(text, start, end); } } } @@ -41875,16 +42328,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 247 /* JSDocParameterTag */: + case 249 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 250 /* JSDocTemplateTag */: + case 252 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 249 /* JSDocTypeTag */: + case 251 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 248 /* JSDocReturnTag */: + case 250 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -41942,11 +42395,13 @@ var ts; } } function classifyToken(token) { - classifyLeadingTrivia(token); - if (token.getWidth() > 0) { + var tokenStart = classifyLeadingTriviaAndGetTokenStart(token); + var tokenWidth = token.end - tokenStart; + ts.Debug.assert(tokenWidth >= 0); + if (tokenWidth > 0) { var type = classifyTokenType(token.kind, token); if (type) { - pushClassification(token.getStart(), token.getWidth(), type); + pushClassification(tokenStart, tokenWidth, type); } } } @@ -41970,16 +42425,16 @@ var ts; if (token) { if (tokenKind === 53 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 199 /* VariableDeclaration */ || - token.parent.kind === 133 /* PropertyDeclaration */ || - token.parent.kind === 130 /* Parameter */) { + if (token.parent.kind === 201 /* VariableDeclaration */ || + token.parent.kind === 134 /* PropertyDeclaration */ || + token.parent.kind === 131 /* Parameter */) { return 5 /* operator */; } } - if (token.parent.kind === 170 /* BinaryExpression */ || - token.parent.kind === 168 /* PrefixUnaryExpression */ || - token.parent.kind === 169 /* PostfixUnaryExpression */ || - token.parent.kind === 171 /* ConditionalExpression */) { + if (token.parent.kind === 172 /* BinaryExpression */ || + token.parent.kind === 170 /* PrefixUnaryExpression */ || + token.parent.kind === 171 /* PostfixUnaryExpression */ || + token.parent.kind === 173 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -42002,32 +42457,32 @@ var ts; else if (tokenKind === 65 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 129 /* TypeParameter */: + case 130 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 130 /* Parameter */: + case 131 /* Parameter */: if (token.parent.name === token) { return 17 /* parameterName */; } @@ -42042,10 +42497,10 @@ var ts; return; } // Ignore nodes that don't intersect the original span to classify. - if (ts.textSpanIntersectsWith(span, element.getFullStart(), element.getFullWidth())) { + if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { var children = element.getChildren(sourceFile); - for (var _i = 0; _i < children.length; _i++) { - var child = children[_i]; + for (var i = 0, n = children.length; i < n; i++) { + var child = children[i]; if (ts.isToken(child)) { classifyToken(child); } @@ -42372,7 +42827,7 @@ var ts; // then we want 'something' to be in the name table. Similarly, if we have // "a['propname']" then we want to store "propname" in the name table. if (ts.isDeclarationName(node) || - node.parent.kind === 220 /* ExternalModuleReference */ || + node.parent.kind === 222 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -42385,7 +42840,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 157 /* ElementAccessExpression */ && + node.parent.kind === 159 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /// Classifier @@ -42433,7 +42888,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 116 /* GetKeyword */ || - keyword2 === 121 /* SetKeyword */ || + keyword2 === 122 /* SetKeyword */ || keyword2 === 114 /* ConstructorKeyword */ || keyword2 === 109 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". @@ -42592,10 +43047,10 @@ var ts; angleBracketStack--; } else if (token === 112 /* AnyKeyword */ || - token === 122 /* StringKeyword */ || - token === 120 /* NumberKeyword */ || + token === 123 /* StringKeyword */ || + token === 121 /* NumberKeyword */ || token === 113 /* BooleanKeyword */ || - token === 123 /* SymbolKeyword */) { + token === 124 /* SymbolKeyword */) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, @@ -42766,7 +43221,7 @@ var ts; } } function isKeyword(token) { - return token >= 66 /* FirstKeyword */ && token <= 126 /* LastKeyword */; + return token >= 66 /* FirstKeyword */ && token <= 127 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -42824,7 +43279,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 228 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); + var proto = kind === 230 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = 0; proto.end = 0; @@ -42894,125 +43349,125 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 185 /* DoStatement */) { + if (node.parent.kind === 187 /* DoStatement */) { // Set span as if on while keyword return spanInPreviousNode(node); } - if (node.parent.kind === 187 /* ForStatement */) { + if (node.parent.kind === 189 /* ForStatement */) { // For now lets set the span on this expression, fix it later return textSpan(node); } - if (node.parent.kind === 170 /* BinaryExpression */ && node.parent.operatorToken.kind === 23 /* CommaToken */) { + if (node.parent.kind === 172 /* BinaryExpression */ && node.parent.operatorToken.kind === 23 /* CommaToken */) { // if this is comma expression, the breakpoint is possible in this expression return textSpan(node); } - if (node.parent.kind == 164 /* ArrowFunction */ && node.parent.body == node) { + if (node.parent.kind === 166 /* ArrowFunction */ && node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); } } switch (node.kind) { - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 199 /* VariableDeclaration */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 201 /* VariableDeclaration */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return spanInVariableDeclaration(node); - case 130 /* Parameter */: + case 131 /* Parameter */: return spanInParameterDeclaration(node); - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 136 /* Constructor */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 137 /* Constructor */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 180 /* Block */: + case 182 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 207 /* ModuleBlock */: + case 209 /* ModuleBlock */: return spanInBlock(node); - case 224 /* CatchClause */: + case 226 /* CatchClause */: return spanInBlock(node.block); - case 183 /* ExpressionStatement */: + case 185 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 192 /* ReturnStatement */: + case 194 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 186 /* WhileStatement */: + case 188 /* WhileStatement */: // Span on while(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 185 /* DoStatement */: + case 187 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 198 /* DebuggerStatement */: + case 200 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 184 /* IfStatement */: + case 186 /* IfStatement */: // set on if(..) span return textSpan(node, ts.findNextToken(node.expression, node)); - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 191 /* BreakStatement */: - case 190 /* ContinueStatement */: + case 193 /* BreakStatement */: + case 192 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 187 /* ForStatement */: + case 189 /* ForStatement */: return spanInForStatement(node); - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: // span on for (a in ...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 194 /* SwitchStatement */: + case 196 /* SwitchStatement */: // span on switch(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 221 /* CaseClause */: - case 222 /* DefaultClause */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 197 /* TryStatement */: + case 199 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 196 /* ThrowStatement */: + case 198 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: - case 227 /* EnumMember */: - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 229 /* EnumMember */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: // span on complete node return textSpan(node); - case 193 /* WithStatement */: + case 195 /* WithStatement */: // span in statement return spanInNode(node.statement); // No breakpoint in interface, type alias - case 203 /* InterfaceDeclaration */: - case 204 /* TypeAliasDeclaration */: + case 205 /* InterfaceDeclaration */: + case 206 /* TypeAliasDeclaration */: return undefined; // Tokens: case 22 /* SemicolonToken */: @@ -43042,11 +43497,11 @@ var ts; return spanInNextNode(node); default: // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 225 /* PropertyAssignment */ && node.parent.name === node) { + if (node.parent.kind === 227 /* PropertyAssignment */ && node.parent.name === node) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 161 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 163 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNode(node.parent.expression); } // return type of function go to previous token @@ -43059,12 +43514,12 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 188 /* ForInStatement */ || - variableDeclaration.parent.parent.kind === 189 /* ForOfStatement */) { + if (variableDeclaration.parent.parent.kind === 190 /* ForInStatement */ || + variableDeclaration.parent.parent.kind === 191 /* ForOfStatement */) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 181 /* VariableStatement */; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 187 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 183 /* VariableStatement */; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 189 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -43118,7 +43573,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1 /* Export */) || - (functionDeclaration.parent.kind === 202 /* ClassDeclaration */ && functionDeclaration.kind !== 136 /* Constructor */); + (functionDeclaration.parent.kind === 204 /* ClassDeclaration */ && functionDeclaration.kind !== 137 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -43141,18 +43596,18 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 186 /* WhileStatement */: - case 184 /* IfStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: + case 188 /* WhileStatement */: + case 186 /* IfStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 187 /* ForStatement */: + case 189 /* ForStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement @@ -43160,7 +43615,7 @@ var ts; } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 200 /* VariableDeclarationList */) { + if (forStatement.initializer.kind === 202 /* VariableDeclarationList */) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -43180,13 +43635,13 @@ var ts; // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 208 /* CaseBlock */: + case 210 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -43194,25 +43649,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 207 /* ModuleBlock */: + case 209 /* ModuleBlock */: // If this is not instantiated module block no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 205 /* EnumDeclaration */: - case 202 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 204 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 180 /* Block */: + case 182 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through. - case 224 /* CatchClause */: + case 226 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 208 /* CaseBlock */: + case 210 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -43226,7 +43681,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 185 /* DoStatement */) { + if (node.parent.kind === 187 /* DoStatement */) { // Go to while keyword and do action instead return spanInPreviousNode(node); } @@ -43236,17 +43691,17 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 163 /* FunctionExpression */: - case 201 /* FunctionDeclaration */: - case 164 /* ArrowFunction */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 136 /* Constructor */: - case 186 /* WhileStatement */: - case 185 /* DoStatement */: - case 187 /* ForStatement */: + case 165 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: + case 166 /* ArrowFunction */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 137 /* Constructor */: + case 188 /* WhileStatement */: + case 187 /* DoStatement */: + case 189 /* ForStatement */: return spanInPreviousNode(node); // Default to parent node default: @@ -43257,19 +43712,19 @@ var ts; } function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration - if (ts.isFunctionLike(node.parent) || node.parent.kind === 225 /* PropertyAssignment */) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 227 /* PropertyAssignment */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 161 /* TypeAssertionExpression */) { + if (node.parent.kind === 163 /* TypeAssertionExpression */) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 185 /* DoStatement */) { + if (node.parent.kind === 187 /* DoStatement */) { // Set span on while expression return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } @@ -43320,6 +43775,7 @@ var ts; ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { var oldSnapshotShim = oldSnapshot; var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + // TODO: should this be '==='? if (encoded == null) { return null; } @@ -43331,12 +43787,18 @@ var ts; var LanguageServiceShimHostAdapter = (function () { function LanguageServiceShimHostAdapter(shimHost) { this.shimHost = shimHost; + this.loggingEnabled = false; + this.tracingEnabled = false; } LanguageServiceShimHostAdapter.prototype.log = function (s) { - this.shimHost.log(s); + if (this.loggingEnabled) { + this.shimHost.log(s); + } }; LanguageServiceShimHostAdapter.prototype.trace = function (s) { - this.shimHost.trace(s); + if (this.tracingEnabled) { + this.shimHost.trace(s); + } }; LanguageServiceShimHostAdapter.prototype.error = function (s) { this.shimHost.error(s); @@ -43348,8 +43810,12 @@ var ts; } return this.shimHost.getProjectVersion(); }; + LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { + return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; + }; LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { var settingsJson = this.shimHost.getCompilationSettings(); + // TODO: should this be '==='? if (settingsJson == null || settingsJson == "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); return null; @@ -43415,13 +43881,13 @@ var ts; return CoreServicesShimHostAdapter; })(); ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; - function simpleForwardCall(logger, actionDescription, action, noPerfLogging) { - if (!noPerfLogging) { + function simpleForwardCall(logger, actionDescription, action, logPerformance) { + if (logPerformance) { logger.log(actionDescription); var start = Date.now(); } var result = action(); - if (!noPerfLogging) { + if (logPerformance) { var end = Date.now(); logger.log(actionDescription + " completed in " + (end - start) + " msec"); if (typeof (result) === "string") { @@ -43434,9 +43900,9 @@ var ts; } return result; } - function forwardJSONCall(logger, actionDescription, action, noPerfLogging) { + function forwardJSONCall(logger, actionDescription, action, logPerformance) { try { - var result = simpleForwardCall(logger, actionDescription, action, noPerfLogging); + var result = simpleForwardCall(logger, actionDescription, action, logPerformance); return JSON.stringify({ result: result }); } catch (err) { @@ -43478,10 +43944,11 @@ var ts; _super.call(this, factory); this.host = host; this.languageService = languageService; + this.logPerformance = false; this.logger = this.host; } LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action, false); + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); }; /// DISPOSE /** @@ -43788,12 +44255,12 @@ var ts; function ClassifierShimObject(factory, logger) { _super.call(this, factory); this.logger = logger; + this.logPerformance = false; this.classifier = ts.createClassifier(); } ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { var _this = this; - return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, - /*noPerfLogging:*/ true); + return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, this.logPerformance); }; /// COLORIZATION ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { @@ -43815,9 +44282,10 @@ var ts; _super.call(this, factory); this.logger = logger; this.host = host; + this.logPerformance = false; } CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action, false); + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { @@ -43874,7 +44342,6 @@ var ts; var TypeScriptServicesFactory = (function () { function TypeScriptServicesFactory() { this._shims = []; - this.documentRegistry = ts.createDocumentRegistry(); } /* * Returns script API version. @@ -43884,6 +44351,9 @@ var ts; }; TypeScriptServicesFactory.prototype.createLanguageServiceShim = function (host) { try { + if (this.documentRegistry === undefined) { + this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + } var hostAdapter = new LanguageServiceShimHostAdapter(host); var languageService = ts.createLanguageService(hostAdapter, this.documentRegistry); return new LanguageServiceShimObject(this, host, languageService); diff --git a/bin/typescriptServices.d.ts b/bin/typescriptServices.d.ts index 9a153ade4b1..da6d55bfd80 100644 --- a/bin/typescriptServices.d.ts +++ b/bin/typescriptServices.d.ts @@ -13,10 +13,17 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -declare module ts { +declare namespace ts { interface Map { [index: string]: T; } + interface FileMap { + get(fileName: string): T; + set(fileName: string, value: T): void; + contains(fileName: string): boolean; + remove(fileName: string): void; + forEachValue(f: (v: T) => void): void; + } interface TextRange { pos: number; end: number; @@ -139,156 +146,158 @@ declare module ts { ConstructorKeyword = 114, DeclareKeyword = 115, GetKeyword = 116, - ModuleKeyword = 117, - NamespaceKeyword = 118, - RequireKeyword = 119, - NumberKeyword = 120, - SetKeyword = 121, - StringKeyword = 122, - SymbolKeyword = 123, - TypeKeyword = 124, - FromKeyword = 125, - OfKeyword = 126, - QualifiedName = 127, - ComputedPropertyName = 128, - TypeParameter = 129, - Parameter = 130, - Decorator = 131, - PropertySignature = 132, - PropertyDeclaration = 133, - MethodSignature = 134, - MethodDeclaration = 135, - Constructor = 136, - GetAccessor = 137, - SetAccessor = 138, - CallSignature = 139, - ConstructSignature = 140, - IndexSignature = 141, - TypeReference = 142, - FunctionType = 143, - ConstructorType = 144, - TypeQuery = 145, - TypeLiteral = 146, - ArrayType = 147, - TupleType = 148, - UnionType = 149, - ParenthesizedType = 150, - ObjectBindingPattern = 151, - ArrayBindingPattern = 152, - BindingElement = 153, - ArrayLiteralExpression = 154, - ObjectLiteralExpression = 155, - PropertyAccessExpression = 156, - ElementAccessExpression = 157, - CallExpression = 158, - NewExpression = 159, - TaggedTemplateExpression = 160, - TypeAssertionExpression = 161, - ParenthesizedExpression = 162, - FunctionExpression = 163, - ArrowFunction = 164, - DeleteExpression = 165, - TypeOfExpression = 166, - VoidExpression = 167, - PrefixUnaryExpression = 168, - PostfixUnaryExpression = 169, - BinaryExpression = 170, - ConditionalExpression = 171, - TemplateExpression = 172, - YieldExpression = 173, - SpreadElementExpression = 174, - ClassExpression = 175, - OmittedExpression = 176, - ExpressionWithTypeArguments = 177, - TemplateSpan = 178, - SemicolonClassElement = 179, - Block = 180, - VariableStatement = 181, - EmptyStatement = 182, - ExpressionStatement = 183, - IfStatement = 184, - DoStatement = 185, - WhileStatement = 186, - ForStatement = 187, - ForInStatement = 188, - ForOfStatement = 189, - ContinueStatement = 190, - BreakStatement = 191, - ReturnStatement = 192, - WithStatement = 193, - SwitchStatement = 194, - LabeledStatement = 195, - ThrowStatement = 196, - TryStatement = 197, - DebuggerStatement = 198, - VariableDeclaration = 199, - VariableDeclarationList = 200, - FunctionDeclaration = 201, - ClassDeclaration = 202, - InterfaceDeclaration = 203, - TypeAliasDeclaration = 204, - EnumDeclaration = 205, - ModuleDeclaration = 206, - ModuleBlock = 207, - CaseBlock = 208, - ImportEqualsDeclaration = 209, - ImportDeclaration = 210, - ImportClause = 211, - NamespaceImport = 212, - NamedImports = 213, - ImportSpecifier = 214, - ExportAssignment = 215, - ExportDeclaration = 216, - NamedExports = 217, - ExportSpecifier = 218, - MissingDeclaration = 219, - ExternalModuleReference = 220, - CaseClause = 221, - DefaultClause = 222, - HeritageClause = 223, - CatchClause = 224, - PropertyAssignment = 225, - ShorthandPropertyAssignment = 226, - EnumMember = 227, - SourceFile = 228, - JSDocTypeExpression = 229, - JSDocAllType = 230, - JSDocUnknownType = 231, - JSDocArrayType = 232, - JSDocUnionType = 233, - JSDocTupleType = 234, - JSDocNullableType = 235, - JSDocNonNullableType = 236, - JSDocRecordType = 237, - JSDocRecordMember = 238, - JSDocTypeReference = 239, - JSDocOptionalType = 240, - JSDocFunctionType = 241, - JSDocVariadicType = 242, - JSDocConstructorType = 243, - JSDocThisType = 244, - JSDocComment = 245, - JSDocTag = 246, - JSDocParameterTag = 247, - JSDocReturnTag = 248, - JSDocTypeTag = 249, - JSDocTemplateTag = 250, - SyntaxList = 251, - Count = 252, + IsKeyword = 117, + ModuleKeyword = 118, + NamespaceKeyword = 119, + RequireKeyword = 120, + NumberKeyword = 121, + SetKeyword = 122, + StringKeyword = 123, + SymbolKeyword = 124, + TypeKeyword = 125, + FromKeyword = 126, + OfKeyword = 127, + QualifiedName = 128, + ComputedPropertyName = 129, + TypeParameter = 130, + Parameter = 131, + Decorator = 132, + PropertySignature = 133, + PropertyDeclaration = 134, + MethodSignature = 135, + MethodDeclaration = 136, + Constructor = 137, + GetAccessor = 138, + SetAccessor = 139, + CallSignature = 140, + ConstructSignature = 141, + IndexSignature = 142, + TypePredicate = 143, + TypeReference = 144, + FunctionType = 145, + ConstructorType = 146, + TypeQuery = 147, + TypeLiteral = 148, + ArrayType = 149, + TupleType = 150, + UnionType = 151, + ParenthesizedType = 152, + ObjectBindingPattern = 153, + ArrayBindingPattern = 154, + BindingElement = 155, + ArrayLiteralExpression = 156, + ObjectLiteralExpression = 157, + PropertyAccessExpression = 158, + ElementAccessExpression = 159, + CallExpression = 160, + NewExpression = 161, + TaggedTemplateExpression = 162, + TypeAssertionExpression = 163, + ParenthesizedExpression = 164, + FunctionExpression = 165, + ArrowFunction = 166, + DeleteExpression = 167, + TypeOfExpression = 168, + VoidExpression = 169, + PrefixUnaryExpression = 170, + PostfixUnaryExpression = 171, + BinaryExpression = 172, + ConditionalExpression = 173, + TemplateExpression = 174, + YieldExpression = 175, + SpreadElementExpression = 176, + ClassExpression = 177, + OmittedExpression = 178, + ExpressionWithTypeArguments = 179, + TemplateSpan = 180, + SemicolonClassElement = 181, + Block = 182, + VariableStatement = 183, + EmptyStatement = 184, + ExpressionStatement = 185, + IfStatement = 186, + DoStatement = 187, + WhileStatement = 188, + ForStatement = 189, + ForInStatement = 190, + ForOfStatement = 191, + ContinueStatement = 192, + BreakStatement = 193, + ReturnStatement = 194, + WithStatement = 195, + SwitchStatement = 196, + LabeledStatement = 197, + ThrowStatement = 198, + TryStatement = 199, + DebuggerStatement = 200, + VariableDeclaration = 201, + VariableDeclarationList = 202, + FunctionDeclaration = 203, + ClassDeclaration = 204, + InterfaceDeclaration = 205, + TypeAliasDeclaration = 206, + EnumDeclaration = 207, + ModuleDeclaration = 208, + ModuleBlock = 209, + CaseBlock = 210, + ImportEqualsDeclaration = 211, + ImportDeclaration = 212, + ImportClause = 213, + NamespaceImport = 214, + NamedImports = 215, + ImportSpecifier = 216, + ExportAssignment = 217, + ExportDeclaration = 218, + NamedExports = 219, + ExportSpecifier = 220, + MissingDeclaration = 221, + ExternalModuleReference = 222, + CaseClause = 223, + DefaultClause = 224, + HeritageClause = 225, + CatchClause = 226, + PropertyAssignment = 227, + ShorthandPropertyAssignment = 228, + EnumMember = 229, + SourceFile = 230, + JSDocTypeExpression = 231, + JSDocAllType = 232, + JSDocUnknownType = 233, + JSDocArrayType = 234, + JSDocUnionType = 235, + JSDocTupleType = 236, + JSDocNullableType = 237, + JSDocNonNullableType = 238, + JSDocRecordType = 239, + JSDocRecordMember = 240, + JSDocTypeReference = 241, + JSDocOptionalType = 242, + JSDocFunctionType = 243, + JSDocVariadicType = 244, + JSDocConstructorType = 245, + JSDocThisType = 246, + JSDocComment = 247, + JSDocTag = 248, + JSDocParameterTag = 249, + JSDocReturnTag = 250, + JSDocTypeTag = 251, + JSDocTemplateTag = 252, + SyntaxList = 253, + Count = 254, FirstAssignment = 53, LastAssignment = 64, FirstReservedWord = 66, LastReservedWord = 101, FirstKeyword = 66, - LastKeyword = 126, + LastKeyword = 127, FirstFutureReservedWord = 102, LastFutureReservedWord = 110, - FirstTypeNode = 142, - LastTypeNode = 150, + FirstTypeNode = 144, + LastTypeNode = 152, FirstPunctuation = 14, LastPunctuation = 64, FirstToken = 0, - LastToken = 126, + LastToken = 127, FirstTriviaToken = 2, LastTriviaToken = 6, FirstLiteralToken = 7, @@ -297,7 +306,7 @@ declare module ts { LastTemplateToken = 13, FirstBinaryOperator = 24, LastBinaryOperator = 64, - FirstNode = 127, + FirstNode = 128, } const enum NodeFlags { Export = 1, @@ -458,6 +467,10 @@ declare module ts { typeName: EntityName; typeArguments?: NodeArray; } + interface TypePredicateNode extends TypeNode { + parameterName: Identifier; + type: TypeNode; + } interface TypeQueryNode extends TypeNode { exprName: EntityName; } @@ -592,7 +605,7 @@ declare module ts { type: TypeNode; expression: UnaryExpression; } - interface Statement extends Node, ModuleElement { + interface Statement extends Node { _statementBrand: any; } interface Block extends Statement { @@ -672,9 +685,6 @@ declare module ts { variableDeclaration: VariableDeclaration; block: Block; } - interface ModuleElement extends Node { - _moduleElementBrand: any; - } interface ClassLikeDeclaration extends Declaration { name?: Identifier; typeParameters?: NodeArray; @@ -700,6 +710,7 @@ declare module ts { } interface TypeAliasDeclaration extends Declaration, Statement { name: Identifier; + typeParameters?: NodeArray; type: TypeNode; } interface EnumMember extends Declaration { @@ -710,21 +721,21 @@ declare module ts { name: Identifier; members: NodeArray; } - interface ModuleDeclaration extends Declaration, ModuleElement { + interface ModuleDeclaration extends Declaration, Statement { name: Identifier | LiteralExpression; body: ModuleBlock | ModuleDeclaration; } - interface ModuleBlock extends Node, ModuleElement { - statements: NodeArray; + interface ModuleBlock extends Node, Statement { + statements: NodeArray; } - interface ImportEqualsDeclaration extends Declaration, ModuleElement { + interface ImportEqualsDeclaration extends Declaration, Statement { name: Identifier; moduleReference: EntityName | ExternalModuleReference; } interface ExternalModuleReference extends Node { expression?: Expression; } - interface ImportDeclaration extends ModuleElement { + interface ImportDeclaration extends Statement { importClause?: ImportClause; moduleSpecifier: Expression; } @@ -735,7 +746,7 @@ declare module ts { interface NamespaceImport extends Declaration { name: Identifier; } - interface ExportDeclaration extends Declaration, ModuleElement { + interface ExportDeclaration extends Declaration, Statement { exportClause?: NamedExports; moduleSpecifier?: Expression; } @@ -750,7 +761,7 @@ declare module ts { } type ImportSpecifier = ImportOrExportSpecifier; type ExportSpecifier = ImportOrExportSpecifier; - interface ExportAssignment extends Declaration, ModuleElement { + interface ExportAssignment extends Declaration, Statement { isExportEquals?: boolean; expression: Expression; } @@ -838,7 +849,7 @@ declare module ts { isBracketed: boolean; } interface SourceFile extends Declaration { - statements: NodeArray; + statements: NodeArray; endOfFileToken: Node; fileName: string; text: string; @@ -846,8 +857,16 @@ declare module ts { path: string; name: string; }[]; - amdModuleName: string; + moduleName: string; referencedFiles: FileReference[]; + /** + * lib.d.ts should have a reference comment like + * + * /// + * + * If any other file has this comment, it signals not to include lib.d.ts + * because this containing file is intended to act as a default library. + */ hasNoDefaultLib: boolean; languageVersion: ScriptTarget; } @@ -878,8 +897,9 @@ declare module ts { * will be invoked when writing the JavaScript and declaration files. */ emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult; - getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; + getOptionsDiagnostics(): Diagnostic[]; getGlobalDiagnostics(): Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[]; /** @@ -998,6 +1018,11 @@ declare module ts { WriteTypeParametersOrArguments = 1, UseOnlyExternalAliasing = 2, } + interface TypePredicate { + parameterName: string; + parameterIndex: number; + type: Type; + } const enum SymbolFlags { None = 0, FunctionScopedVariable = 1, @@ -1060,6 +1085,7 @@ declare module ts { ExportHasLocal = 944, HasExports = 1952, HasMembers = 6240, + BlockScoped = 418, PropertyOrAccessor = 98308, Export = 7340032, } @@ -1111,9 +1137,8 @@ declare module ts { typeParameters: TypeParameter[]; outerTypeParameters: TypeParameter[]; localTypeParameters: TypeParameter[]; - } - interface InterfaceTypeWithBaseTypes extends InterfaceType { - baseTypes: ObjectType[]; + resolvedBaseConstructorType?: Type; + resolvedBaseTypes: ObjectType[]; } interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; @@ -1146,6 +1171,7 @@ declare module ts { declaration: SignatureDeclaration; typeParameters: TypeParameter[]; parameters: Symbol[]; + typePredicate?: TypePredicate; } const enum IndexKind { String = 0, @@ -1267,7 +1293,7 @@ declare module ts { newLength: number; } } -declare module ts { +declare namespace ts { interface System { args: string[]; newLine: string; @@ -1291,7 +1317,7 @@ declare module ts { } var sys: System; } -declare module ts { +declare namespace ts { interface ErrorCallback { (message: DiagnosticMessage, length: number): void; } @@ -1323,12 +1349,13 @@ declare module ts { function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter; function isWhiteSpace(ch: number): boolean; function isLineBreak(ch: number): boolean; + function couldStartTrivia(text: string, pos: number): boolean; function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; } -declare module ts { +declare namespace ts { function getDefaultLibFileName(options: CompilerOptions): string; function textSpanEnd(span: TextSpan): number; function textSpanIsEmpty(span: TextSpan): boolean; @@ -1338,6 +1365,7 @@ declare module ts { function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan; function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean; function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean; + function decodedTextSpanIntersectsWith(start1: number, length1: number, start2: number, length2: number): boolean; function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean; function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan; function createTextSpan(start: number, length: number): TextSpan; @@ -1357,14 +1385,14 @@ declare module ts { function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange; function getTypeParameterOwner(d: Declaration): Declaration; } -declare module ts { +declare namespace ts { function getNodeConstructor(kind: SyntaxKind): new () => Node; function createNode(kind: SyntaxKind): Node; function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T; function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile; function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; } -declare module ts { +declare namespace ts { /** The version of the TypeScript compiler release */ const version: string; function findConfigFile(searchPath: string): string; @@ -1373,7 +1401,7 @@ declare module ts { function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program; } -declare module ts { +declare namespace ts { function parseCommandLine(commandLine: string[]): ParsedCommandLine; /** * Read tsconfig.json file @@ -1400,7 +1428,7 @@ declare module ts { */ function parseConfigFile(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine; } -declare module ts { +declare namespace ts { /** The version of the language service API */ let servicesVersion: string; interface Node { @@ -1490,6 +1518,7 @@ declare module ts { log?(s: string): void; trace?(s: string): void; error?(s: string): void; + useCaseSensitiveFileNames?(): boolean; } interface LanguageService { cleanupSemanticCache(): void; @@ -1948,11 +1977,11 @@ declare module ts { isCancellationRequested(): boolean; throwIfCancellationRequested(): void; } - function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string; + function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; - function createDocumentRegistry(): DocumentRegistry; + function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry; function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; function createClassifier(): Classifier; diff --git a/bin/typescriptServices.js b/bin/typescriptServices.js index 138a38642c9..2e3a784b298 100644 --- a/bin/typescriptServices.js +++ b/bin/typescriptServices.js @@ -144,176 +144,178 @@ var ts; SyntaxKind[SyntaxKind["ConstructorKeyword"] = 114] = "ConstructorKeyword"; SyntaxKind[SyntaxKind["DeclareKeyword"] = 115] = "DeclareKeyword"; SyntaxKind[SyntaxKind["GetKeyword"] = 116] = "GetKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 117] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 118] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 119] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 120] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 121] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 122] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 123] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 124] = "TypeKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 125] = "FromKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 126] = "OfKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 117] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 118] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 119] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 120] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 121] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 122] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 123] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 124] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 125] = "TypeKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 126] = "FromKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 127] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 127] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 128] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 128] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 129] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 129] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 130] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 131] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 130] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 131] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 132] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 132] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 133] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 134] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 135] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 136] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 137] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 138] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 139] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 140] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 141] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 133] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 134] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 135] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 136] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 137] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 138] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 139] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 140] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 141] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 142] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypeReference"] = 142] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 143] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 144] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 145] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 146] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 147] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 148] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 149] = "UnionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 150] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 143] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 144] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 145] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 146] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 147] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 148] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 149] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 150] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 151] = "UnionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 152] = "ParenthesizedType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 151] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 152] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 153] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 153] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 154] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 155] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 154] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 155] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 156] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 157] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 158] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 159] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 160] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 161] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 162] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 163] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 164] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 165] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 166] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 167] = "VoidExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 168] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 169] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 170] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 171] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 172] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 173] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 174] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 175] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 176] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 177] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 156] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 157] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 158] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 159] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 160] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 161] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 162] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 163] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 164] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 165] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 166] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 167] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 168] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 169] = "VoidExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 170] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 171] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 172] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 173] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 174] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 175] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 176] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 177] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 178] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 179] = "ExpressionWithTypeArguments"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 178] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 179] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 180] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 181] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 180] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 181] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 182] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 183] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 184] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 185] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 186] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 187] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 188] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 189] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 190] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 191] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 192] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 193] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 194] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 195] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 196] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 197] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 198] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 199] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 200] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 201] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 202] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 203] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 204] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 205] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 206] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 207] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 208] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 209] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 210] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 211] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 212] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 213] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 214] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 215] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 216] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 217] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 218] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 219] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 182] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 183] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 184] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 185] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 186] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 187] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 188] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 189] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 190] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 191] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 192] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 193] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 194] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 195] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 196] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 197] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 198] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 199] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 200] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 201] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 202] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 203] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 204] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 205] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 206] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 207] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 208] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 209] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 210] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 211] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 212] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 213] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 214] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 215] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 216] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 217] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 218] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 219] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 220] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 221] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 220] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 222] = "ExternalModuleReference"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 221] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 222] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 223] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 224] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 223] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 224] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 225] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 226] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 225] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 226] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 227] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 228] = "ShorthandPropertyAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 227] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 229] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 228] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 230] = "SourceFile"; // JSDoc nodes. - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 229] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 231] = "JSDocTypeExpression"; // The * type. - SyntaxKind[SyntaxKind["JSDocAllType"] = 230] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 232] = "JSDocAllType"; // The ? type. - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 231] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 232] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 233] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 234] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 235] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 236] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 237] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 238] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 239] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 240] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 241] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 242] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 243] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 244] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 245] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 246] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 247] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 248] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 249] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 250] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 233] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 234] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 235] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 236] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 237] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 238] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 239] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 240] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 241] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 242] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 243] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 244] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 245] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 246] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 247] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 248] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 249] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 250] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 251] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 252] = "JSDocTemplateTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 251] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 253] = "SyntaxList"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 252] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 254] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 53] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 64] = "LastAssignment"; SyntaxKind[SyntaxKind["FirstReservedWord"] = 66] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 101] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 66] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 126] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 127] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 102] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 110] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 142] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 150] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 144] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 152] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 14] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 64] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 126] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 127] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 6] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 7] = "FirstLiteralToken"; @@ -322,7 +324,7 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 13] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 24] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 64] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 127] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstNode"] = 128] = "FirstNode"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { @@ -349,9 +351,6 @@ var ts; /* @internal */ (function (ParserContextFlags) { ParserContextFlags[ParserContextFlags["None"] = 0] = "None"; - // Set if this node was parsed in strict mode. Used for grammar error checks, as well as - // checking if the node can be reused in incremental settings. - ParserContextFlags[ParserContextFlags["StrictMode"] = 1] = "StrictMode"; // If this node was parsed in a context where 'in-expressions' are not allowed. ParserContextFlags[ParserContextFlags["DisallowIn"] = 2] = "DisallowIn"; // If this node was parsed in the 'yield' context created when parsing a generator. @@ -368,7 +367,7 @@ var ts; // its type can be specified usign a JSDoc comment. ParserContextFlags[ParserContextFlags["JavaScriptFile"] = 64] = "JavaScriptFile"; // Context flags set directly by the parser. - ParserContextFlags[ParserContextFlags["ParserGeneratedFlags"] = 63] = "ParserGeneratedFlags"; + ParserContextFlags[ParserContextFlags["ParserGeneratedFlags"] = 62] = "ParserGeneratedFlags"; // Context flags computed by aggregating child flags upwards. // Used during incremental parsing to determine if this node or any of its children had an // error. Computed only once and then cached. @@ -494,8 +493,13 @@ var ts; SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; SymbolFlags[SymbolFlags["HasExports"] = 1952] = "HasExports"; SymbolFlags[SymbolFlags["HasMembers"] = 6240] = "HasMembers"; + SymbolFlags[SymbolFlags["BlockScoped"] = 418] = "BlockScoped"; SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; SymbolFlags[SymbolFlags["Export"] = 7340032] = "Export"; + /* @internal */ + // The set of things we consider semantically classifiable. Used to speed up the LS during + // classification. + SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; })(ts.SymbolFlags || (ts.SymbolFlags = {})); var SymbolFlags = ts.SymbolFlags; /* @internal */ @@ -735,6 +739,36 @@ var ts; Ternary[Ternary["True"] = -1] = "True"; })(ts.Ternary || (ts.Ternary = {})); var Ternary = ts.Ternary; + function createFileMap(getCanonicalFileName) { + var files = {}; + return { + get: get, + set: set, + contains: contains, + remove: remove, + forEachValue: forEachValueInMap + }; + function set(fileName, value) { + files[normalizeKey(fileName)] = value; + } + function get(fileName) { + return files[normalizeKey(fileName)]; + } + function contains(fileName) { + return hasProperty(files, normalizeKey(fileName)); + } + function remove(fileName) { + var key = normalizeKey(fileName); + delete files[key]; + } + function forEachValueInMap(f) { + forEachValue(files, f); + } + function normalizeKey(key) { + return getCanonicalFileName(normalizeSlashes(key)); + } + } + ts.createFileMap = createFileMap; (function (Comparison) { Comparison[Comparison["LessThan"] = -1] = "LessThan"; Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; @@ -1232,7 +1266,7 @@ var ts; function getNormalizedPathComponents(path, currentDirectory) { path = normalizeSlashes(path); var rootLength = getRootLength(path); - if (rootLength == 0) { + if (rootLength === 0) { // If the path is not rooted it is relative to current directory path = combinePaths(normalizeSlashes(currentDirectory), path); rootLength = getRootLength(path); @@ -1896,14 +1930,26 @@ var ts; A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, - Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" }, - Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, + Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Modules are automatically in strict mode." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators are only available when targeting ECMAScript 6 or higher." }, Generators_are_not_allowed_in_an_ambient_context: { code: 1221, category: ts.DiagnosticCategory.Error, key: "Generators are not allowed in an ambient context." }, An_overload_signature_cannot_be_declared_as_a_generator: { code: 1222, category: ts.DiagnosticCategory.Error, key: "An overload signature cannot be declared as a generator." }, _0_tag_already_specified: { code: 1223, category: ts.DiagnosticCategory.Error, key: "'{0}' tag already specified." }, + Signature_0_must_have_a_type_predicate: { code: 1224, category: ts.DiagnosticCategory.Error, key: "Signature '{0}' must have a type predicate." }, + Cannot_find_parameter_0: { code: 1225, category: ts.DiagnosticCategory.Error, key: "Cannot find parameter '{0}'." }, + Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: ts.DiagnosticCategory.Error, key: "Type predicate '{0}' is not assignable to '{1}'." }, + Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' is not in the same position as parameter '{1}'." }, + A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: ts.DiagnosticCategory.Error, key: "A type predicate is only allowed in return type position for functions and methods." }, + A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: ts.DiagnosticCategory.Error, key: "A type predicate cannot reference a rest parameter." }, + A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: ts.DiagnosticCategory.Error, key: "A type predicate cannot reference element '{0}' in a binding pattern." }, + An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: ts.DiagnosticCategory.Error, key: "An export assignment can only be used in a module." }, + An_import_declaration_can_only_be_used_in_a_namespace_or_module: { code: 1232, category: ts.DiagnosticCategory.Error, key: "An import declaration can only be used in a namespace or module." }, + An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: ts.DiagnosticCategory.Error, key: "An export declaration can only be used in a module." }, + An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: ts.DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." }, + A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: ts.DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -2097,6 +2143,11 @@ var ts; Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, No_best_common_type_exists_among_yield_expressions: { code: 2504, category: ts.DiagnosticCategory.Error, key: "No best common type exists among yield expressions." }, A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: ts.DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." }, + _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: ts.DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own base expression." }, + Type_0_is_not_a_constructor_function_type: { code: 2507, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not a constructor function type." }, + No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: ts.DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." }, + Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: ts.DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." }, + Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: ts.DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -2306,7 +2357,7 @@ var ts; "false": 80 /* FalseKeyword */, "finally": 81 /* FinallyKeyword */, "for": 82 /* ForKeyword */, - "from": 125 /* FromKeyword */, + "from": 126 /* FromKeyword */, "function": 83 /* FunctionKeyword */, "get": 116 /* GetKeyword */, "if": 84 /* IfKeyword */, @@ -2315,36 +2366,37 @@ var ts; "in": 86 /* InKeyword */, "instanceof": 87 /* InstanceOfKeyword */, "interface": 103 /* InterfaceKeyword */, + "is": 117 /* IsKeyword */, "let": 104 /* LetKeyword */, - "module": 117 /* ModuleKeyword */, - "namespace": 118 /* NamespaceKeyword */, + "module": 118 /* ModuleKeyword */, + "namespace": 119 /* NamespaceKeyword */, "new": 88 /* NewKeyword */, "null": 89 /* NullKeyword */, - "number": 120 /* NumberKeyword */, + "number": 121 /* NumberKeyword */, "package": 105 /* PackageKeyword */, "private": 106 /* PrivateKeyword */, "protected": 107 /* ProtectedKeyword */, "public": 108 /* PublicKeyword */, - "require": 119 /* RequireKeyword */, + "require": 120 /* RequireKeyword */, "return": 90 /* ReturnKeyword */, - "set": 121 /* SetKeyword */, + "set": 122 /* SetKeyword */, "static": 109 /* StaticKeyword */, - "string": 122 /* StringKeyword */, + "string": 123 /* StringKeyword */, "super": 91 /* SuperKeyword */, "switch": 92 /* SwitchKeyword */, - "symbol": 123 /* SymbolKeyword */, + "symbol": 124 /* SymbolKeyword */, "this": 93 /* ThisKeyword */, "throw": 94 /* ThrowKeyword */, "true": 95 /* TrueKeyword */, "try": 96 /* TryKeyword */, - "type": 124 /* TypeKeyword */, + "type": 125 /* TypeKeyword */, "typeof": 97 /* TypeOfKeyword */, "var": 98 /* VarKeyword */, "void": 99 /* VoidKeyword */, "while": 100 /* WhileKeyword */, "with": 101 /* WithKeyword */, "yield": 110 /* YieldKeyword */, - "of": 126 /* OfKeyword */, + "of": 127 /* OfKeyword */, "{": 14 /* OpenBraceToken */, "}": 15 /* CloseBraceToken */, "(": 16 /* OpenParenToken */, @@ -2604,8 +2656,31 @@ var ts; return ch >= 48 /* _0 */ && ch <= 55 /* _7 */; } ts.isOctalDigit = isOctalDigit; + function couldStartTrivia(text, pos) { + // Keep in sync with skipTrivia + var ch = text.charCodeAt(pos); + switch (ch) { + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 32 /* space */: + case 47 /* slash */: + // starts of normal trivia + case 60 /* lessThan */: + case 61 /* equals */: + case 62 /* greaterThan */: + // Starts of conflict marker trivia + return true; + default: + return ch > 127 /* maxAsciiCharacter */; + } + } + ts.couldStartTrivia = couldStartTrivia; /* @internal */ function skipTrivia(text, pos, stopAfterLineBreak) { + // Keep in sync with couldStartTrivia while (true) { var ch = text.charCodeAt(pos); switch (ch) { @@ -3109,7 +3184,7 @@ var ts; error(ts.Diagnostics.Unexpected_end_of_text); isInvalidExtendedEscape = true; } - else if (text.charCodeAt(pos) == 125 /* closeBrace */) { + else if (text.charCodeAt(pos) === 125 /* closeBrace */) { // Only swallow the following character up if it's a '}'. pos++; } @@ -3666,16 +3741,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 203 /* InterfaceDeclaration */ || node.kind === 204 /* TypeAliasDeclaration */) { + if (node.kind === 205 /* InterfaceDeclaration */ || node.kind === 206 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 210 /* ImportDeclaration */ || node.kind === 209 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { + else if ((node.kind === 212 /* ImportDeclaration */ || node.kind === 211 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 207 /* ModuleBlock */) { + else if (node.kind === 209 /* ModuleBlock */) { var state = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -3694,7 +3769,7 @@ var ts; }); return state; } - else if (node.kind === 206 /* ModuleDeclaration */) { + else if (node.kind === 208 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -3734,11 +3809,17 @@ var ts; var container; var blockScopeContainer; var lastContainer; + // If this file is an external module, then it is automatically in strict-mode according to + // ES6. If it is not an external module, then we'll determine if it is in strict mode or + // not depending on if we see "use strict" in certain places (or if we hit a class/namespace). + var inStrictMode = !!file.externalModuleIndicator; var symbolCount = 0; var Symbol = ts.objectAllocator.getSymbolConstructor(); + var classifiableNames = {}; if (!file.locals) { bind(file); file.symbolCount = symbolCount; + file.classifiableNames = classifiableNames; } return; function createSymbol(flags, name) { @@ -3766,10 +3847,10 @@ var ts; // unless it is a well known Symbol. function getDeclarationName(node) { if (node.name) { - if (node.kind === 206 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */) { + if (node.kind === 208 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */) { return '"' + node.name.text + '"'; } - if (node.name.kind === 128 /* ComputedPropertyName */) { + if (node.name.kind === 129 /* ComputedPropertyName */) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -3777,22 +3858,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 136 /* Constructor */: + case 137 /* Constructor */: return "__constructor"; - case 143 /* FunctionType */: - case 139 /* CallSignature */: + case 145 /* FunctionType */: + case 140 /* CallSignature */: return "__call"; - case 144 /* ConstructorType */: - case 140 /* ConstructSignature */: + case 146 /* ConstructorType */: + case 141 /* ConstructSignature */: return "__new"; - case 141 /* IndexSignature */: + case 142 /* IndexSignature */: return "__index"; - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: return "__export"; - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 201 /* FunctionDeclaration */: - case 202 /* ClassDeclaration */: + case 203 /* FunctionDeclaration */: + case 204 /* ClassDeclaration */: return node.flags & 256 /* Default */ ? "default" : undefined; } } @@ -3826,6 +3907,9 @@ var ts; symbol = ts.hasProperty(symbolTable, name) ? symbolTable[name] : (symbolTable[name] = createSymbol(0 /* None */, name)); + if (name && (includes & 788448 /* Classifiable */)) { + classifiableNames[name] = name; + } if (symbol.flags & excludes) { if (node.name) { node.name.parent = node; @@ -3852,7 +3936,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 218 /* ExportSpecifier */ || (node.kind === 209 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 220 /* ExportSpecifier */ || (node.kind === 211 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -3933,36 +4017,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 175 /* ClassExpression */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 146 /* TypeLiteral */: - case 155 /* ObjectLiteralExpression */: + case 177 /* ClassExpression */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 148 /* TypeLiteral */: + case 157 /* ObjectLiteralExpression */: return 1 /* IsContainer */; - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 201 /* FunctionDeclaration */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - case 206 /* ModuleDeclaration */: - case 228 /* SourceFile */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 203 /* FunctionDeclaration */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 208 /* ModuleDeclaration */: + case 230 /* SourceFile */: + case 206 /* TypeAliasDeclaration */: return 5 /* IsContainerWithLocals */; - case 224 /* CatchClause */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 208 /* CaseBlock */: + case 226 /* CatchClause */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 210 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 180 /* Block */: + case 182 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Othewise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -3995,45 +4080,47 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - // Modules, source files, and classes need specialized handling for how their + // Modules, source files, and classes need specialized handling for how their // members are declared (for example, a member of a class will go into a specific - // symbol table depending on if it is static or not). As such, we defer to - // specialized handlers to take care of declaring these child members. - case 206 /* ModuleDeclaration */: + // symbol table depending on if it is static or not). We defer to specialized + // handlers to take care of declaring these child members. + case 208 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 228 /* SourceFile */: + case 230 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 175 /* ClassExpression */: - case 202 /* ClassDeclaration */: + case 177 /* ClassExpression */: + case 204 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 146 /* TypeLiteral */: - case 155 /* ObjectLiteralExpression */: - case 203 /* InterfaceDeclaration */: + case 148 /* TypeLiteral */: + case 157 /* ObjectLiteralExpression */: + case 205 /* InterfaceDeclaration */: // Interface/Object-types always have their children added to the 'members' of - // their container. They are only accessible through an instance of their - // container, and are never in scope otherwise (even inside the body of the - // object / type / interface declaring them). + // their container. They are only accessible through an instance of their + // container, and are never in scope otherwise (even inside the body of the + // object / type / interface declaring them). An exception is type parameters, + // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 206 /* TypeAliasDeclaration */: // All the children of these container types are never visible through another - // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, - // they're only accessed 'lexically' (i.e. from code that exists underneath + // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, + // they're only accessed 'lexically' (i.e. from code that exists underneath // their container in the tree. To accomplish this, we simply add their declared - // symbol to the 'locals' of the container. These symbols can then be found as + // symbol to the 'locals' of the container. These symbols can then be found as // the type checker walks up the containers, checking them for matching names. return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } @@ -4058,11 +4145,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 228 /* SourceFile */ ? node : node.body; - if (body.kind === 228 /* SourceFile */ || body.kind === 207 /* ModuleBlock */) { + var body = node.kind === 230 /* SourceFile */ ? node : node.body; + if (body.kind === 230 /* SourceFile */ || body.kind === 209 /* ModuleBlock */) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 216 /* ExportDeclaration */ || stat.kind === 215 /* ExportAssignment */) { + if (stat.kind === 218 /* ExportDeclaration */ || stat.kind === 217 /* ExportAssignment */) { return true; } } @@ -4117,16 +4204,54 @@ var ts; typeLiteralSymbol.members = (_a = {}, _a[symbol.name] = symbol, _a); var _a; } + function bindObjectLiteralExpression(node) { + var ElementKind; + (function (ElementKind) { + ElementKind[ElementKind["Property"] = 1] = "Property"; + ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; + })(ElementKind || (ElementKind = {})); + if (inStrictMode) { + var seen = {}; + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var prop = _a[_i]; + if (prop.name.kind !== 65 /* Identifier */) { + continue; + } + var identifier = prop.name; + // ECMA-262 11.1.5 Object Initialiser + // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true + // a.This production is contained in strict code and IsDataDescriptor(previous) is true and + // IsDataDescriptor(propId.descriptor) is true. + // b.IsDataDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true. + // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. + // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true + // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields + var currentKind = prop.kind === 227 /* PropertyAssignment */ || prop.kind === 228 /* ShorthandPropertyAssignment */ || prop.kind === 136 /* MethodDeclaration */ + ? 1 /* Property */ + : 2 /* Accessor */; + var existingKind = seen[identifier.text]; + if (!existingKind) { + seen[identifier.text] = currentKind; + continue; + } + if (currentKind === 1 /* Property */ && existingKind === 1 /* Property */) { + var span = ts.getErrorSpanForNode(file, identifier); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode)); + } + } + } + return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object"); + } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); addDeclarationToSymbol(symbol, node, symbolFlags); } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 228 /* SourceFile */: + case 230 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -4143,11 +4268,126 @@ var ts; function bindBlockScopedVariableDeclaration(node) { bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */); } + // The binder visits every node in the syntax tree so it is a convenient place to perform a single localized + // check for reserved words used as identifiers in strict mode code. + function checkStrictModeIdentifier(node) { + if (inStrictMode && + node.originalKeywordKind >= 102 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 110 /* LastFutureReservedWord */ && + !ts.isIdentifierName(node)) { + // Report error only if there are no parse errors in file + if (!file.parseDiagnostics.length) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); + } + } + } + function getStrictModeIdentifierMessage(node) { + // Provide specialized messages to help the user understand why we think they're in + // strict mode. + if (ts.getAncestor(node, 204 /* ClassDeclaration */) || ts.getAncestor(node, 177 /* ClassExpression */)) { + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode; + } + if (file.externalModuleIndicator) { + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode; + } + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode; + } + function checkStrictModeBinaryExpression(node) { + if (inStrictMode && ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) { + // ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an + // Assignment operator(11.13) or of a PostfixExpression(11.3) + checkStrictModeEvalOrArguments(node, node.left); + } + } + function checkStrictModeCatchClause(node) { + // It is a SyntaxError if a TryStatement with a Catch occurs within strict code and the Identifier of the + // Catch production is eval or arguments + if (inStrictMode && node.variableDeclaration) { + checkStrictModeEvalOrArguments(node, node.variableDeclaration.name); + } + } + function checkStrictModeDeleteExpression(node) { + // Grammar checking + if (inStrictMode && node.expression.kind === 65 /* Identifier */) { + // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its + // UnaryExpression is a direct reference to a variable, function argument, or function name + var span = ts.getErrorSpanForNode(file, node.expression); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); + } + } + function isEvalOrArgumentsIdentifier(node) { + return node.kind === 65 /* Identifier */ && + (node.text === "eval" || node.text === "arguments"); + } + function checkStrictModeEvalOrArguments(contextNode, name) { + if (name && name.kind === 65 /* Identifier */) { + var identifier = name; + if (isEvalOrArgumentsIdentifier(identifier)) { + // We check first if the name is inside class declaration or class expression; if so give explicit message + // otherwise report generic error message. + var span = ts.getErrorSpanForNode(file, name); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, getStrictModeEvalOrArgumentsMessage(contextNode), identifier.text)); + } + } + } + function getStrictModeEvalOrArgumentsMessage(node) { + // Provide specialized messages to help the user understand why we think they're in + // strict mode. + if (ts.getAncestor(node, 204 /* ClassDeclaration */) || ts.getAncestor(node, 177 /* ClassExpression */)) { + return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode; + } + if (file.externalModuleIndicator) { + return ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode; + } + return ts.Diagnostics.Invalid_use_of_0_in_strict_mode; + } + function checkStrictModeFunctionName(node) { + if (inStrictMode) { + // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a strict mode FunctionDeclaration or FunctionExpression (13.1)) + checkStrictModeEvalOrArguments(node, node.name); + } + } + function checkStrictModeNumericLiteral(node) { + if (inStrictMode && node.flags & 16384 /* OctalLiteral */) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); + } + } + function checkStrictModePostfixUnaryExpression(node) { + // Grammar checking + // The identifier eval or arguments may not appear as the LeftHandSideExpression of an + // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression + // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator. + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.operand); + } + } + function checkStrictModePrefixUnaryExpression(node) { + // Grammar checking + if (inStrictMode) { + if (node.operator === 38 /* PlusPlusToken */ || node.operator === 39 /* MinusMinusToken */) { + checkStrictModeEvalOrArguments(node, node.operand); + } + } + } + function checkStrictModeWithStatement(node) { + // Grammar checking for withStatement + if (inStrictMode) { + grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); + } + } + function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + var span = ts.getSpanOfTokenAtPosition(file, node.pos); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); + } function getDestructuringParameterName(node) { return "__" + ts.indexOf(node.parent.parameters, node); } function bind(node) { node.parent = parent; + var savedInStrictMode = inStrictMode; + if (!savedInStrictMode) { + updateStrictMode(node); + } // First we bind declaration nodes to a symbol if possible. We'll both create a symbol // and then potentially add the symbol to an appropriate symbol table. Possible // destination symbol tables are: @@ -4164,76 +4404,132 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. bindChildren(node); + inStrictMode = savedInStrictMode; + } + function updateStrictMode(node) { + switch (node.kind) { + case 230 /* SourceFile */: + case 209 /* ModuleBlock */: + updateStrictModeStatementList(node.statements); + return; + case 182 /* Block */: + if (ts.isFunctionLike(node.parent)) { + updateStrictModeStatementList(node.statements); + } + return; + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: + // All classes are automatically in strict mode in ES6. + inStrictMode = true; + return; + } + } + function updateStrictModeStatementList(statements) { + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (!ts.isPrologueDirective(statement)) { + return; + } + if (isUseStrictPrologueDirective(statement)) { + inStrictMode = true; + return; + } + } + } + /// Should be called only on prologue directives (isPrologueDirective(node) should be true) + function isUseStrictPrologueDirective(node) { + var nodeText = ts.getTextOfNodeFromSourceText(file.text, node.expression); + // Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the + // string to contain unicode escapes (as per ES5). + return nodeText === '"use strict"' || nodeText === "'use strict'"; } function bindWorker(node) { switch (node.kind) { - case 129 /* TypeParameter */: + case 65 /* Identifier */: + return checkStrictModeIdentifier(node); + case 172 /* BinaryExpression */: + return checkStrictModeBinaryExpression(node); + case 226 /* CatchClause */: + return checkStrictModeCatchClause(node); + case 167 /* DeleteExpression */: + return checkStrictModeDeleteExpression(node); + case 7 /* NumericLiteral */: + return checkStrictModeNumericLiteral(node); + case 171 /* PostfixUnaryExpression */: + return checkStrictModePostfixUnaryExpression(node); + case 170 /* PrefixUnaryExpression */: + return checkStrictModePrefixUnaryExpression(node); + case 195 /* WithStatement */: + return checkStrictModeWithStatement(node); + case 130 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */); - case 130 /* Parameter */: + case 131 /* Parameter */: return bindParameter(node); - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */); - case 225 /* PropertyAssignment */: - case 226 /* ShorthandPropertyAssignment */: + case 227 /* PropertyAssignment */: + case 228 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); - case 227 /* EnumMember */: + case 229 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: + checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */); - case 136 /* Constructor */: + case 137 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, 0 /* None */); - case 137 /* GetAccessor */: + case 138 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 138 /* SetAccessor */: + case 139 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 146 /* TypeLiteral */: + case 148 /* TypeLiteral */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 155 /* ObjectLiteralExpression */: - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object"); - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 157 /* ObjectLiteralExpression */: + return bindObjectLiteralExpression(node); + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + checkStrictModeFunctionName(node); return bindAnonymousDeclaration(node, 16 /* Function */, "__function"); - case 175 /* ClassExpression */: - case 202 /* ClassDeclaration */: + case 177 /* ClassExpression */: + case 204 /* ClassDeclaration */: return bindClassLikeDeclaration(node); - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792992 /* InterfaceExcludes */); - case 204 /* TypeAliasDeclaration */: + case 206 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return bindModuleDeclaration(node); - case 209 /* ImportEqualsDeclaration */: - case 212 /* NamespaceImport */: - case 214 /* ImportSpecifier */: - case 218 /* ExportSpecifier */: + case 211 /* ImportEqualsDeclaration */: + case 214 /* NamespaceImport */: + case 216 /* ImportSpecifier */: + case 220 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 211 /* ImportClause */: + case 213 /* ImportClause */: return bindImportClause(node); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: return bindExportDeclaration(node); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return bindExportAssignment(node); - case 228 /* SourceFile */: + case 230 /* SourceFile */: return bindSourceFileIfExternalModule(); } } @@ -4244,7 +4540,11 @@ var ts; } } function bindExportAssignment(node) { - if (node.expression.kind === 65 /* Identifier */) { + if (!container.symbol || !container.symbol.exports) { + // Export assignment in some sort of block construct + bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); + } + else if (node.expression.kind === 65 /* Identifier */) { // An export default clause with an identifier exports all meanings of that identifier declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* Alias */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); } @@ -4254,7 +4554,11 @@ var ts; } } function bindExportDeclaration(node) { - if (!node.exportClause) { + if (!container.symbol || !container.symbol.exports) { + // Export * in some sort of block construct + bindAnonymousDeclaration(node, 1073741824 /* ExportStar */, getDeclarationName(node)); + } + else if (!node.exportClause) { // All export * declarations are collected in an __export symbol declareSymbol(container.symbol.exports, container.symbol, node, 1073741824 /* ExportStar */, 0 /* None */); } @@ -4265,7 +4569,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899583 /* ClassExcludes */); } else { @@ -4297,6 +4601,9 @@ var ts; : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); } function bindVariableDeclarationOrBindingElement(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.name); + } if (!ts.isBindingPattern(node.name)) { if (ts.isBlockOrCatchScoped(node)) { bindBlockScopedVariableDeclaration(node); @@ -4319,6 +4626,11 @@ var ts; } } function bindParameter(node) { + if (inStrictMode) { + // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a + // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) + checkStrictModeEvalOrArguments(node, node.name); + } if (ts.isBindingPattern(node.name)) { bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, getDestructuringParameterName(node)); } @@ -4328,8 +4640,8 @@ var ts; // If this is a property-parameter, then also declare the property symbol into the // containing class. if (node.flags & 112 /* AccessibilityModifier */ && - node.parent.kind === 136 /* Constructor */ && - (node.parent.parent.kind === 202 /* ClassDeclaration */ || node.parent.parent.kind === 175 /* ClassExpression */)) { + node.parent.kind === 137 /* Constructor */ && + (node.parent.parent.kind === 204 /* ClassDeclaration */ || node.parent.parent.kind === 177 /* ClassExpression */)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); } @@ -4359,7 +4671,7 @@ var ts; // Pool writers to avoid needing to allocate them for every symbol we write. var stringWriters = []; function getSingleLineStringWriter() { - if (stringWriters.length == 0) { + if (stringWriters.length === 0) { var str = ""; var writeText = function (text) { return str += text; }; return { @@ -4416,7 +4728,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 228 /* SourceFile */) { + while (node && node.kind !== 230 /* SourceFile */) { node = node.parent; } return node; @@ -4526,15 +4838,15 @@ var ts; return current; } switch (current.kind) { - case 228 /* SourceFile */: - case 208 /* CaseBlock */: - case 224 /* CatchClause */: - case 206 /* ModuleDeclaration */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: + case 230 /* SourceFile */: + case 210 /* CaseBlock */: + case 226 /* CatchClause */: + case 208 /* ModuleDeclaration */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: return current; - case 180 /* Block */: + case 182 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block if (!isFunctionLike(current.parent)) { @@ -4547,9 +4859,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 199 /* VariableDeclaration */ && + declaration.kind === 201 /* VariableDeclaration */ && declaration.parent && - declaration.parent.kind === 224 /* CatchClause */; + declaration.parent.kind === 226 /* CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; // Return display name of an identifier @@ -4588,7 +4900,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 228 /* SourceFile */: + case 230 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -4597,16 +4909,16 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: - case 202 /* ClassDeclaration */: - case 175 /* ClassExpression */: - case 203 /* InterfaceDeclaration */: - case 206 /* ModuleDeclaration */: - case 205 /* EnumDeclaration */: - case 227 /* EnumMember */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: + case 205 /* InterfaceDeclaration */: + case 208 /* ModuleDeclaration */: + case 207 /* EnumDeclaration */: + case 229 /* EnumMember */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: errorNode = node.name; break; } @@ -4630,11 +4942,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 205 /* EnumDeclaration */ && isConst(node); + return node.kind === 207 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 153 /* BindingElement */ || isBindingPattern(node))) { + while (node && (node.kind === 155 /* BindingElement */ || isBindingPattern(node))) { node = node.parent; } return node; @@ -4649,14 +4961,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 199 /* VariableDeclaration */) { + if (node.kind === 201 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 200 /* VariableDeclarationList */) { + if (node && node.kind === 202 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 181 /* VariableStatement */) { + if (node && node.kind === 183 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -4671,12 +4983,12 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 183 /* ExpressionStatement */ && node.expression.kind === 8 /* StringLiteral */; + return node.kind === 185 /* ExpressionStatement */ && node.expression.kind === 8 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { // If parameter/type parameter, the prev token trailing comments are part of this node too - if (node.kind === 130 /* Parameter */ || node.kind === 129 /* TypeParameter */) { + if (node.kind === 131 /* Parameter */ || node.kind === 130 /* TypeParameter */) { // e.g. (/** blah */ a, /** blah */ b); // e.g.: ( // /** blah */ a, @@ -4700,40 +5012,40 @@ var ts; ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (142 /* FirstTypeNode */ <= node.kind && node.kind <= 150 /* LastTypeNode */) { + if (144 /* FirstTypeNode */ <= node.kind && node.kind <= 152 /* LastTypeNode */) { return true; } switch (node.kind) { case 112 /* AnyKeyword */: - case 120 /* NumberKeyword */: - case 122 /* StringKeyword */: + case 121 /* NumberKeyword */: + case 123 /* StringKeyword */: case 113 /* BooleanKeyword */: - case 123 /* SymbolKeyword */: + case 124 /* SymbolKeyword */: return true; case 99 /* VoidKeyword */: - return node.parent.kind !== 167 /* VoidExpression */; + return node.parent.kind !== 169 /* VoidExpression */; case 8 /* StringLiteral */: // Specialized signatures can have string literals as their parameters' type names - return node.parent.kind === 130 /* Parameter */; - case 177 /* ExpressionWithTypeArguments */: - return true; + return node.parent.kind === 131 /* Parameter */; + case 179 /* ExpressionWithTypeArguments */: + return !isExpressionWithTypeArgumentsInClassExtendsClause(node); // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 65 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 127 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 128 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 156 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 158 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // fall through - case 127 /* QualifiedName */: - case 156 /* PropertyAccessExpression */: + case 128 /* QualifiedName */: + case 158 /* PropertyAccessExpression */: // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 65 /* Identifier */ || node.kind === 127 /* QualifiedName */ || node.kind === 156 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + ts.Debug.assert(node.kind === 65 /* Identifier */ || node.kind === 128 /* QualifiedName */ || node.kind === 158 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_1 = node.parent; - if (parent_1.kind === 145 /* TypeQuery */) { + if (parent_1.kind === 147 /* TypeQuery */) { return false; } // Do not recursively call isTypeNode on the parent. In the example: @@ -4742,38 +5054,38 @@ var ts; // // Calling isTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (142 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 150 /* LastTypeNode */) { + if (144 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 152 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 177 /* ExpressionWithTypeArguments */: - return true; - case 129 /* TypeParameter */: + case 179 /* ExpressionWithTypeArguments */: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); + case 130 /* TypeParameter */: return node === parent_1.constraint; - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 130 /* Parameter */: - case 199 /* VariableDeclaration */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 131 /* Parameter */: + case 201 /* VariableDeclaration */: return node === parent_1.type; - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - case 136 /* Constructor */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 137 /* Constructor */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: return node === parent_1.type; - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: return node === parent_1.type; - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: return node === parent_1.type; - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 160 /* TaggedTemplateExpression */: + case 162 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -4787,23 +5099,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 192 /* ReturnStatement */: + case 194 /* ReturnStatement */: return visitor(node); - case 208 /* CaseBlock */: - case 180 /* Block */: - case 184 /* IfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 193 /* WithStatement */: - case 194 /* SwitchStatement */: - case 221 /* CaseClause */: - case 222 /* DefaultClause */: - case 195 /* LabeledStatement */: - case 197 /* TryStatement */: - case 224 /* CatchClause */: + case 210 /* CaseBlock */: + case 182 /* Block */: + case 186 /* IfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 195 /* WithStatement */: + case 196 /* SwitchStatement */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: + case 197 /* LabeledStatement */: + case 199 /* TryStatement */: + case 226 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -4813,17 +5125,17 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 173 /* YieldExpression */: + case 175 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 205 /* EnumDeclaration */: - case 203 /* InterfaceDeclaration */: - case 206 /* ModuleDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 202 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 205 /* InterfaceDeclaration */: + case 208 /* ModuleDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 204 /* ClassDeclaration */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. @@ -4831,7 +5143,7 @@ var ts; default: if (isFunctionLike(node)) { var name_4 = node.name; - if (name_4 && name_4.kind === 128 /* ComputedPropertyName */) { + if (name_4 && name_4.kind === 129 /* ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(name_4.expression); @@ -4850,14 +5162,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 153 /* BindingElement */: - case 227 /* EnumMember */: - case 130 /* Parameter */: - case 225 /* PropertyAssignment */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 226 /* ShorthandPropertyAssignment */: - case 199 /* VariableDeclaration */: + case 155 /* BindingElement */: + case 229 /* EnumMember */: + case 131 /* Parameter */: + case 227 /* PropertyAssignment */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 228 /* ShorthandPropertyAssignment */: + case 201 /* VariableDeclaration */: return true; } } @@ -4867,8 +5179,8 @@ var ts; function isAccessor(node) { if (node) { switch (node.kind) { - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: return true; } } @@ -4877,26 +5189,26 @@ var ts; ts.isAccessor = isAccessor; function isClassLike(node) { if (node) { - return node.kind === 202 /* ClassDeclaration */ || node.kind === 175 /* ClassExpression */; + return node.kind === 204 /* ClassDeclaration */ || node.kind === 177 /* ClassExpression */; } } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 136 /* Constructor */: - case 163 /* FunctionExpression */: - case 201 /* FunctionDeclaration */: - case 164 /* ArrowFunction */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: - case 143 /* FunctionType */: - case 144 /* ConstructorType */: + case 137 /* Constructor */: + case 165 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: + case 166 /* ArrowFunction */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: return true; } } @@ -4904,11 +5216,11 @@ var ts; } ts.isFunctionLike = isFunctionLike; function isFunctionBlock(node) { - return node && node.kind === 180 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 182 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 135 /* MethodDeclaration */ && node.parent.kind === 155 /* ObjectLiteralExpression */; + return node && node.kind === 136 /* MethodDeclaration */ && node.parent.kind === 157 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -4927,12 +5239,12 @@ var ts; return undefined; } switch (node.kind) { - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container // so that we can error on it. - if (node.parent.parent.kind === 202 /* ClassDeclaration */) { + if (node.parent.parent.kind === 204 /* ClassDeclaration */) { return node; } // If this is a computed property, then the parent should not @@ -4942,9 +5254,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 131 /* Decorator */: + case 132 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 130 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 131 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -4955,23 +5267,23 @@ var ts; node = node.parent; } break; - case 164 /* ArrowFunction */: + case 166 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 206 /* ModuleDeclaration */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 205 /* EnumDeclaration */: - case 228 /* SourceFile */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 208 /* ModuleDeclaration */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 207 /* EnumDeclaration */: + case 230 /* SourceFile */: return node; } } @@ -4983,12 +5295,12 @@ var ts; if (!node) return node; switch (node.kind) { - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'super' container. // A computed property name in a class needs to be a super container // so that we can error on it. - if (node.parent.parent.kind === 202 /* ClassDeclaration */) { + if (node.parent.parent.kind === 204 /* ClassDeclaration */) { return node; } // If this is a computed property, then the parent should not @@ -4998,9 +5310,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 131 /* Decorator */: + case 132 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 130 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 131 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -5011,26 +5323,26 @@ var ts; node = node.parent; } break; - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: if (!includeFunctions) { continue; } - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: return node; } } } ts.getSuperContainer = getSuperContainer; function getInvokedExpression(node) { - if (node.kind === 160 /* TaggedTemplateExpression */) { + if (node.kind === 162 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression or NewExpression. @@ -5039,44 +5351,44 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: // classes are valid targets return true; - case 133 /* PropertyDeclaration */: + case 134 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 202 /* ClassDeclaration */; - case 130 /* Parameter */: + return node.parent.kind === 204 /* ClassDeclaration */; + case 131 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; - return node.parent.body && node.parent.parent.kind === 202 /* ClassDeclaration */; - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 135 /* MethodDeclaration */: + return node.parent.body && node.parent.parent.kind === 204 /* ClassDeclaration */; + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 136 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. - return node.body && node.parent.kind === 202 /* ClassDeclaration */; + return node.body && node.parent.kind === 204 /* ClassDeclaration */; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: if (node.decorators) { return true; } return false; - case 133 /* PropertyDeclaration */: - case 130 /* Parameter */: + case 134 /* PropertyDeclaration */: + case 131 /* Parameter */: if (node.decorators) { return true; } return false; - case 137 /* GetAccessor */: + case 138 /* GetAccessor */: if (node.body && node.decorators) { return true; } return false; - case 135 /* MethodDeclaration */: - case 138 /* SetAccessor */: + case 136 /* MethodDeclaration */: + case 139 /* SetAccessor */: if (node.body && node.decorators) { return true; } @@ -5087,10 +5399,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 135 /* MethodDeclaration */: - case 138 /* SetAccessor */: + case 136 /* MethodDeclaration */: + case 139 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -5108,38 +5420,38 @@ var ts; case 95 /* TrueKeyword */: case 80 /* FalseKeyword */: case 9 /* RegularExpressionLiteral */: - case 154 /* ArrayLiteralExpression */: - case 155 /* ObjectLiteralExpression */: - case 156 /* PropertyAccessExpression */: - case 157 /* ElementAccessExpression */: - case 158 /* CallExpression */: - case 159 /* NewExpression */: - case 160 /* TaggedTemplateExpression */: - case 161 /* TypeAssertionExpression */: - case 162 /* ParenthesizedExpression */: - case 163 /* FunctionExpression */: - case 175 /* ClassExpression */: - case 164 /* ArrowFunction */: - case 167 /* VoidExpression */: - case 165 /* DeleteExpression */: - case 166 /* TypeOfExpression */: - case 168 /* PrefixUnaryExpression */: - case 169 /* PostfixUnaryExpression */: - case 170 /* BinaryExpression */: - case 171 /* ConditionalExpression */: - case 174 /* SpreadElementExpression */: - case 172 /* TemplateExpression */: + case 156 /* ArrayLiteralExpression */: + case 157 /* ObjectLiteralExpression */: + case 158 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: + case 162 /* TaggedTemplateExpression */: + case 163 /* TypeAssertionExpression */: + case 164 /* ParenthesizedExpression */: + case 165 /* FunctionExpression */: + case 177 /* ClassExpression */: + case 166 /* ArrowFunction */: + case 169 /* VoidExpression */: + case 167 /* DeleteExpression */: + case 168 /* TypeOfExpression */: + case 170 /* PrefixUnaryExpression */: + case 171 /* PostfixUnaryExpression */: + case 172 /* BinaryExpression */: + case 173 /* ConditionalExpression */: + case 176 /* SpreadElementExpression */: + case 174 /* TemplateExpression */: case 10 /* NoSubstitutionTemplateLiteral */: - case 176 /* OmittedExpression */: - case 173 /* YieldExpression */: + case 178 /* OmittedExpression */: + case 175 /* YieldExpression */: return true; - case 127 /* QualifiedName */: - while (node.parent.kind === 127 /* QualifiedName */) { + case 128 /* QualifiedName */: + while (node.parent.kind === 128 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 145 /* TypeQuery */; + return node.parent.kind === 147 /* TypeQuery */; case 65 /* Identifier */: - if (node.parent.kind === 145 /* TypeQuery */) { + if (node.parent.kind === 147 /* TypeQuery */) { return true; } // fall through @@ -5147,43 +5459,45 @@ var ts; case 8 /* StringLiteral */: var parent_2 = node.parent; switch (parent_2.kind) { - case 199 /* VariableDeclaration */: - case 130 /* Parameter */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 227 /* EnumMember */: - case 225 /* PropertyAssignment */: - case 153 /* BindingElement */: + case 201 /* VariableDeclaration */: + case 131 /* Parameter */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 229 /* EnumMember */: + case 227 /* PropertyAssignment */: + case 155 /* BindingElement */: return parent_2.initializer === node; - case 183 /* ExpressionStatement */: - case 184 /* IfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: - case 192 /* ReturnStatement */: - case 193 /* WithStatement */: - case 194 /* SwitchStatement */: - case 221 /* CaseClause */: - case 196 /* ThrowStatement */: - case 194 /* SwitchStatement */: + case 185 /* ExpressionStatement */: + case 186 /* IfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: + case 194 /* ReturnStatement */: + case 195 /* WithStatement */: + case 196 /* SwitchStatement */: + case 223 /* CaseClause */: + case 198 /* ThrowStatement */: + case 196 /* SwitchStatement */: return parent_2.expression === node; - case 187 /* ForStatement */: + case 189 /* ForStatement */: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 200 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 202 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 200 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 202 /* VariableDeclarationList */) || forInStatement.expression === node; - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: return node === parent_2.expression; - case 178 /* TemplateSpan */: + case 180 /* TemplateSpan */: return node === parent_2.expression; - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: return node === parent_2.expression; - case 131 /* Decorator */: + case 132 /* Decorator */: return true; + case 179 /* ExpressionWithTypeArguments */: + return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { return true; @@ -5200,7 +5514,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 209 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 220 /* ExternalModuleReference */; + return node.kind === 211 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 222 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5209,20 +5523,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 209 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 220 /* ExternalModuleReference */; + return node.kind === 211 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 222 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 210 /* ImportDeclaration */) { + if (node.kind === 212 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 209 /* ImportEqualsDeclaration */) { + if (node.kind === 211 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 220 /* ExternalModuleReference */) { + if (reference.kind === 222 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 216 /* ExportDeclaration */) { + if (node.kind === 218 /* ExportDeclaration */) { return node.moduleSpecifier; } } @@ -5230,15 +5544,15 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 130 /* Parameter */: + case 131 /* Parameter */: return node.questionToken !== undefined; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return node.questionToken !== undefined; - case 226 /* ShorthandPropertyAssignment */: - case 225 /* PropertyAssignment */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 228 /* ShorthandPropertyAssignment */: + case 227 /* PropertyAssignment */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -5246,9 +5560,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 241 /* JSDocFunctionType */ && + return node.kind === 243 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 243 /* JSDocConstructorType */; + node.parameters[0].type.kind === 245 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -5262,15 +5576,15 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 249 /* JSDocTypeTag */); + return getJSDocTag(node, 251 /* JSDocTypeTag */); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 248 /* JSDocReturnTag */); + return getJSDocTag(node, 250 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 250 /* JSDocTemplateTag */); + return getJSDocTag(node, 252 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { @@ -5281,7 +5595,7 @@ var ts; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 247 /* JSDocParameterTag */) { + if (t.kind === 249 /* JSDocParameterTag */) { var parameterTag = t; var name_5 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_5.text === parameterName) { @@ -5300,12 +5614,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 64 /* JavaScriptFile */) { - if (node.type && node.type.kind === 242 /* JSDocVariadicType */) { + if (node.type && node.type.kind === 244 /* JSDocVariadicType */) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 242 /* JSDocVariadicType */; + return paramTag.typeExpression.type.kind === 244 /* JSDocVariadicType */; } } return node.dotDotDotToken !== undefined; @@ -5326,7 +5640,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 152 /* ArrayBindingPattern */ || node.kind === 151 /* ObjectBindingPattern */); + return !!node && (node.kind === 154 /* ArrayBindingPattern */ || node.kind === 153 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -5341,33 +5655,33 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 164 /* ArrowFunction */: - case 153 /* BindingElement */: - case 202 /* ClassDeclaration */: - case 136 /* Constructor */: - case 205 /* EnumDeclaration */: - case 227 /* EnumMember */: - case 218 /* ExportSpecifier */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 137 /* GetAccessor */: - case 211 /* ImportClause */: - case 209 /* ImportEqualsDeclaration */: - case 214 /* ImportSpecifier */: - case 203 /* InterfaceDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 206 /* ModuleDeclaration */: - case 212 /* NamespaceImport */: - case 130 /* Parameter */: - case 225 /* PropertyAssignment */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 138 /* SetAccessor */: - case 226 /* ShorthandPropertyAssignment */: - case 204 /* TypeAliasDeclaration */: - case 129 /* TypeParameter */: - case 199 /* VariableDeclaration */: + case 166 /* ArrowFunction */: + case 155 /* BindingElement */: + case 204 /* ClassDeclaration */: + case 137 /* Constructor */: + case 207 /* EnumDeclaration */: + case 229 /* EnumMember */: + case 220 /* ExportSpecifier */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 138 /* GetAccessor */: + case 213 /* ImportClause */: + case 211 /* ImportEqualsDeclaration */: + case 216 /* ImportSpecifier */: + case 205 /* InterfaceDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 208 /* ModuleDeclaration */: + case 214 /* NamespaceImport */: + case 131 /* Parameter */: + case 227 /* PropertyAssignment */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 139 /* SetAccessor */: + case 228 /* ShorthandPropertyAssignment */: + case 206 /* TypeAliasDeclaration */: + case 130 /* TypeParameter */: + case 201 /* VariableDeclaration */: return true; } return false; @@ -5375,25 +5689,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 191 /* BreakStatement */: - case 190 /* ContinueStatement */: - case 198 /* DebuggerStatement */: - case 185 /* DoStatement */: - case 183 /* ExpressionStatement */: - case 182 /* EmptyStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 187 /* ForStatement */: - case 184 /* IfStatement */: - case 195 /* LabeledStatement */: - case 192 /* ReturnStatement */: - case 194 /* SwitchStatement */: + case 193 /* BreakStatement */: + case 192 /* ContinueStatement */: + case 200 /* DebuggerStatement */: + case 187 /* DoStatement */: + case 185 /* ExpressionStatement */: + case 184 /* EmptyStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 189 /* ForStatement */: + case 186 /* IfStatement */: + case 197 /* LabeledStatement */: + case 194 /* ReturnStatement */: + case 196 /* SwitchStatement */: case 94 /* ThrowKeyword */: - case 197 /* TryStatement */: - case 181 /* VariableStatement */: - case 186 /* WhileStatement */: - case 193 /* WithStatement */: - case 215 /* ExportAssignment */: + case 199 /* TryStatement */: + case 183 /* VariableStatement */: + case 188 /* WhileStatement */: + case 195 /* WithStatement */: + case 217 /* ExportAssignment */: return true; default: return false; @@ -5402,13 +5716,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 136 /* Constructor */: - case 133 /* PropertyDeclaration */: - case 135 /* MethodDeclaration */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 134 /* MethodSignature */: - case 141 /* IndexSignature */: + case 137 /* Constructor */: + case 134 /* PropertyDeclaration */: + case 136 /* MethodDeclaration */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 135 /* MethodSignature */: + case 142 /* IndexSignature */: return true; default: return false; @@ -5421,7 +5735,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 214 /* ImportSpecifier */ || parent.kind === 218 /* ExportSpecifier */) { + if (parent.kind === 216 /* ImportSpecifier */ || parent.kind === 220 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -5432,6 +5746,41 @@ var ts; return false; } ts.isDeclarationName = isDeclarationName; + // Return true if the given identifier is classified as an IdentifierName + function isIdentifierName(node) { + var parent = node.parent; + switch (parent.kind) { + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 229 /* EnumMember */: + case 227 /* PropertyAssignment */: + case 158 /* PropertyAccessExpression */: + // Name in member declaration or property name in property access + return parent.name === node; + case 128 /* QualifiedName */: + // Name on right hand side of dot in a type query + if (parent.right === node) { + while (parent.kind === 128 /* QualifiedName */) { + parent = parent.parent; + } + return parent.kind === 147 /* TypeQuery */; + } + return false; + case 155 /* BindingElement */: + case 216 /* ImportSpecifier */: + // Property name in binding element or import specifier + return parent.propertyName === node; + case 220 /* ExportSpecifier */: + // Any name in an export specifier + return true; + } + return false; + } + ts.isIdentifierName = isIdentifierName; // An alias symbol is created by one of the following declarations: // import = ... // import from ... @@ -5441,12 +5790,12 @@ var ts; // export = ... // export default ... function isAliasSymbolDeclaration(node) { - return node.kind === 209 /* ImportEqualsDeclaration */ || - node.kind === 211 /* ImportClause */ && !!node.name || - node.kind === 212 /* NamespaceImport */ || - node.kind === 214 /* ImportSpecifier */ || - node.kind === 218 /* ExportSpecifier */ || - node.kind === 215 /* ExportAssignment */ && node.expression.kind === 65 /* Identifier */; + return node.kind === 211 /* ImportEqualsDeclaration */ || + node.kind === 213 /* ImportClause */ && !!node.name || + node.kind === 214 /* NamespaceImport */ || + node.kind === 216 /* ImportSpecifier */ || + node.kind === 220 /* ExportSpecifier */ || + node.kind === 217 /* ExportAssignment */ && node.expression.kind === 65 /* Identifier */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { @@ -5529,7 +5878,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 66 /* FirstKeyword */ <= token && token <= 126 /* LastKeyword */; + return 66 /* FirstKeyword */ <= token && token <= 127 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -5545,7 +5894,7 @@ var ts; */ function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 128 /* ComputedPropertyName */ && + declaration.name.kind === 129 /* ComputedPropertyName */ && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; @@ -5555,14 +5904,14 @@ var ts; * where Symbol is literally the word "Symbol", and name is any identifierName */ function isWellKnownSymbolSyntactically(node) { - return node.kind === 156 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); + return node.kind === 158 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { if (name.kind === 65 /* Identifier */ || name.kind === 8 /* StringLiteral */ || name.kind === 7 /* NumericLiteral */) { return name.text; } - if (name.kind === 128 /* ComputedPropertyName */) { + if (name.kind === 129 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -5600,18 +5949,18 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 130 /* Parameter */; + return root.kind === 131 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 153 /* BindingElement */) { + while (node.kind === 155 /* BindingElement */) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 206 /* ModuleDeclaration */ || n.kind === 228 /* SourceFile */; + return isFunctionLike(n) || n.kind === 208 /* ModuleDeclaration */ || n.kind === 230 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -5847,7 +6196,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 136 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 137 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -5872,10 +6221,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 137 /* GetAccessor */) { + if (accessor.kind === 138 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 138 /* SetAccessor */) { + else if (accessor.kind === 139 /* SetAccessor */) { setAccessor = accessor; } else { @@ -5884,7 +6233,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 137 /* GetAccessor */ || member.kind === 138 /* SetAccessor */) + if ((member.kind === 138 /* GetAccessor */ || member.kind === 139 /* SetAccessor */) && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -5895,10 +6244,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 137 /* GetAccessor */ && !getAccessor) { + if (member.kind === 138 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 138 /* SetAccessor */ && !setAccessor) { + if (member.kind === 139 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -6046,22 +6395,22 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 156 /* PropertyAccessExpression */: - case 157 /* ElementAccessExpression */: - case 159 /* NewExpression */: - case 158 /* CallExpression */: - case 160 /* TaggedTemplateExpression */: - case 154 /* ArrayLiteralExpression */: - case 162 /* ParenthesizedExpression */: - case 155 /* ObjectLiteralExpression */: - case 175 /* ClassExpression */: - case 163 /* FunctionExpression */: + case 158 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + case 161 /* NewExpression */: + case 160 /* CallExpression */: + case 162 /* TaggedTemplateExpression */: + case 156 /* ArrayLiteralExpression */: + case 164 /* ParenthesizedExpression */: + case 157 /* ObjectLiteralExpression */: + case 177 /* ClassExpression */: + case 165 /* FunctionExpression */: case 65 /* Identifier */: case 9 /* RegularExpressionLiteral */: case 7 /* NumericLiteral */: case 8 /* StringLiteral */: case 10 /* NoSubstitutionTemplateLiteral */: - case 172 /* TemplateExpression */: + case 174 /* TemplateExpression */: case 80 /* FalseKeyword */: case 89 /* NullKeyword */: case 93 /* ThisKeyword */: @@ -6077,6 +6426,12 @@ var ts; return token >= 53 /* FirstAssignment */ && token <= 64 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; + function isExpressionWithTypeArgumentsInClassExtendsClause(node) { + return node.kind === 179 /* ExpressionWithTypeArguments */ && + node.parent.token === 79 /* ExtendsKeyword */ && + node.parent.parent.kind === 204 /* ClassDeclaration */; + } + ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; // Returns false if this heritage clause element's expression contains something unsupported // (i.e. not a name or dotted name). function isSupportedExpressionWithTypeArguments(node) { @@ -6087,7 +6442,7 @@ var ts; if (node.kind === 65 /* Identifier */) { return true; } - else if (node.kind === 156 /* PropertyAccessExpression */) { + else if (node.kind === 158 /* PropertyAccessExpression */) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -6095,8 +6450,8 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 127 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 156 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 128 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 158 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function getLocalSymbolForExportDefault(symbol) { @@ -6237,6 +6592,12 @@ var ts; return start <= textSpanEnd(span) && end >= span.start; } ts.textSpanIntersectsWith = textSpanIntersectsWith; + function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { + var end1 = start1 + length1; + var end2 = start2 + length2; + return start2 <= end1 && end2 >= start1; + } + ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; function textSpanIntersectsWithPosition(span, position) { return position <= textSpanEnd(span) && position >= span.start; } @@ -6396,9 +6757,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 129 /* TypeParameter */) { + if (d && d.kind === 130 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 203 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 205 /* InterfaceDeclaration */) { return current; } } @@ -6410,7 +6771,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(252 /* Count */); + var nodeConstructors = new Array(254 /* Count */); /* @internal */ ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -6455,20 +6816,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 127 /* QualifiedName */: + case 128 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 129 /* TypeParameter */: + case 130 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 130 /* Parameter */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 225 /* PropertyAssignment */: - case 226 /* ShorthandPropertyAssignment */: - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: + case 131 /* Parameter */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 227 /* PropertyAssignment */: + case 228 /* ShorthandPropertyAssignment */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -6477,24 +6838,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 163 /* FunctionExpression */: - case 201 /* FunctionDeclaration */: - case 164 /* ArrowFunction */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 165 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: + case 166 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -6505,263 +6866,267 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 142 /* TypeReference */: + case 144 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 145 /* TypeQuery */: + case 143 /* TypePredicate */: + return visitNode(cbNode, node.parameterName) || + visitNode(cbNode, node.type); + case 147 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 146 /* TypeLiteral */: + case 148 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 147 /* ArrayType */: + case 149 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 148 /* TupleType */: + case 150 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 149 /* UnionType */: + case 151 /* UnionType */: return visitNodes(cbNodes, node.types); - case 150 /* ParenthesizedType */: + case 152 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 151 /* ObjectBindingPattern */: - case 152 /* ArrayBindingPattern */: + case 153 /* ObjectBindingPattern */: + case 154 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 155 /* ObjectLiteralExpression */: + case 157 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 156 /* PropertyAccessExpression */: + case 158 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 157 /* ElementAccessExpression */: + case 159 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 160 /* TaggedTemplateExpression */: + case 162 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 165 /* DeleteExpression */: + case 167 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 166 /* TypeOfExpression */: + case 168 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 167 /* VoidExpression */: + case 169 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 168 /* PrefixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 173 /* YieldExpression */: + case 175 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 169 /* PostfixUnaryExpression */: + case 171 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 174 /* SpreadElementExpression */: + case 176 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 180 /* Block */: - case 207 /* ModuleBlock */: + case 182 /* Block */: + case 209 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 228 /* SourceFile */: + case 230 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 200 /* VariableDeclarationList */: + case 202 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 183 /* ExpressionStatement */: + case 185 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 184 /* IfStatement */: + case 186 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 185 /* DoStatement */: + case 187 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 186 /* WhileStatement */: + case 188 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 187 /* ForStatement */: + case 189 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 188 /* ForInStatement */: + case 190 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 189 /* ForOfStatement */: + case 191 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 190 /* ContinueStatement */: - case 191 /* BreakStatement */: + case 192 /* ContinueStatement */: + case 193 /* BreakStatement */: return visitNode(cbNode, node.label); - case 192 /* ReturnStatement */: + case 194 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 193 /* WithStatement */: + case 195 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 194 /* SwitchStatement */: + case 196 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 208 /* CaseBlock */: + case 210 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 221 /* CaseClause */: + case 223 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 222 /* DefaultClause */: + case 224 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 196 /* ThrowStatement */: + case 198 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 197 /* TryStatement */: + case 199 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 224 /* CatchClause */: + case 226 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 131 /* Decorator */: + case 132 /* Decorator */: return visitNode(cbNode, node.expression); - case 202 /* ClassDeclaration */: - case 175 /* ClassExpression */: + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 204 /* TypeAliasDeclaration */: + case 206 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 227 /* EnumMember */: + case 229 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 211 /* ImportClause */: + case 213 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 212 /* NamespaceImport */: + case 214 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 213 /* NamedImports */: - case 217 /* NamedExports */: + case 215 /* NamedImports */: + case 219 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 214 /* ImportSpecifier */: - case 218 /* ExportSpecifier */: + case 216 /* ImportSpecifier */: + case 220 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 172 /* TemplateExpression */: + case 174 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 178 /* TemplateSpan */: + case 180 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 223 /* HeritageClause */: + case 225 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 177 /* ExpressionWithTypeArguments */: + case 179 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 220 /* ExternalModuleReference */: + case 222 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 219 /* MissingDeclaration */: + case 221 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 229 /* JSDocTypeExpression */: + case 231 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 233 /* JSDocUnionType */: + case 235 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 234 /* JSDocTupleType */: + case 236 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 232 /* JSDocArrayType */: + case 234 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 236 /* JSDocNonNullableType */: + case 238 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 235 /* JSDocNullableType */: + case 237 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 237 /* JSDocRecordType */: + case 239 /* JSDocRecordType */: return visitNodes(cbNodes, node.members); - case 239 /* JSDocTypeReference */: + case 241 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 240 /* JSDocOptionalType */: + case 242 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 241 /* JSDocFunctionType */: + case 243 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 242 /* JSDocVariadicType */: + case 244 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 243 /* JSDocConstructorType */: + case 245 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 244 /* JSDocThisType */: + case 246 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 238 /* JSDocRecordMember */: + case 240 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 245 /* JSDocComment */: + case 247 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 247 /* JSDocParameterTag */: + case 249 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 248 /* JSDocReturnTag */: + case 250 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 249 /* JSDocTypeTag */: + case 251 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 250 /* JSDocTemplateTag */: + case 252 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); } } @@ -6891,13 +7256,6 @@ var ts; // Note: any errors at the end of the file that do not precede a regular node, should get // attached to the EOF token. var parseErrorBeforeNextFinishedNode = false; - (function (StatementFlags) { - StatementFlags[StatementFlags["None"] = 0] = "None"; - StatementFlags[StatementFlags["Statement"] = 1] = "Statement"; - StatementFlags[StatementFlags["ModuleElement"] = 2] = "ModuleElement"; - StatementFlags[StatementFlags["StatementOrModuleElement"] = 3] = "StatementOrModuleElement"; - })(Parser.StatementFlags || (Parser.StatementFlags = {})); - var StatementFlags = Parser.StatementFlags; function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes) { initializeState(fileName, _sourceText, languageVersion, _syntaxCursor); var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); @@ -6936,7 +7294,7 @@ var ts; // Prime the scanner. token = nextToken(); processReferenceComments(sourceFile); - sourceFile.statements = parseList(0 /* SourceElements */, true, parseSourceElement); + sourceFile.statements = parseList(0 /* SourceElements */, parseStatement); ts.Debug.assert(token === 1 /* EndOfFileToken */); sourceFile.endOfFileToken = parseTokenNode(); setExternalModuleIndicator(sourceFile); @@ -6962,9 +7320,9 @@ var ts; // Add additional cases as necessary depending on how we see JSDoc comments used // in the wild. switch (node.kind) { - case 181 /* VariableStatement */: - case 201 /* FunctionDeclaration */: - case 130 /* Parameter */: + case 183 /* VariableStatement */: + case 203 /* FunctionDeclaration */: + case 131 /* Parameter */: addJSDocComment(node); } forEachChild(node, visit); @@ -7005,7 +7363,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(228 /* SourceFile */, 0); + var sourceFile = createNode(230 /* SourceFile */, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -7023,9 +7381,6 @@ var ts; contextFlags &= ~flag; } } - function setStrictModeContext(val) { - setContextFlag(val, 1 /* StrictMode */); - } function setDisallowInContext(val) { setContextFlag(val, 2 /* DisallowIn */); } @@ -7102,9 +7457,6 @@ var ts; function inYieldContext() { return (contextFlags & 4 /* Yield */) !== 0; } - function inStrictModeContext() { - return (contextFlags & 1 /* StrictMode */) !== 0; - } function inGeneratorParameterContext() { return (contextFlags & 8 /* GeneratorParameter */) !== 0; } @@ -7356,7 +7708,7 @@ var ts; // ComputedPropertyName[Yield] : // [ AssignmentExpression[In, ?Yield] ] // - var node = createNode(128 /* ComputedPropertyName */); + var node = createNode(129 /* ComputedPropertyName */); parseExpected(18 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -7414,37 +7766,34 @@ var ts; } switch (parsingContext) { case 0 /* SourceElements */: - case 1 /* ModuleElements */: + case 1 /* BlockStatements */: + case 3 /* SwitchClauseStatements */: // If we're in error recovery, then we don't want to treat ';' as an empty statement. // The problem is that ';' can show up in far too many contexts, and if we see one // and assume it's a statement, then we may bail out inappropriately from whatever // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token === 22 /* SemicolonToken */ && inErrorRecovery) && isStartOfModuleElement(); - case 2 /* BlockStatements */: - case 4 /* SwitchClauseStatements */: - // During error recovery we don't treat empty statements as statements return !(token === 22 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); - case 3 /* SwitchClauses */: + case 2 /* SwitchClauses */: return token === 67 /* CaseKeyword */ || token === 73 /* DefaultKeyword */; - case 5 /* TypeMembers */: + case 4 /* TypeMembers */: return isStartOfTypeMember(); - case 6 /* ClassMembers */: + case 5 /* ClassMembers */: // We allow semicolons as class elements (as specified by ES6) as long as we're // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. return lookAhead(isClassMemberStart) || (token === 22 /* SemicolonToken */ && !inErrorRecovery); - case 7 /* EnumMembers */: + case 6 /* EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. return token === 18 /* OpenBracketToken */ || isLiteralPropertyName(); - case 13 /* ObjectLiteralMembers */: + case 12 /* ObjectLiteralMembers */: return token === 18 /* OpenBracketToken */ || token === 35 /* AsteriskToken */ || isLiteralPropertyName(); - case 10 /* ObjectBindingElements */: + case 9 /* ObjectBindingElements */: return isLiteralPropertyName(); - case 8 /* HeritageClauseElement */: + case 7 /* HeritageClauseElement */: // If we see { } then only consume it as an expression if it is followed by , or { // That way we won't consume the body of a class in its heritage clause. if (token === 14 /* OpenBraceToken */) { @@ -7459,29 +7808,29 @@ var ts; // element during recovery. return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); } - case 9 /* VariableDeclarations */: + case 8 /* VariableDeclarations */: return isIdentifierOrPattern(); - case 11 /* ArrayBindingElements */: + case 10 /* ArrayBindingElements */: return token === 23 /* CommaToken */ || token === 21 /* DotDotDotToken */ || isIdentifierOrPattern(); - case 16 /* TypeParameters */: + case 15 /* TypeParameters */: return isIdentifier(); - case 12 /* ArgumentExpressions */: - case 14 /* ArrayLiteralMembers */: + case 11 /* ArgumentExpressions */: + case 13 /* ArrayLiteralMembers */: return token === 23 /* CommaToken */ || token === 21 /* DotDotDotToken */ || isStartOfExpression(); - case 15 /* Parameters */: + case 14 /* Parameters */: return isStartOfParameter(); - case 17 /* TypeArguments */: - case 18 /* TupleElementTypes */: + case 16 /* TypeArguments */: + case 17 /* TupleElementTypes */: return token === 23 /* CommaToken */ || isStartOfType(); - case 19 /* HeritageClauses */: + case 18 /* HeritageClauses */: return isHeritageClause(); - case 20 /* ImportOrExportSpecifiers */: + case 19 /* ImportOrExportSpecifiers */: return isIdentifierOrKeyword(); - case 21 /* JSDocFunctionParameters */: - case 22 /* JSDocTypeArguments */: - case 24 /* JSDocTupleTypes */: + case 20 /* JSDocFunctionParameters */: + case 21 /* JSDocTypeArguments */: + case 23 /* JSDocTupleTypes */: return JSDocParser.isJSDocType(); - case 23 /* JSDocRecordMembers */: + case 22 /* JSDocRecordMembers */: return isSimplePropertyName(); } ts.Debug.fail("Non-exhaustive case in 'isListElement'."); @@ -7523,47 +7872,46 @@ var ts; return true; } switch (kind) { - case 1 /* ModuleElements */: - case 2 /* BlockStatements */: - case 3 /* SwitchClauses */: - case 5 /* TypeMembers */: - case 6 /* ClassMembers */: - case 7 /* EnumMembers */: - case 13 /* ObjectLiteralMembers */: - case 10 /* ObjectBindingElements */: - case 20 /* ImportOrExportSpecifiers */: + case 1 /* BlockStatements */: + case 2 /* SwitchClauses */: + case 4 /* TypeMembers */: + case 5 /* ClassMembers */: + case 6 /* EnumMembers */: + case 12 /* ObjectLiteralMembers */: + case 9 /* ObjectBindingElements */: + case 19 /* ImportOrExportSpecifiers */: return token === 15 /* CloseBraceToken */; - case 4 /* SwitchClauseStatements */: + case 3 /* SwitchClauseStatements */: return token === 15 /* CloseBraceToken */ || token === 67 /* CaseKeyword */ || token === 73 /* DefaultKeyword */; - case 8 /* HeritageClauseElement */: + case 7 /* HeritageClauseElement */: return token === 14 /* OpenBraceToken */ || token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */; - case 9 /* VariableDeclarations */: + case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); - case 16 /* TypeParameters */: + case 15 /* TypeParameters */: // Tokens other than '>' are here for better error recovery return token === 25 /* GreaterThanToken */ || token === 16 /* OpenParenToken */ || token === 14 /* OpenBraceToken */ || token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */; - case 12 /* ArgumentExpressions */: + case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token === 17 /* CloseParenToken */ || token === 22 /* SemicolonToken */; - case 14 /* ArrayLiteralMembers */: - case 18 /* TupleElementTypes */: - case 11 /* ArrayBindingElements */: + case 13 /* ArrayLiteralMembers */: + case 17 /* TupleElementTypes */: + case 10 /* ArrayBindingElements */: return token === 19 /* CloseBracketToken */; - case 15 /* Parameters */: + case 14 /* Parameters */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery return token === 17 /* CloseParenToken */ || token === 19 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; - case 17 /* TypeArguments */: + case 16 /* TypeArguments */: // Tokens other than '>' are here for better error recovery return token === 25 /* GreaterThanToken */ || token === 16 /* OpenParenToken */; - case 19 /* HeritageClauses */: + case 18 /* HeritageClauses */: return token === 14 /* OpenBraceToken */ || token === 15 /* CloseBraceToken */; - case 21 /* JSDocFunctionParameters */: + case 20 /* JSDocFunctionParameters */: return token === 17 /* CloseParenToken */ || token === 51 /* ColonToken */ || token === 15 /* CloseBraceToken */; - case 22 /* JSDocTypeArguments */: + case 21 /* JSDocTypeArguments */: return token === 25 /* GreaterThanToken */ || token === 15 /* CloseBraceToken */; - case 24 /* JSDocTupleTypes */: + case 23 /* JSDocTupleTypes */: return token === 19 /* CloseBracketToken */ || token === 15 /* CloseBraceToken */; - case 23 /* JSDocRecordMembers */: + case 22 /* JSDocRecordMembers */: return token === 15 /* CloseBraceToken */; } } @@ -7590,7 +7938,7 @@ var ts; } // True if positioned at element or terminator of the current list or any enclosing list function isInSomeParsingContext() { - for (var kind = 0; kind < 25 /* Count */; kind++) { + for (var kind = 0; kind < 24 /* Count */; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, true) || isListTerminator(kind)) { return true; @@ -7600,47 +7948,25 @@ var ts; return false; } // Parses a list of elements - function parseList(kind, checkForStrictMode, parseElement) { + function parseList(kind, parseElement) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; var result = []; result.pos = getNodePos(); - var savedStrictModeContext = inStrictModeContext(); while (!isListTerminator(kind)) { if (isListElement(kind, false)) { var element = parseListElement(kind, parseElement); result.push(element); - // test elements only if we are not already in strict mode - if (checkForStrictMode && !inStrictModeContext()) { - if (ts.isPrologueDirective(element)) { - if (isUseStrictPrologueDirective(element)) { - setStrictModeContext(true); - checkForStrictMode = false; - } - } - else { - checkForStrictMode = false; - } - } continue; } if (abortParsingListOrMoveToNextToken(kind)) { break; } } - setStrictModeContext(savedStrictModeContext); result.end = getNodeEnd(); parsingContext = saveParsingContext; return result; } - /// Should be called only on prologue directives (isPrologueDirective(node) should be true) - function isUseStrictPrologueDirective(node) { - ts.Debug.assert(ts.isPrologueDirective(node)); - var nodeText = ts.getTextOfNodeFromSourceText(sourceText, node.expression); - // Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the - // string to contain unicode escapes (as per ES5). - return nodeText === '"use strict"' || nodeText === "'use strict'"; - } function parseListElement(parsingContext, parseElement) { var node = currentNode(parsingContext); if (node) { @@ -7688,7 +8014,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.parserContextFlags & 63 /* ParserGeneratedFlags */; + var nodeContextFlags = node.parserContextFlags & 62 /* ParserGeneratedFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -7707,37 +8033,36 @@ var ts; } function canReuseNode(node, parsingContext) { switch (parsingContext) { - case 1 /* ModuleElements */: - return isReusableModuleElement(node); - case 6 /* ClassMembers */: + case 5 /* ClassMembers */: return isReusableClassMember(node); - case 3 /* SwitchClauses */: + case 2 /* SwitchClauses */: return isReusableSwitchClause(node); - case 2 /* BlockStatements */: - case 4 /* SwitchClauseStatements */: + case 0 /* SourceElements */: + case 1 /* BlockStatements */: + case 3 /* SwitchClauseStatements */: return isReusableStatement(node); - case 7 /* EnumMembers */: + case 6 /* EnumMembers */: return isReusableEnumMember(node); - case 5 /* TypeMembers */: + case 4 /* TypeMembers */: return isReusableTypeMember(node); - case 9 /* VariableDeclarations */: + case 8 /* VariableDeclarations */: return isReusableVariableDeclaration(node); - case 15 /* Parameters */: + case 14 /* Parameters */: return isReusableParameter(node); // Any other lists we do not care about reusing nodes in. But feel free to add if // you can do so safely. Danger areas involve nodes that may involve speculative // parsing. If speculative parsing is involved with the node, then the range the // parser reached while looking ahead might be in the edited range (see the example // in canReuseVariableDeclaratorNode for a good case of this). - case 19 /* HeritageClauses */: + case 18 /* HeritageClauses */: // This would probably be safe to reuse. There is no speculative parsing with // heritage clauses. - case 16 /* TypeParameters */: + case 15 /* TypeParameters */: // This would probably be safe to reuse. There is no speculative parsing with // type parameters. Note that that's because type *parameters* only occur in // unambiguous *type* contexts. While type *arguments* occur in very ambiguous // *expression* contexts. - case 18 /* TupleElementTypes */: + case 17 /* TupleElementTypes */: // This would probably be safe to reuse. There is no speculative parsing with // tuple types. // Technically, type argument list types are probably safe to reuse. While @@ -7745,51 +8070,41 @@ var ts; // produced from speculative parsing a < as a type argument list), we only have // the types because speculative parsing succeeded. Thus, the lookahead never // went past the end of the list and rewound. - case 17 /* TypeArguments */: + case 16 /* TypeArguments */: // Note: these are almost certainly not safe to ever reuse. Expressions commonly // need a large amount of lookahead, and we should not reuse them as they may // have actually intersected the edit. - case 12 /* ArgumentExpressions */: + case 11 /* ArgumentExpressions */: // This is not safe to reuse for the same reason as the 'AssignmentExpression' // cases. i.e. a property assignment may end with an expression, and thus might // have lookahead far beyond it's old node. - case 13 /* ObjectLiteralMembers */: + case 12 /* ObjectLiteralMembers */: // This is probably not safe to reuse. There can be speculative parsing with // type names in a heritage clause. There can be generic names in the type // name list, and there can be left hand side expressions (which can have type // arguments.) - case 8 /* HeritageClauseElement */: - } - return false; - } - function isReusableModuleElement(node) { - if (node) { - switch (node.kind) { - case 210 /* ImportDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 216 /* ExportDeclaration */: - case 215 /* ExportAssignment */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 206 /* ModuleDeclaration */: - case 205 /* EnumDeclaration */: - return true; - } - return isReusableStatement(node); + case 7 /* HeritageClauseElement */: } return false; } function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 136 /* Constructor */: - case 141 /* IndexSignature */: - case 135 /* MethodDeclaration */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 133 /* PropertyDeclaration */: - case 179 /* SemicolonClassElement */: + case 137 /* Constructor */: + case 142 /* IndexSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 134 /* PropertyDeclaration */: + case 181 /* SemicolonClassElement */: return true; + case 136 /* MethodDeclaration */: + // Method declarations are not necessarily reusable. An object-literal + // may have a method calls "constructor(...)" and we must reparse that + // into an actual .ConstructorDeclaration. + var methodDeclaration = node; + var nameIsConstructor = methodDeclaration.name.kind === 65 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 114 /* ConstructorKeyword */; + return !nameIsConstructor; } } return false; @@ -7797,8 +8112,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 221 /* CaseClause */: - case 222 /* DefaultClause */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: return true; } } @@ -7807,49 +8122,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 201 /* FunctionDeclaration */: - case 181 /* VariableStatement */: - case 180 /* Block */: - case 184 /* IfStatement */: - case 183 /* ExpressionStatement */: - case 196 /* ThrowStatement */: - case 192 /* ReturnStatement */: - case 194 /* SwitchStatement */: - case 191 /* BreakStatement */: - case 190 /* ContinueStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 187 /* ForStatement */: - case 186 /* WhileStatement */: - case 193 /* WithStatement */: - case 182 /* EmptyStatement */: - case 197 /* TryStatement */: - case 195 /* LabeledStatement */: - case 185 /* DoStatement */: - case 198 /* DebuggerStatement */: + case 203 /* FunctionDeclaration */: + case 183 /* VariableStatement */: + case 182 /* Block */: + case 186 /* IfStatement */: + case 185 /* ExpressionStatement */: + case 198 /* ThrowStatement */: + case 194 /* ReturnStatement */: + case 196 /* SwitchStatement */: + case 193 /* BreakStatement */: + case 192 /* ContinueStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 189 /* ForStatement */: + case 188 /* WhileStatement */: + case 195 /* WithStatement */: + case 184 /* EmptyStatement */: + case 199 /* TryStatement */: + case 197 /* LabeledStatement */: + case 187 /* DoStatement */: + case 200 /* DebuggerStatement */: + case 212 /* ImportDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 218 /* ExportDeclaration */: + case 217 /* ExportAssignment */: + case 208 /* ModuleDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 206 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 227 /* EnumMember */; + return node.kind === 229 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 140 /* ConstructSignature */: - case 134 /* MethodSignature */: - case 141 /* IndexSignature */: - case 132 /* PropertySignature */: - case 139 /* CallSignature */: + case 141 /* ConstructSignature */: + case 135 /* MethodSignature */: + case 142 /* IndexSignature */: + case 133 /* PropertySignature */: + case 140 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 199 /* VariableDeclaration */) { + if (node.kind !== 201 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -7870,7 +8194,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 130 /* Parameter */) { + if (node.kind !== 131 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -7889,30 +8213,29 @@ var ts; function parsingContextErrors(context) { switch (context) { case 0 /* SourceElements */: return ts.Diagnostics.Declaration_or_statement_expected; - case 1 /* ModuleElements */: return ts.Diagnostics.Declaration_or_statement_expected; - case 2 /* BlockStatements */: return ts.Diagnostics.Statement_expected; - case 3 /* SwitchClauses */: return ts.Diagnostics.case_or_default_expected; - case 4 /* SwitchClauseStatements */: return ts.Diagnostics.Statement_expected; - case 5 /* TypeMembers */: return ts.Diagnostics.Property_or_signature_expected; - case 6 /* ClassMembers */: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; - case 7 /* EnumMembers */: return ts.Diagnostics.Enum_member_expected; - case 8 /* HeritageClauseElement */: return ts.Diagnostics.Expression_expected; - case 9 /* VariableDeclarations */: return ts.Diagnostics.Variable_declaration_expected; - case 10 /* ObjectBindingElements */: return ts.Diagnostics.Property_destructuring_pattern_expected; - case 11 /* ArrayBindingElements */: return ts.Diagnostics.Array_element_destructuring_pattern_expected; - case 12 /* ArgumentExpressions */: return ts.Diagnostics.Argument_expression_expected; - case 13 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected; - case 14 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; - case 15 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; - case 16 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; - case 17 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; - case 18 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; - case 19 /* HeritageClauses */: return ts.Diagnostics.Unexpected_token_expected; - case 20 /* ImportOrExportSpecifiers */: return ts.Diagnostics.Identifier_expected; - case 21 /* JSDocFunctionParameters */: return ts.Diagnostics.Parameter_declaration_expected; - case 22 /* JSDocTypeArguments */: return ts.Diagnostics.Type_argument_expected; - case 24 /* JSDocTupleTypes */: return ts.Diagnostics.Type_expected; - case 23 /* JSDocRecordMembers */: return ts.Diagnostics.Property_assignment_expected; + case 1 /* BlockStatements */: return ts.Diagnostics.Declaration_or_statement_expected; + case 2 /* SwitchClauses */: return ts.Diagnostics.case_or_default_expected; + case 3 /* SwitchClauseStatements */: return ts.Diagnostics.Statement_expected; + case 4 /* TypeMembers */: return ts.Diagnostics.Property_or_signature_expected; + case 5 /* ClassMembers */: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; + case 6 /* EnumMembers */: return ts.Diagnostics.Enum_member_expected; + case 7 /* HeritageClauseElement */: return ts.Diagnostics.Expression_expected; + case 8 /* VariableDeclarations */: return ts.Diagnostics.Variable_declaration_expected; + case 9 /* ObjectBindingElements */: return ts.Diagnostics.Property_destructuring_pattern_expected; + case 10 /* ArrayBindingElements */: return ts.Diagnostics.Array_element_destructuring_pattern_expected; + case 11 /* ArgumentExpressions */: return ts.Diagnostics.Argument_expression_expected; + case 12 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected; + case 13 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; + case 14 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; + case 15 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; + case 16 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; + case 17 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; + case 18 /* HeritageClauses */: return ts.Diagnostics.Unexpected_token_expected; + case 19 /* ImportOrExportSpecifiers */: return ts.Diagnostics.Identifier_expected; + case 20 /* JSDocFunctionParameters */: return ts.Diagnostics.Parameter_declaration_expected; + case 21 /* JSDocTypeArguments */: return ts.Diagnostics.Type_argument_expected; + case 23 /* JSDocTupleTypes */: return ts.Diagnostics.Type_expected; + case 22 /* JSDocRecordMembers */: return ts.Diagnostics.Property_assignment_expected; } } ; @@ -7986,7 +8309,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(20 /* DotToken */)) { - var node = createNode(127 /* QualifiedName */, entity.pos); + var node = createNode(128 /* QualifiedName */, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -7994,38 +8317,38 @@ var ts; return entity; } function parseRightSideOfDot(allowIdentifierNames) { - // Technically a keyword is valid here as all keywords are identifier names. - // However, often we'll encounter this in error situations when the keyword + // Technically a keyword is valid here as all identifiers and keywords are identifier names. + // However, often we'll encounter this in error situations when the identifier or keyword // is actually starting another valid construct. // // So, we check for the following specific case: // // name. - // keyword identifierNameOrKeyword + // identifierOrKeyword identifierNameOrKeyword // // Note: the newlines are important here. For example, if that above code // were rewritten into: // - // name.keyword + // name.identifierOrKeyword // identifierNameOrKeyword // // Then we would consider it valid. That's because ASI would take effect and - // the code would be implicitly: "name.keyword; identifierNameOrKeyword". + // the code would be implicitly: "name.identifierOrKeyword; identifierNameOrKeyword". // In the first case though, ASI will not take effect because there is not a - // line terminator after the keyword. - if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord()) { + // line terminator after the identifier or keyword. + if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually - // be an identifier and the error woudl be quite confusing. + // be an identifier and the error would be quite confusing. return createMissingNode(65 /* Identifier */, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(172 /* TemplateExpression */); + var template = createNode(174 /* TemplateExpression */); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 11 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; @@ -8038,7 +8361,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(178 /* TemplateSpan */); + var span = createNode(180 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token === 15 /* CloseBraceToken */) { @@ -8078,22 +8401,30 @@ var ts; return node; } // TYPES - function parseTypeReference() { - var node = createNode(142 /* TypeReference */); - node.typeName = parseEntityName(false, ts.Diagnostics.Type_expected); + function parseTypeReferenceOrTypePredicate() { + var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); + if (typeName.kind === 65 /* Identifier */ && token === 117 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + nextToken(); + var node_1 = createNode(143 /* TypePredicate */, typeName.pos); + node_1.parameterName = typeName; + node_1.type = parseType(); + return finishNode(node_1); + } + var node = createNode(144 /* TypeReference */, typeName.pos); + node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 24 /* LessThanToken */) { - node.typeArguments = parseBracketedList(17 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); + node.typeArguments = parseBracketedList(16 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(145 /* TypeQuery */); + var node = createNode(147 /* TypeQuery */); parseExpected(97 /* TypeOfKeyword */); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(129 /* TypeParameter */); + var node = createNode(130 /* TypeParameter */); node.name = parseIdentifier(); if (parseOptional(79 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the @@ -8118,7 +8449,7 @@ var ts; } function parseTypeParameters() { if (token === 24 /* LessThanToken */) { - return parseBracketedList(16 /* TypeParameters */, parseTypeParameter, 24 /* LessThanToken */, 25 /* GreaterThanToken */); + return parseBracketedList(15 /* TypeParameters */, parseTypeParameter, 24 /* LessThanToken */, 25 /* GreaterThanToken */); } } function parseParameterType() { @@ -8139,7 +8470,7 @@ var ts; } } function parseParameter() { - var node = createNode(130 /* Parameter */); + var node = createNode(131 /* Parameter */); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); @@ -8210,7 +8541,7 @@ var ts; var savedGeneratorParameterContext = inGeneratorParameterContext(); setYieldContext(yieldAndGeneratorParameterContext); setGeneratorParameterContext(yieldAndGeneratorParameterContext); - var result = parseDelimitedList(15 /* Parameters */, parseParameter); + var result = parseDelimitedList(14 /* Parameters */, parseParameter); setYieldContext(savedYieldContext); setGeneratorParameterContext(savedGeneratorParameterContext); if (!parseExpected(17 /* CloseParenToken */) && requireCompleteParameterList) { @@ -8236,7 +8567,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 140 /* ConstructSignature */) { + if (kind === 141 /* ConstructSignature */) { parseExpected(88 /* NewKeyword */); } fillSignature(51 /* ColonToken */, false, false, node); @@ -8300,10 +8631,10 @@ var ts; return token === 51 /* ColonToken */ || token === 23 /* CommaToken */ || token === 19 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(141 /* IndexSignature */, fullStart); + var node = createNode(142 /* IndexSignature */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.parameters = parseBracketedList(15 /* Parameters */, parseParameter, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); + node.parameters = parseBracketedList(14 /* Parameters */, parseParameter, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); @@ -8313,7 +8644,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(50 /* QuestionToken */); if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { - var method = createNode(134 /* MethodSignature */, fullStart); + var method = createNode(135 /* MethodSignature */, fullStart); method.name = name; method.questionToken = questionToken; // Method signatues don't exist in expression contexts. So they have neither @@ -8323,7 +8654,7 @@ var ts; return finishNode(method); } else { - var property = createNode(132 /* PropertySignature */, fullStart); + var property = createNode(133 /* PropertySignature */, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -8365,7 +8696,7 @@ var ts; switch (token) { case 16 /* OpenParenToken */: case 24 /* LessThanToken */: - return parseSignatureMember(139 /* CallSignature */); + return parseSignatureMember(140 /* CallSignature */); case 18 /* OpenBracketToken */: // Indexer or computed property return isIndexSignature() @@ -8373,7 +8704,7 @@ var ts; : parsePropertyOrMethodSignature(); case 88 /* NewKeyword */: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(140 /* ConstructSignature */); + return parseSignatureMember(141 /* ConstructSignature */); } // fall through. case 8 /* StringLiteral */: @@ -8410,14 +8741,14 @@ var ts; return token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(146 /* TypeLiteral */); + var node = createNode(148 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; if (parseExpected(14 /* OpenBraceToken */)) { - members = parseList(5 /* TypeMembers */, false, parseTypeMember); + members = parseList(4 /* TypeMembers */, parseTypeMember); parseExpected(15 /* CloseBraceToken */); } else { @@ -8426,12 +8757,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(148 /* TupleType */); - node.elementTypes = parseBracketedList(18 /* TupleElementTypes */, parseType, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); + var node = createNode(150 /* TupleType */); + node.elementTypes = parseBracketedList(17 /* TupleElementTypes */, parseType, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(150 /* ParenthesizedType */); + var node = createNode(152 /* ParenthesizedType */); parseExpected(16 /* OpenParenToken */); node.type = parseType(); parseExpected(17 /* CloseParenToken */); @@ -8439,7 +8770,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 144 /* ConstructorType */) { + if (kind === 146 /* ConstructorType */) { parseExpected(88 /* NewKeyword */); } fillSignature(32 /* EqualsGreaterThanToken */, false, false, node); @@ -8452,13 +8783,13 @@ var ts; function parseNonArrayType() { switch (token) { case 112 /* AnyKeyword */: - case 122 /* StringKeyword */: - case 120 /* NumberKeyword */: + case 123 /* StringKeyword */: + case 121 /* NumberKeyword */: case 113 /* BooleanKeyword */: - case 123 /* SymbolKeyword */: + case 124 /* SymbolKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); - return node || parseTypeReference(); + return node || parseTypeReferenceOrTypePredicate(); case 99 /* VoidKeyword */: return parseTokenNode(); case 97 /* TypeOfKeyword */: @@ -8470,16 +8801,16 @@ var ts; case 16 /* OpenParenToken */: return parseParenthesizedType(); default: - return parseTypeReference(); + return parseTypeReferenceOrTypePredicate(); } } function isStartOfType() { switch (token) { case 112 /* AnyKeyword */: - case 122 /* StringKeyword */: - case 120 /* NumberKeyword */: + case 123 /* StringKeyword */: + case 121 /* NumberKeyword */: case 113 /* BooleanKeyword */: - case 123 /* SymbolKeyword */: + case 124 /* SymbolKeyword */: case 99 /* VoidKeyword */: case 97 /* TypeOfKeyword */: case 14 /* OpenBraceToken */: @@ -8503,7 +8834,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(18 /* OpenBracketToken */)) { parseExpected(19 /* CloseBracketToken */); - var node = createNode(147 /* ArrayType */, type.pos); + var node = createNode(149 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -8518,7 +8849,7 @@ var ts; types.push(parseArrayTypeOrHigher()); } types.end = getNodeEnd(); - var node = createNode(149 /* UnionType */, type.pos); + var node = createNode(151 /* UnionType */, type.pos); node.types = types; type = finishNode(node); } @@ -8573,10 +8904,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(143 /* FunctionType */); + return parseFunctionOrConstructorType(145 /* FunctionType */); } if (token === 88 /* NewKeyword */) { - return parseFunctionOrConstructorType(144 /* ConstructorType */); + return parseFunctionOrConstructorType(146 /* ConstructorType */); } return parseUnionTypeOrHigher(); } @@ -8745,11 +9076,6 @@ var ts; if (inYieldContext()) { return true; } - if (inStrictModeContext()) { - // If we're in strict mode, then 'yield' is a keyword, could only ever start - // a yield expression. - return true; - } // We're in a context where 'yield expr' is not allowed. However, if we can // definitely tell that the user was trying to parse a 'yield expr' and not // just a normal expr that start with a 'yield' identifier, then parse out @@ -8764,7 +9090,7 @@ var ts; // for now we just check if the next token is an identifier. More heuristics // can be added here later as necessary. We just need to make sure that we // don't accidently consume something legal. - return lookAhead(nextTokenIsIdentifierOnSameLine); + return lookAhead(nextTokenIsIdentifierOrKeywordOrNumberOnSameLine); } return false; } @@ -8773,7 +9099,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(173 /* YieldExpression */); + var node = createNode(175 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -8793,8 +9119,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 32 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(164 /* ArrowFunction */, identifier.pos); - var parameter = createNode(130 /* Parameter */, identifier.pos); + var node = createNode(166 /* ArrowFunction */, identifier.pos); + var parameter = createNode(131 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -8912,7 +9238,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(164 /* ArrowFunction */); + var node = createNode(166 /* ArrowFunction */); // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -8974,7 +9300,7 @@ var ts; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(171 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(173 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -8987,7 +9313,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 86 /* InKeyword */ || t === 126 /* OfKeyword */; + return t === 86 /* InKeyword */ || t === 127 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -9053,33 +9379,33 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(170 /* BinaryExpression */, left.pos); + var node = createNode(172 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(168 /* PrefixUnaryExpression */); + var node = createNode(170 /* PrefixUnaryExpression */); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(165 /* DeleteExpression */); + var node = createNode(167 /* DeleteExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(166 /* TypeOfExpression */); + var node = createNode(168 /* TypeOfExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(167 /* VoidExpression */); + var node = createNode(169 /* VoidExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -9109,7 +9435,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token === 38 /* PlusPlusToken */ || token === 39 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(169 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(171 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -9213,14 +9539,14 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(156 /* PropertyAccessExpression */, expression.pos); + var node = createNode(158 /* PropertyAccessExpression */, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(20 /* DotToken */, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } function parseTypeAssertion() { - var node = createNode(161 /* TypeAssertionExpression */); + var node = createNode(163 /* TypeAssertionExpression */); parseExpected(24 /* LessThanToken */); node.type = parseType(); parseExpected(25 /* GreaterThanToken */); @@ -9231,7 +9557,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(20 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(156 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(158 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); @@ -9240,7 +9566,7 @@ var ts; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(18 /* OpenBracketToken */)) { - var indexedAccess = createNode(157 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(159 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; // It's not uncommon for a user to write: "new Type[]". // Check for that common pattern and report a better error message. @@ -9256,7 +9582,7 @@ var ts; continue; } if (token === 10 /* NoSubstitutionTemplateLiteral */ || token === 11 /* TemplateHead */) { - var tagExpression = createNode(160 /* TaggedTemplateExpression */, expression.pos); + var tagExpression = createNode(162 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 10 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() @@ -9279,7 +9605,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(158 /* CallExpression */, expression.pos); + var callExpr = createNode(160 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -9287,7 +9613,7 @@ var ts; continue; } else if (token === 16 /* OpenParenToken */) { - var callExpr = createNode(158 /* CallExpression */, expression.pos); + var callExpr = createNode(160 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -9298,7 +9624,7 @@ var ts; } function parseArgumentList() { parseExpected(16 /* OpenParenToken */); - var result = parseDelimitedList(12 /* ArgumentExpressions */, parseArgumentExpression); + var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); parseExpected(17 /* CloseParenToken */); return result; } @@ -9306,7 +9632,7 @@ var ts; if (!parseOptional(24 /* LessThanToken */)) { return undefined; } - var typeArguments = parseDelimitedList(17 /* TypeArguments */, parseType); + var typeArguments = parseDelimitedList(16 /* TypeArguments */, parseType); if (!parseExpected(25 /* GreaterThanToken */)) { // If it doesn't have the closing > then it's definitely not an type argument list. return undefined; @@ -9389,41 +9715,41 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(162 /* ParenthesizedExpression */); + var node = createNode(164 /* ParenthesizedExpression */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(174 /* SpreadElementExpression */); + var node = createNode(176 /* SpreadElementExpression */); parseExpected(21 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 21 /* DotDotDotToken */ ? parseSpreadElement() : - token === 23 /* CommaToken */ ? createNode(176 /* OmittedExpression */) : + token === 23 /* CommaToken */ ? createNode(178 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(154 /* ArrayLiteralExpression */); + var node = createNode(156 /* ArrayLiteralExpression */); parseExpected(18 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 512 /* MultiLine */; - node.elements = parseDelimitedList(14 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); + node.elements = parseDelimitedList(13 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); parseExpected(19 /* CloseBracketToken */); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(116 /* GetKeyword */)) { - return parseAccessorDeclaration(137 /* GetAccessor */, fullStart, decorators, modifiers); + return parseAccessorDeclaration(138 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(121 /* SetKeyword */)) { - return parseAccessorDeclaration(138 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(122 /* SetKeyword */)) { + return parseAccessorDeclaration(139 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -9446,13 +9772,13 @@ var ts; } // Parse to check if it is short-hand property assignment or normal property assignment if ((token === 23 /* CommaToken */ || token === 15 /* CloseBraceToken */) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(226 /* ShorthandPropertyAssignment */, fullStart); + var shorthandDeclaration = createNode(228 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(225 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(227 /* PropertyAssignment */, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; parseExpected(51 /* ColonToken */); @@ -9461,12 +9787,12 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(155 /* ObjectLiteralExpression */); + var node = createNode(157 /* ObjectLiteralExpression */); parseExpected(14 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.flags |= 512 /* MultiLine */; } - node.properties = parseDelimitedList(13 /* ObjectLiteralMembers */, parseObjectLiteralElement, true); + node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, true); parseExpected(15 /* CloseBraceToken */); return finishNode(node); } @@ -9479,7 +9805,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(163 /* FunctionExpression */); + var node = createNode(165 /* FunctionExpression */); parseExpected(83 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(35 /* AsteriskToken */); node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); @@ -9494,7 +9820,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(159 /* NewExpression */); + var node = createNode(161 /* NewExpression */); parseExpected(88 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -9504,10 +9830,10 @@ var ts; return finishNode(node); } // STATEMENTS - function parseBlock(ignoreMissingOpenBrace, checkForStrictMode, diagnosticMessage) { - var node = createNode(180 /* Block */); + function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { + var node = createNode(182 /* Block */); if (parseExpected(14 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { - node.statements = parseList(2 /* BlockStatements */, checkForStrictMode, parseStatement); + node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(15 /* CloseBraceToken */); } else { @@ -9524,7 +9850,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var block = parseBlock(ignoreMissingOpenBrace, true, diagnosticMessage); + var block = parseBlock(ignoreMissingOpenBrace, diagnosticMessage); if (saveDecoratorContext) { setDecoratorContext(true); } @@ -9532,12 +9858,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(182 /* EmptyStatement */); + var node = createNode(184 /* EmptyStatement */); parseExpected(22 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(184 /* IfStatement */); + var node = createNode(186 /* IfStatement */); parseExpected(84 /* IfKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -9547,7 +9873,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(185 /* DoStatement */); + var node = createNode(187 /* DoStatement */); parseExpected(75 /* DoKeyword */); node.statement = parseStatement(); parseExpected(100 /* WhileKeyword */); @@ -9562,7 +9888,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(186 /* WhileStatement */); + var node = createNode(188 /* WhileStatement */); parseExpected(100 /* WhileKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -9585,21 +9911,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(86 /* InKeyword */)) { - var forInStatement = createNode(188 /* ForInStatement */, pos); + var forInStatement = createNode(190 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(126 /* OfKeyword */)) { - var forOfStatement = createNode(189 /* ForOfStatement */, pos); + else if (parseOptional(127 /* OfKeyword */)) { + var forOfStatement = createNode(191 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(17 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(187 /* ForStatement */, pos); + var forStatement = createNode(189 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(22 /* SemicolonToken */); if (token !== 22 /* SemicolonToken */ && token !== 17 /* CloseParenToken */) { @@ -9617,7 +9943,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 191 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */); + parseExpected(kind === 193 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -9625,7 +9951,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(192 /* ReturnStatement */); + var node = createNode(194 /* ReturnStatement */); parseExpected(90 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -9634,7 +9960,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(193 /* WithStatement */); + var node = createNode(195 /* WithStatement */); parseExpected(101 /* WithKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -9643,32 +9969,32 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(221 /* CaseClause */); + var node = createNode(223 /* CaseClause */); parseExpected(67 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(51 /* ColonToken */); - node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatement); + node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(222 /* DefaultClause */); + var node = createNode(224 /* DefaultClause */); parseExpected(73 /* DefaultKeyword */); parseExpected(51 /* ColonToken */); - node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatement); + node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { return token === 67 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(194 /* SwitchStatement */); + var node = createNode(196 /* SwitchStatement */); parseExpected(92 /* SwitchKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); - var caseBlock = createNode(208 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(210 /* CaseBlock */, scanner.getStartPos()); parseExpected(14 /* OpenBraceToken */); - caseBlock.clauses = parseList(3 /* SwitchClauses */, false, parseCaseOrDefaultClause); + caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(15 /* CloseBraceToken */); node.caseBlock = finishNode(caseBlock); return finishNode(node); @@ -9681,7 +10007,7 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(196 /* ThrowStatement */); + var node = createNode(198 /* ThrowStatement */); parseExpected(94 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -9689,30 +10015,30 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(197 /* TryStatement */); + var node = createNode(199 /* TryStatement */); parseExpected(96 /* TryKeyword */); - node.tryBlock = parseBlock(false, false); + node.tryBlock = parseBlock(false); node.catchClause = token === 68 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. if (!node.catchClause || token === 81 /* FinallyKeyword */) { parseExpected(81 /* FinallyKeyword */); - node.finallyBlock = parseBlock(false, false); + node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(224 /* CatchClause */); + var result = createNode(226 /* CatchClause */); parseExpected(68 /* CatchKeyword */); if (parseExpected(16 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); } parseExpected(17 /* CloseParenToken */); - result.block = parseBlock(false, false); + result.block = parseBlock(false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(198 /* DebuggerStatement */); + var node = createNode(200 /* DebuggerStatement */); parseExpected(72 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -9724,13 +10050,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 65 /* Identifier */ && parseOptional(51 /* ColonToken */)) { - var labeledStatement = createNode(195 /* LabeledStatement */, fullStart); + var labeledStatement = createNode(197 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(183 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(185 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -9743,7 +10069,11 @@ var ts; nextToken(); return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); } - function parseDeclarationFlags() { + function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { + nextToken(); + return (isIdentifierOrKeyword() || token === 7 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak(); + } + function isDeclaration() { while (true) { switch (token) { case 98 /* VarKeyword */: @@ -9752,28 +10082,52 @@ var ts; case 83 /* FunctionKeyword */: case 69 /* ClassKeyword */: case 77 /* EnumKeyword */: - return 1 /* Statement */; + return true; + // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; + // however, an identifier cannot be followed by another identifier on the same line. This is what we + // count on to parse out the respective declarations. For instance, we exploit this to say that + // + // namespace n + // + // can be none other than the beginning of a namespace declaration, but need to respect that JavaScript sees + // + // namespace + // n + // + // as the identifier 'namespace' on one line followed by the identifier 'n' on another. + // We need to look one token ahead to see if it permissible to try parsing a declaration. + // + // *Note*: 'interface' is actually a strict mode reserved word. So while + // + // "use strict" + // interface + // I {} + // + // could be legal, it would add complexity for very little gain. case 103 /* InterfaceKeyword */: - case 124 /* TypeKeyword */: + case 125 /* TypeKeyword */: + return nextTokenIsIdentifierOnSameLine(); + case 118 /* ModuleKeyword */: + case 119 /* NamespaceKeyword */: + return nextTokenIsIdentifierOrStringLiteralOnSameLine(); + case 115 /* DeclareKeyword */: nextToken(); - return isIdentifierOrKeyword() ? 1 /* Statement */ : 0 /* None */; - case 117 /* ModuleKeyword */: - case 118 /* NamespaceKeyword */: - nextToken(); - return isIdentifierOrKeyword() || token === 8 /* StringLiteral */ ? 2 /* ModuleElement */ : 0 /* None */; + // ASI takes effect for this modifier. + if (scanner.hasPrecedingLineBreak()) { + return false; + } + continue; case 85 /* ImportKeyword */: nextToken(); return token === 8 /* StringLiteral */ || token === 35 /* AsteriskToken */ || - token === 14 /* OpenBraceToken */ || isIdentifierOrKeyword() ? - 2 /* ModuleElement */ : 0 /* None */; + token === 14 /* OpenBraceToken */ || isIdentifierOrKeyword(); case 78 /* ExportKeyword */: nextToken(); if (token === 53 /* EqualsToken */ || token === 35 /* AsteriskToken */ || token === 14 /* OpenBraceToken */ || token === 73 /* DefaultKeyword */) { - return 2 /* ModuleElement */; + return true; } continue; - case 115 /* DeclareKeyword */: case 108 /* PublicKeyword */: case 106 /* PrivateKeyword */: case 107 /* ProtectedKeyword */: @@ -9781,14 +10135,14 @@ var ts; nextToken(); continue; default: - return 0 /* None */; + return false; } } } - function getDeclarationFlags() { - return lookAhead(parseDeclarationFlags); + function isStartOfDeclaration() { + return lookAhead(isDeclaration); } - function getStatementFlags() { + function isStartOfStatement() { switch (token) { case 52 /* AtToken */: case 22 /* SemicolonToken */: @@ -9814,61 +10168,44 @@ var ts; // however, we say they are here so that we may gracefully parse them and error later. case 68 /* CatchKeyword */: case 81 /* FinallyKeyword */: - return 1 /* Statement */; + return true; case 70 /* ConstKeyword */: case 78 /* ExportKeyword */: case 85 /* ImportKeyword */: - return getDeclarationFlags(); + return isStartOfDeclaration(); case 115 /* DeclareKeyword */: case 103 /* InterfaceKeyword */: - case 117 /* ModuleKeyword */: - case 118 /* NamespaceKeyword */: - case 124 /* TypeKeyword */: + case 118 /* ModuleKeyword */: + case 119 /* NamespaceKeyword */: + case 125 /* TypeKeyword */: // When these don't start a declaration, they're an identifier in an expression statement - return getDeclarationFlags() || 1 /* Statement */; + return true; case 108 /* PublicKeyword */: case 106 /* PrivateKeyword */: case 107 /* ProtectedKeyword */: case 109 /* StaticKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. - return getDeclarationFlags() || - (lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? 0 /* None */ : 1 /* Statement */); + return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: - return isStartOfExpression() ? 1 /* Statement */ : 0 /* None */; + return isStartOfExpression(); } } - function isStartOfStatement() { - return (getStatementFlags() & 1 /* Statement */) !== 0; - } - function isStartOfModuleElement() { - return (getStatementFlags() & 3 /* StatementOrModuleElement */) !== 0; - } - function nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine() { + function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return !scanner.hasPrecedingLineBreak() && - (isIdentifier() || token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */); + return isIdentifier() || token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */; } function isLetDeclaration() { - // It is let declaration if in strict mode or next token is identifier\open bracket\open curly on same line. - // otherwise it needs to be treated like identifier - return inStrictModeContext() || lookAhead(nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine); + // In ES6 'let' always starts a lexical declaration if followed by an identifier or { + // or [. + return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } function parseStatement() { - return parseModuleElementOfKind(1 /* Statement */); - } - function parseModuleElement() { - return parseModuleElementOfKind(3 /* StatementOrModuleElement */); - } - function parseSourceElement() { - return parseModuleElementOfKind(3 /* StatementOrModuleElement */); - } - function parseModuleElementOfKind(flags) { switch (token) { case 22 /* SemicolonToken */: return parseEmptyStatement(); case 14 /* OpenBraceToken */: - return parseBlock(false, false); + return parseBlock(false); case 98 /* VarKeyword */: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); case 104 /* LetKeyword */: @@ -9889,9 +10226,9 @@ var ts; case 82 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 71 /* ContinueKeyword */: - return parseBreakOrContinueStatement(190 /* ContinueStatement */); + return parseBreakOrContinueStatement(192 /* ContinueStatement */); case 66 /* BreakKeyword */: - return parseBreakOrContinueStatement(191 /* BreakStatement */); + return parseBreakOrContinueStatement(193 /* BreakStatement */); case 90 /* ReturnKeyword */: return parseReturnStatement(); case 101 /* WithKeyword */: @@ -9901,7 +10238,7 @@ var ts; case 94 /* ThrowKeyword */: return parseThrowStatement(); case 96 /* TryKeyword */: - // Include the next two for error recovery. + // Include 'catch' and 'finally' for error recovery. case 68 /* CatchKeyword */: case 81 /* FinallyKeyword */: return parseTryStatement(); @@ -9909,20 +10246,20 @@ var ts; return parseDebuggerStatement(); case 52 /* AtToken */: return parseDeclaration(); - case 70 /* ConstKeyword */: + case 103 /* InterfaceKeyword */: + case 125 /* TypeKeyword */: + case 118 /* ModuleKeyword */: + case 119 /* NamespaceKeyword */: case 115 /* DeclareKeyword */: + case 70 /* ConstKeyword */: case 77 /* EnumKeyword */: case 78 /* ExportKeyword */: case 85 /* ImportKeyword */: - case 103 /* InterfaceKeyword */: - case 117 /* ModuleKeyword */: - case 118 /* NamespaceKeyword */: case 106 /* PrivateKeyword */: case 107 /* ProtectedKeyword */: case 108 /* PublicKeyword */: case 109 /* StaticKeyword */: - case 124 /* TypeKeyword */: - if (getDeclarationFlags() & flags) { + if (isStartOfDeclaration()) { return parseDeclaration(); } break; @@ -9944,12 +10281,12 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 103 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 124 /* TypeKeyword */: + case 125 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 77 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 117 /* ModuleKeyword */: - case 118 /* NamespaceKeyword */: + case 118 /* ModuleKeyword */: + case 119 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); case 85 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); @@ -9959,10 +10296,10 @@ var ts; parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: - if (decorators) { + if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(219 /* MissingDeclaration */, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(221 /* MissingDeclaration */, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -9970,6 +10307,10 @@ var ts; } } } + function nextTokenIsIdentifierOrStringLiteralOnSameLine() { + nextToken(); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 8 /* StringLiteral */); + } function parseFunctionBlockOrSemicolon(isGenerator, diagnosticMessage) { if (token !== 14 /* OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); @@ -9980,16 +10321,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token === 23 /* CommaToken */) { - return createNode(176 /* OmittedExpression */); + return createNode(178 /* OmittedExpression */); } - var node = createNode(153 /* BindingElement */); + var node = createNode(155 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(153 /* BindingElement */); + var node = createNode(155 /* BindingElement */); // TODO(andersh): Handle computed properties var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -10005,16 +10346,16 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(151 /* ObjectBindingPattern */); + var node = createNode(153 /* ObjectBindingPattern */); parseExpected(14 /* OpenBraceToken */); - node.elements = parseDelimitedList(10 /* ObjectBindingElements */, parseObjectBindingElement); + node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(15 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(152 /* ArrayBindingPattern */); + var node = createNode(154 /* ArrayBindingPattern */); parseExpected(18 /* OpenBracketToken */); - node.elements = parseDelimitedList(11 /* ArrayBindingElements */, parseArrayBindingElement); + node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(19 /* CloseBracketToken */); return finishNode(node); } @@ -10031,7 +10372,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(199 /* VariableDeclaration */); + var node = createNode(201 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -10040,7 +10381,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(200 /* VariableDeclarationList */); + var node = createNode(202 /* VariableDeclarationList */); switch (token) { case 98 /* VarKeyword */: break; @@ -10063,13 +10404,13 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token === 126 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token === 127 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { var savedDisallowIn = inDisallowInContext(); setDisallowInContext(inForStatementInitializer); - node.declarations = parseDelimitedList(9 /* VariableDeclarations */, parseVariableDeclaration); + node.declarations = parseDelimitedList(8 /* VariableDeclarations */, parseVariableDeclaration); setDisallowInContext(savedDisallowIn); } return finishNode(node); @@ -10078,7 +10419,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 17 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(181 /* VariableStatement */, fullStart); + var node = createNode(183 /* VariableStatement */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -10086,7 +10427,7 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(201 /* FunctionDeclaration */, fullStart); + var node = createNode(203 /* FunctionDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(83 /* FunctionKeyword */); @@ -10097,7 +10438,7 @@ var ts; return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(136 /* Constructor */, pos); + var node = createNode(137 /* Constructor */, pos); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(114 /* ConstructorKeyword */); @@ -10106,7 +10447,7 @@ var ts; return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(135 /* MethodDeclaration */, fullStart); + var method = createNode(136 /* MethodDeclaration */, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -10117,7 +10458,7 @@ var ts; return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(133 /* PropertyDeclaration */, fullStart); + var property = createNode(134 /* PropertyDeclaration */, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -10209,7 +10550,7 @@ var ts; // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 121 /* SetKeyword */ || idToken === 116 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 122 /* SetKeyword */ || idToken === 116 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -10243,7 +10584,7 @@ var ts; decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(131 /* Decorator */, decoratorStart); + var decorator = createNode(132 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -10276,7 +10617,7 @@ var ts; } function parseClassElement() { if (token === 22 /* SemicolonToken */) { - var result = createNode(179 /* SemicolonClassElement */); + var result = createNode(181 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -10302,7 +10643,7 @@ var ts; token === 18 /* OpenBracketToken */) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } - if (decorators) { + if (decorators || modifiers) { // treat this as a property declaration with a missing name. var name_6 = createMissingNode(65 /* Identifier */, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_6, undefined); @@ -10314,15 +10655,12 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 175 /* ClassExpression */); + /*modifiers*/ undefined, 177 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 202 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 204 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { - // In ES6 specification, All parts of a ClassDeclaration or a ClassExpression are strict mode code - var savedStrictModeContext = inStrictModeContext(); - setStrictModeContext(true); var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); @@ -10342,9 +10680,7 @@ var ts; else { node.members = createMissingList(); } - var finishedNode = finishNode(node); - setStrictModeContext(savedStrictModeContext); - return finishedNode; + return finishNode(node); } function parseHeritageClauses(isClassHeritageClause) { // ClassTail[Yield,GeneratorParameter] : See 14.5 @@ -10358,23 +10694,23 @@ var ts; return undefined; } function parseHeritageClausesWorker() { - return parseList(19 /* HeritageClauses */, false, parseHeritageClause); + return parseList(18 /* HeritageClauses */, parseHeritageClause); } function parseHeritageClause() { if (token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */) { - var node = createNode(223 /* HeritageClause */); + var node = createNode(225 /* HeritageClause */); node.token = token; nextToken(); - node.types = parseDelimitedList(8 /* HeritageClauseElement */, parseExpressionWithTypeArguments); + node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(177 /* ExpressionWithTypeArguments */); + var node = createNode(179 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 24 /* LessThanToken */) { - node.typeArguments = parseBracketedList(17 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); + node.typeArguments = parseBracketedList(16 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); } return finishNode(node); } @@ -10382,10 +10718,10 @@ var ts; return token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */; } function parseClassMembers() { - return parseList(6 /* ClassMembers */, false, parseClassElement); + return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(203 /* InterfaceDeclaration */, fullStart); + var node = createNode(205 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(103 /* InterfaceKeyword */); @@ -10396,11 +10732,12 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(204 /* TypeAliasDeclaration */, fullStart); + var node = createNode(206 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(124 /* TypeKeyword */); + parseExpected(125 /* TypeKeyword */); node.name = parseIdentifier(); + node.typeParameters = parseTypeParameters(); parseExpected(53 /* EqualsToken */); node.type = parseType(); parseSemicolon(); @@ -10411,19 +10748,19 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNode(227 /* EnumMember */, scanner.getStartPos()); + var node = createNode(229 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(205 /* EnumDeclaration */, fullStart); + var node = createNode(207 /* EnumDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(77 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(14 /* OpenBraceToken */)) { - node.members = parseDelimitedList(7 /* EnumMembers */, parseEnumMember); + node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); parseExpected(15 /* CloseBraceToken */); } else { @@ -10432,9 +10769,9 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(207 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(209 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(14 /* OpenBraceToken */)) { - node.statements = parseList(1 /* ModuleElements */, false, parseModuleElement); + node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(15 /* CloseBraceToken */); } else { @@ -10443,7 +10780,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(206 /* ModuleDeclaration */, fullStart); + var node = createNode(208 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; @@ -10454,7 +10791,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(206 /* ModuleDeclaration */, fullStart); + var node = createNode(208 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -10463,11 +10800,11 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(118 /* NamespaceKeyword */)) { + if (parseOptional(119 /* NamespaceKeyword */)) { flags |= 32768 /* Namespace */; } else { - parseExpected(117 /* ModuleKeyword */); + parseExpected(118 /* ModuleKeyword */); if (token === 8 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -10475,7 +10812,7 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 119 /* RequireKeyword */ && + return token === 120 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -10484,7 +10821,7 @@ var ts; function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 23 /* CommaToken */ || - token === 125 /* FromKeyword */; + token === 126 /* FromKeyword */; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { parseExpected(85 /* ImportKeyword */); @@ -10492,11 +10829,11 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 /* CommaToken */ && token !== 125 /* FromKeyword */) { + if (token !== 23 /* CommaToken */ && token !== 126 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(209 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(211 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; @@ -10507,7 +10844,7 @@ var ts; } } // Import statement - var importDeclaration = createNode(210 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(212 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); // ImportDeclaration: @@ -10517,7 +10854,7 @@ var ts; token === 35 /* AsteriskToken */ || token === 14 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(125 /* FromKeyword */); + parseExpected(126 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -10530,7 +10867,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(211 /* ImportClause */, fullStart); + var importClause = createNode(213 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -10540,7 +10877,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(23 /* CommaToken */)) { - importClause.namedBindings = token === 35 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(213 /* NamedImports */); + importClause.namedBindings = token === 35 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(215 /* NamedImports */); } return finishNode(importClause); } @@ -10550,8 +10887,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(220 /* ExternalModuleReference */); - parseExpected(119 /* RequireKeyword */); + var node = createNode(222 /* ExternalModuleReference */); + parseExpected(120 /* RequireKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(17 /* CloseParenToken */); @@ -10572,7 +10909,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(212 /* NamespaceImport */); + var namespaceImport = createNode(214 /* NamespaceImport */); parseExpected(35 /* AsteriskToken */); parseExpected(111 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -10587,14 +10924,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(20 /* ImportOrExportSpecifiers */, kind === 213 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 14 /* OpenBraceToken */, 15 /* CloseBraceToken */); + node.elements = parseBracketedList(19 /* ImportOrExportSpecifiers */, kind === 215 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 14 /* OpenBraceToken */, 15 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(218 /* ExportSpecifier */); + return parseImportOrExportSpecifier(220 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(214 /* ImportSpecifier */); + return parseImportOrExportSpecifier(216 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -10619,23 +10956,23 @@ var ts; else { node.name = identifierName; } - if (kind === 214 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 216 /* ImportSpecifier */ && checkIdentifierIsKeyword) { // Report error identifier expected parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216 /* ExportDeclaration */, fullStart); + var node = createNode(218 /* ExportDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(35 /* AsteriskToken */)) { - parseExpected(125 /* FromKeyword */); + parseExpected(126 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(217 /* NamedExports */); - if (parseOptional(125 /* FromKeyword */)) { + node.exportClause = parseNamedImportsOrExports(219 /* NamedExports */); + if (parseOptional(126 /* FromKeyword */)) { node.moduleSpecifier = parseModuleSpecifier(); } } @@ -10643,7 +10980,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(215 /* ExportAssignment */, fullStart); + var node = createNode(217 /* ExportAssignment */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(53 /* EqualsToken */)) { @@ -10711,15 +11048,15 @@ var ts; } sourceFile.referencedFiles = referencedFiles; sourceFile.amdDependencies = amdDependencies; - sourceFile.amdModuleName = amdModuleName; + sourceFile.moduleName = amdModuleName; } function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 /* Export */ - || node.kind === 209 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 220 /* ExternalModuleReference */ - || node.kind === 210 /* ImportDeclaration */ - || node.kind === 215 /* ExportAssignment */ - || node.kind === 216 /* ExportDeclaration */ + || node.kind === 211 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 222 /* ExternalModuleReference */ + || node.kind === 212 /* ImportDeclaration */ + || node.kind === 217 /* ExportAssignment */ + || node.kind === 218 /* ExportDeclaration */ ? node : undefined; }); @@ -10727,31 +11064,30 @@ var ts; var ParsingContext; (function (ParsingContext) { ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements"; - ParsingContext[ParsingContext["ModuleElements"] = 1] = "ModuleElements"; - ParsingContext[ParsingContext["BlockStatements"] = 2] = "BlockStatements"; - ParsingContext[ParsingContext["SwitchClauses"] = 3] = "SwitchClauses"; - ParsingContext[ParsingContext["SwitchClauseStatements"] = 4] = "SwitchClauseStatements"; - ParsingContext[ParsingContext["TypeMembers"] = 5] = "TypeMembers"; - ParsingContext[ParsingContext["ClassMembers"] = 6] = "ClassMembers"; - ParsingContext[ParsingContext["EnumMembers"] = 7] = "EnumMembers"; - ParsingContext[ParsingContext["HeritageClauseElement"] = 8] = "HeritageClauseElement"; - ParsingContext[ParsingContext["VariableDeclarations"] = 9] = "VariableDeclarations"; - ParsingContext[ParsingContext["ObjectBindingElements"] = 10] = "ObjectBindingElements"; - ParsingContext[ParsingContext["ArrayBindingElements"] = 11] = "ArrayBindingElements"; - ParsingContext[ParsingContext["ArgumentExpressions"] = 12] = "ArgumentExpressions"; - ParsingContext[ParsingContext["ObjectLiteralMembers"] = 13] = "ObjectLiteralMembers"; - ParsingContext[ParsingContext["ArrayLiteralMembers"] = 14] = "ArrayLiteralMembers"; - ParsingContext[ParsingContext["Parameters"] = 15] = "Parameters"; - ParsingContext[ParsingContext["TypeParameters"] = 16] = "TypeParameters"; - ParsingContext[ParsingContext["TypeArguments"] = 17] = "TypeArguments"; - ParsingContext[ParsingContext["TupleElementTypes"] = 18] = "TupleElementTypes"; - ParsingContext[ParsingContext["HeritageClauses"] = 19] = "HeritageClauses"; - ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 20] = "ImportOrExportSpecifiers"; - ParsingContext[ParsingContext["JSDocFunctionParameters"] = 21] = "JSDocFunctionParameters"; - ParsingContext[ParsingContext["JSDocTypeArguments"] = 22] = "JSDocTypeArguments"; - ParsingContext[ParsingContext["JSDocRecordMembers"] = 23] = "JSDocRecordMembers"; - ParsingContext[ParsingContext["JSDocTupleTypes"] = 24] = "JSDocTupleTypes"; - ParsingContext[ParsingContext["Count"] = 25] = "Count"; // Number of parsing contexts + ParsingContext[ParsingContext["BlockStatements"] = 1] = "BlockStatements"; + ParsingContext[ParsingContext["SwitchClauses"] = 2] = "SwitchClauses"; + ParsingContext[ParsingContext["SwitchClauseStatements"] = 3] = "SwitchClauseStatements"; + ParsingContext[ParsingContext["TypeMembers"] = 4] = "TypeMembers"; + ParsingContext[ParsingContext["ClassMembers"] = 5] = "ClassMembers"; + ParsingContext[ParsingContext["EnumMembers"] = 6] = "EnumMembers"; + ParsingContext[ParsingContext["HeritageClauseElement"] = 7] = "HeritageClauseElement"; + ParsingContext[ParsingContext["VariableDeclarations"] = 8] = "VariableDeclarations"; + ParsingContext[ParsingContext["ObjectBindingElements"] = 9] = "ObjectBindingElements"; + ParsingContext[ParsingContext["ArrayBindingElements"] = 10] = "ArrayBindingElements"; + ParsingContext[ParsingContext["ArgumentExpressions"] = 11] = "ArgumentExpressions"; + ParsingContext[ParsingContext["ObjectLiteralMembers"] = 12] = "ObjectLiteralMembers"; + ParsingContext[ParsingContext["ArrayLiteralMembers"] = 13] = "ArrayLiteralMembers"; + ParsingContext[ParsingContext["Parameters"] = 14] = "Parameters"; + ParsingContext[ParsingContext["TypeParameters"] = 15] = "TypeParameters"; + ParsingContext[ParsingContext["TypeArguments"] = 16] = "TypeArguments"; + ParsingContext[ParsingContext["TupleElementTypes"] = 17] = "TupleElementTypes"; + ParsingContext[ParsingContext["HeritageClauses"] = 18] = "HeritageClauses"; + ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 19] = "ImportOrExportSpecifiers"; + ParsingContext[ParsingContext["JSDocFunctionParameters"] = 20] = "JSDocFunctionParameters"; + ParsingContext[ParsingContext["JSDocTypeArguments"] = 21] = "JSDocTypeArguments"; + ParsingContext[ParsingContext["JSDocRecordMembers"] = 22] = "JSDocRecordMembers"; + ParsingContext[ParsingContext["JSDocTupleTypes"] = 23] = "JSDocTupleTypes"; + ParsingContext[ParsingContext["Count"] = 24] = "Count"; // Number of parsing contexts })(ParsingContext || (ParsingContext = {})); var Tristate; (function (Tristate) { @@ -10793,7 +11129,7 @@ var ts; scanner.setText(sourceText, start, length); // Prime the first token for us to start processing. token = nextToken(); - var result = createNode(229 /* JSDocTypeExpression */); + var result = createNode(231 /* JSDocTypeExpression */); parseExpected(14 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(15 /* CloseBraceToken */); @@ -10804,12 +11140,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token === 44 /* BarToken */) { - var unionType = createNode(233 /* JSDocUnionType */, type.pos); + var unionType = createNode(235 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token === 53 /* EqualsToken */) { - var optionalType = createNode(240 /* JSDocOptionalType */, type.pos); + var optionalType = createNode(242 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -10820,20 +11156,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 18 /* OpenBracketToken */) { - var arrayType = createNode(232 /* JSDocArrayType */, type.pos); + var arrayType = createNode(234 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); parseExpected(19 /* CloseBracketToken */); type = finishNode(arrayType); } else if (token === 50 /* QuestionToken */) { - var nullableType = createNode(235 /* JSDocNullableType */, type.pos); + var nullableType = createNode(237 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token === 46 /* ExclamationToken */) { - var nonNullableType = createNode(236 /* JSDocNonNullableType */, type.pos); + var nonNullableType = createNode(238 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -10867,40 +11203,40 @@ var ts; case 93 /* ThisKeyword */: return parseJSDocThisType(); case 112 /* AnyKeyword */: - case 122 /* StringKeyword */: - case 120 /* NumberKeyword */: + case 123 /* StringKeyword */: + case 121 /* NumberKeyword */: case 113 /* BooleanKeyword */: - case 123 /* SymbolKeyword */: + case 124 /* SymbolKeyword */: case 99 /* VoidKeyword */: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(244 /* JSDocThisType */); + var result = createNode(246 /* JSDocThisType */); nextToken(); parseExpected(51 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(243 /* JSDocConstructorType */); + var result = createNode(245 /* JSDocConstructorType */); nextToken(); parseExpected(51 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(242 /* JSDocVariadicType */); + var result = createNode(244 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(241 /* JSDocFunctionType */); + var result = createNode(243 /* JSDocFunctionType */); nextToken(); parseExpected(16 /* OpenParenToken */); - result.parameters = parseDelimitedList(21 /* JSDocFunctionParameters */, parseJSDocParameter); + result.parameters = parseDelimitedList(20 /* JSDocFunctionParameters */, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(17 /* CloseParenToken */); if (token === 51 /* ColonToken */) { @@ -10910,18 +11246,18 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(130 /* Parameter */); + var parameter = createNode(131 /* Parameter */); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(240 /* JSDocOptionalType */, type.pos); + var result = createNode(242 /* JSDocOptionalType */, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(239 /* JSDocTypeReference */); + var result = createNode(241 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); while (parseOptional(20 /* DotToken */)) { if (token === 24 /* LessThanToken */) { @@ -10937,7 +11273,7 @@ var ts; function parseTypeArguments() { // Move past the < nextToken(); - var typeArguments = parseDelimitedList(22 /* JSDocTypeArguments */, parseJSDocType); + var typeArguments = parseDelimitedList(21 /* JSDocTypeArguments */, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); parseExpected(25 /* GreaterThanToken */); @@ -10951,21 +11287,21 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(127 /* QualifiedName */, left.pos); + var result = createNode(128 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(237 /* JSDocRecordType */); + var result = createNode(239 /* JSDocRecordType */); nextToken(); - result.members = parseDelimitedList(23 /* JSDocRecordMembers */, parseJSDocRecordMember); + result.members = parseDelimitedList(22 /* JSDocRecordMembers */, parseJSDocRecordMember); checkForTrailingComma(result.members); parseExpected(15 /* CloseBraceToken */); return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(238 /* JSDocRecordMember */); + var result = createNode(240 /* JSDocRecordMember */); result.name = parseSimplePropertyName(); if (token === 51 /* ColonToken */) { nextToken(); @@ -10974,15 +11310,15 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(236 /* JSDocNonNullableType */); + var result = createNode(238 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(234 /* JSDocTupleType */); + var result = createNode(236 /* JSDocTupleType */); nextToken(); - result.types = parseDelimitedList(24 /* JSDocTupleTypes */, parseJSDocType); + result.types = parseDelimitedList(23 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); parseExpected(19 /* CloseBracketToken */); return finishNode(result); @@ -10994,7 +11330,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(233 /* JSDocUnionType */); + var result = createNode(235 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(17 /* CloseParenToken */); @@ -11012,7 +11348,7 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(230 /* JSDocAllType */); + var result = createNode(232 /* JSDocAllType */); nextToken(); return finishNode(result); } @@ -11035,11 +11371,11 @@ var ts; token === 25 /* GreaterThanToken */ || token === 53 /* EqualsToken */ || token === 44 /* BarToken */) { - var result = createNode(231 /* JSDocUnknownType */, pos); + var result = createNode(233 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(235 /* JSDocNullableType */, pos); + var result = createNode(237 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -11127,7 +11463,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(245 /* JSDocComment */, start); + var result = createNode(247 /* JSDocComment */, start); result.tags = tags; return finishNode(result, end); } @@ -11165,7 +11501,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(246 /* JSDocTag */, atToken.pos); + var result = createNode(248 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -11217,7 +11553,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(247 /* JSDocParameterTag */, atToken.pos); + var result = createNode(249 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -11227,27 +11563,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 248 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 250 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(248 /* JSDocReturnTag */, atToken.pos); + var result = createNode(250 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 249 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 251 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(249 /* JSDocTypeTag */, atToken.pos); + var result = createNode(251 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 250 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 252 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -11260,7 +11596,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(129 /* TypeParameter */, name_7.pos); + var typeParameter = createNode(130 /* TypeParameter */, name_7.pos); typeParameter.name = name_7; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -11271,7 +11607,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(250 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(252 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -11857,8 +12193,8 @@ var ts; emptyGenericType.instantiations = {}; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var anySignature = createSignature(undefined, undefined, emptyArray, anyType, 0, false, false); - var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, false, false); + var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); + var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); var globals = {}; var globalESSymbolConstructorSymbol; var globalObjectType; @@ -11909,6 +12245,11 @@ var ts; flags: 2097152 /* ESSymbol */ } }; + var subtypeRelation = {}; + var assignableRelation = {}; + var identityRelation = {}; + initializeTypeChecker(); + return checker; function getEmitResolver(sourceFile) { // Ensure we have all the type information in place for this file so that all the // emitter questions of this resolver will return the right information. @@ -12051,10 +12392,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 228 /* SourceFile */); + return ts.getAncestor(node, 230 /* SourceFile */); } function isGlobalSourceFile(node) { - return node.kind === 228 /* SourceFile */ && !ts.isExternalModule(node); + return node.kind === 230 /* SourceFile */ && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -12111,40 +12452,54 @@ var ts; } } switch (location.kind) { - case 228 /* SourceFile */: + case 230 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 206 /* ModuleDeclaration */: - if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8914931 /* ModuleMember */)) { - if (result.flags & meaning || !(result.flags & 8388608 /* Alias */ && getDeclarationOfAliasSymbol(result).kind === 218 /* ExportSpecifier */)) { - break loop; + case 208 /* ModuleDeclaration */: + var moduleExports = getSymbolOfNode(location).exports; + if (location.kind === 230 /* SourceFile */ || + (location.kind === 208 /* ModuleDeclaration */ && location.name.kind === 8 /* StringLiteral */)) { + // It's an external module. Because of module/namespace merging, a module's exports are in scope, + // yet we never want to treat an export specifier as putting a member in scope. Therefore, + // if the name we find is purely an export specifier, it is not actually considered in scope. + // Two things to note about this: + // 1. We have to check this without calling getSymbol. The problem with calling getSymbol + // on an export specifier is that it might find the export specifier itself, and try to + // resolve it as an alias. This will cause the checker to consider the export specifier + // a circular alias reference when it might not be. + // 2. We check === SymbolFlags.Alias in order to check that the symbol is *purely* + // an alias. If we used &, we'd be throwing out symbols that have non alias aspects, + // which is not the desired behavior. + if (ts.hasProperty(moduleExports, name) && + moduleExports[name].flags === 8388608 /* Alias */ && + ts.getDeclarationOfKind(moduleExports[name], 220 /* ExportSpecifier */)) { + break; } - result = undefined; - } - else if (location.kind === 228 /* SourceFile */ || - (location.kind === 206 /* ModuleDeclaration */ && location.name.kind === 8 /* StringLiteral */)) { - result = getSymbolOfNode(location).exports["default"]; + result = moduleExports["default"]; var localSymbol = ts.getLocalSymbolForExportDefault(result); if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; } result = undefined; } + if (result = getSymbol(moduleExports, name, meaning & 8914931 /* ModuleMember */)) { + break loop; + } break; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or // local variables of the constructor. This effectively means that entities from outer scopes // by the same name as a constructor parameter or local variable are inaccessible // in initializer expressions for instance member variables. - if (location.parent.kind === 202 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) { + if (location.parent.kind === 204 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455 /* Value */)) { @@ -12154,8 +12509,8 @@ var ts; } } break; - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { if (lastLocation && lastLocation.flags & 128 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -12175,9 +12530,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (grandparent.kind === 202 /* ClassDeclaration */ || grandparent.kind === 203 /* InterfaceDeclaration */) { + if (grandparent.kind === 204 /* ClassDeclaration */ || grandparent.kind === 205 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -12185,19 +12540,19 @@ var ts; } } break; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 201 /* FunctionDeclaration */: - case 164 /* ArrowFunction */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 203 /* FunctionDeclaration */: + case 166 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 163 /* FunctionExpression */: + case 165 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -12210,7 +12565,7 @@ var ts; } } break; - case 175 /* ClassExpression */: + case 177 /* ClassExpression */: if (meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { @@ -12219,7 +12574,7 @@ var ts; } } break; - case 131 /* Decorator */: + case 132 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -12228,7 +12583,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 130 /* Parameter */) { + if (location.parent && location.parent.kind === 131 /* Parameter */) { location = location.parent; } // @@ -12284,16 +12639,16 @@ var ts; // for (let x in x) // for (let x of x) // climb up to the variable declaration skipping binding patterns - var variableDeclaration = ts.getAncestor(declaration, 199 /* VariableDeclaration */); + var variableDeclaration = ts.getAncestor(declaration, 201 /* VariableDeclaration */); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 181 /* VariableStatement */ || - variableDeclaration.parent.parent.kind === 187 /* ForStatement */) { + if (variableDeclaration.parent.parent.kind === 183 /* VariableStatement */ || + variableDeclaration.parent.parent.kind === 189 /* ForStatement */) { // variable statement/for statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 189 /* ForOfStatement */ || - variableDeclaration.parent.parent.kind === 188 /* ForInStatement */) { + else if (variableDeclaration.parent.parent.kind === 191 /* ForOfStatement */ || + variableDeclaration.parent.parent.kind === 190 /* ForInStatement */) { // ForIn/ForOf case - use site should not be used in expression part var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); @@ -12320,10 +12675,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 209 /* ImportEqualsDeclaration */) { + if (node.kind === 211 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 210 /* ImportDeclaration */) { + while (node && node.kind !== 212 /* ImportDeclaration */) { node = node.parent; } return node; @@ -12333,7 +12688,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 220 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 222 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -12440,17 +12795,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 211 /* ImportClause */: + case 213 /* ImportClause */: return getTargetOfImportClause(node); - case 212 /* NamespaceImport */: + case 214 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 214 /* ImportSpecifier */: + case 216 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 218 /* ExportSpecifier */: + case 220 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return getTargetOfExportAssignment(node); } } @@ -12495,11 +12850,11 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 215 /* ExportAssignment */) { + if (node.kind === 217 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 218 /* ExportSpecifier */) { + else if (node.kind === 220 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -12512,7 +12867,7 @@ var ts; // This function is only for imports with entity names function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 209 /* ImportEqualsDeclaration */); + importDeclaration = ts.getAncestor(entityName, 211 /* ImportEqualsDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } // There are three things we might try to look for. In the following examples, @@ -12525,13 +12880,13 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 65 /* Identifier */ || entityName.parent.kind === 127 /* QualifiedName */) { + if (entityName.kind === 65 /* Identifier */ || entityName.parent.kind === 128 /* QualifiedName */) { return resolveEntityName(entityName, 1536 /* Namespace */); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 209 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 211 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); } } @@ -12551,9 +12906,9 @@ var ts; return undefined; } } - else if (name.kind === 127 /* QualifiedName */ || name.kind === 156 /* PropertyAccessExpression */) { - var left = name.kind === 127 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 127 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 128 /* QualifiedName */ || name.kind === 158 /* PropertyAccessExpression */) { + var left = name.kind === 128 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 128 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1536 /* Namespace */); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -12714,7 +13069,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 136 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 137 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -12784,17 +13139,17 @@ var ts; } } switch (location_1.kind) { - case 228 /* SourceFile */: + case 230 /* SourceFile */: if (!ts.isExternalModule(location_1)) { break; } - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -12943,8 +13298,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 206 /* ModuleDeclaration */ && declaration.name.kind === 8 /* StringLiteral */) || - (declaration.kind === 228 /* SourceFile */ && ts.isExternalModule(declaration)); + return (declaration.kind === 208 /* ModuleDeclaration */ && declaration.name.kind === 8 /* StringLiteral */) || + (declaration.kind === 230 /* SourceFile */ && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -12980,12 +13335,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 145 /* TypeQuery */) { + if (entityName.parent.kind === 147 /* TypeQuery */) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 127 /* QualifiedName */ || entityName.kind === 156 /* PropertyAccessExpression */ || - entityName.parent.kind === 209 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 128 /* QualifiedName */ || entityName.kind === 158 /* PropertyAccessExpression */ || + entityName.parent.kind === 211 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1536 /* Namespace */; @@ -13019,6 +13374,13 @@ var ts; ts.releaseStringWriter(writer); return result; } + function signatureToString(signature, enclosingDeclaration, flags) { + var writer = ts.getSingleLineStringWriter(); + getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); + var result = writer.string(); + ts.releaseStringWriter(writer); + return result; + } function typeToString(type, enclosingDeclaration, flags) { var writer = ts.getSingleLineStringWriter(); getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); @@ -13033,10 +13395,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 150 /* ParenthesizedType */) { + while (node.kind === 152 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 204 /* TypeAliasDeclaration */) { + if (node.kind === 206 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -13286,7 +13648,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 228 /* SourceFile */ || declaration.parent.kind === 207 /* ModuleBlock */; + return declaration.parent.kind === 230 /* SourceFile */ || declaration.parent.kind === 209 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -13364,7 +13726,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, "x")); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 122 /* StringKeyword */); + writeKeyword(writer, 123 /* StringKeyword */); writePunctuation(writer, 19 /* CloseBracketToken */); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); @@ -13378,7 +13740,7 @@ var ts; writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, "x")); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 120 /* NumberKeyword */); + writeKeyword(writer, 121 /* NumberKeyword */); writePunctuation(writer, 19 /* CloseBracketToken */); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); @@ -13421,7 +13783,7 @@ var ts; function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { var targetSymbol = getTargetSymbol(symbol); if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */) { - buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterface(symbol), writer, enclosingDeclaraiton, flags); + buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); } } function buildTypeParameterDisplay(tp, writer, enclosingDeclaration, flags, symbolStack) { @@ -13525,12 +13887,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 206 /* ModuleDeclaration */) { + if (node.kind === 208 /* ModuleDeclaration */) { if (node.name.kind === 8 /* StringLiteral */) { return node; } } - else if (node.kind === 228 /* SourceFile */) { + else if (node.kind === 230 /* SourceFile */) { return ts.isExternalModule(node) ? node : undefined; } } @@ -13579,69 +13941,69 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 153 /* BindingElement */: + case 155 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 199 /* VariableDeclaration */: + case 201 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // Otherwise fall through - case 206 /* ModuleDeclaration */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 201 /* FunctionDeclaration */: - case 205 /* EnumDeclaration */: - case 209 /* ImportEqualsDeclaration */: + case 208 /* ModuleDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 203 /* FunctionDeclaration */: + case 207 /* EnumDeclaration */: + case 211 /* ImportEqualsDeclaration */: var parent_4 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && - !(node.kind !== 209 /* ImportEqualsDeclaration */ && parent_4.kind !== 228 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 211 /* ImportEqualsDeclaration */ && parent_4.kind !== 230 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent_4); - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: if (node.flags & (32 /* Private */ | 64 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so let it fall into next case statement - case 136 /* Constructor */: - case 140 /* ConstructSignature */: - case 139 /* CallSignature */: - case 141 /* IndexSignature */: - case 130 /* Parameter */: - case 207 /* ModuleBlock */: - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 146 /* TypeLiteral */: - case 142 /* TypeReference */: - case 147 /* ArrayType */: - case 148 /* TupleType */: - case 149 /* UnionType */: - case 150 /* ParenthesizedType */: + case 137 /* Constructor */: + case 141 /* ConstructSignature */: + case 140 /* CallSignature */: + case 142 /* IndexSignature */: + case 131 /* Parameter */: + case 209 /* ModuleBlock */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 148 /* TypeLiteral */: + case 144 /* TypeReference */: + case 149 /* ArrayType */: + case 150 /* TupleType */: + case 151 /* UnionType */: + case 152 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 211 /* ImportClause */: - case 212 /* NamespaceImport */: - case 214 /* ImportSpecifier */: + case 213 /* ImportClause */: + case 214 /* NamespaceImport */: + case 216 /* ImportSpecifier */: return false; // Type parameters are always visible - case 129 /* TypeParameter */: + case 130 /* TypeParameter */: // Source file is always visible - case 228 /* SourceFile */: + case 230 /* SourceFile */: return true; // Export assignements do not create name bindings outside the module - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -13657,10 +14019,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 215 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 217 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 218 /* ExportSpecifier */) { + else if (node.parent.kind === 220 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent); } var result = []; @@ -13718,7 +14080,7 @@ var ts; node = ts.getRootDeclaration(node); // Parent chain: // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' - return node.kind === 199 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; + return node.kind === 201 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 @@ -13754,7 +14116,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 151 /* ObjectBindingPattern */) { + if (pattern.kind === 153 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name_9 = declaration.propertyName || declaration.name; // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, @@ -13801,10 +14163,10 @@ var ts; // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration) { // A variable declared in a for..in statement is always of type any - if (declaration.parent.parent.kind === 188 /* ForInStatement */) { + if (declaration.parent.parent.kind === 190 /* ForInStatement */) { return anyType; } - if (declaration.parent.parent.kind === 189 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 191 /* ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -13818,11 +14180,11 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 130 /* Parameter */) { + if (declaration.kind === 131 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 138 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 137 /* GetAccessor */); + if (func.kind === 139 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 138 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -13838,7 +14200,7 @@ var ts; return checkExpressionCached(declaration.initializer); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 226 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 228 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // No type specified and nothing can be inferred @@ -13873,7 +14235,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 176 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 178 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -13896,7 +14258,7 @@ var ts; // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. function getTypeFromBindingPattern(pattern) { - return pattern.kind === 151 /* ObjectBindingPattern */ + return pattern.kind === 153 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -13918,7 +14280,7 @@ var ts; // During a normal type check we'll never get to here with a property assignment (the check of the containing // object literal uses a different path). We exclude widening only so that language services and type verification // tools see the actual type. - return declaration.kind !== 225 /* PropertyAssignment */ ? getWidenedType(type) : type; + return declaration.kind !== 227 /* PropertyAssignment */ ? getWidenedType(type) : type; } // If no type was specified and nothing could be inferred, and if the declaration specifies a binding pattern, use // the type implied by the binding pattern @@ -13930,7 +14292,7 @@ var ts; // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 130 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 131 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -13945,11 +14307,11 @@ var ts; } // Handle catch clause variables var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 224 /* CatchClause */) { + if (declaration.parent.kind === 226 /* CatchClause */) { return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 215 /* ExportAssignment */) { + if (declaration.kind === 217 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle variable, parameter or property @@ -13980,7 +14342,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 137 /* GetAccessor */) { + if (accessor.kind === 138 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -13996,8 +14358,8 @@ var ts; if (!pushTypeResolution(symbol)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 137 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 138 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 138 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 139 /* SetAccessor */); var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); @@ -14026,7 +14388,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 137 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 138 /* GetAccessor */); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -14126,9 +14488,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 202 /* ClassDeclaration */ || node.kind === 201 /* FunctionDeclaration */ || - node.kind === 163 /* FunctionExpression */ || node.kind === 135 /* MethodDeclaration */ || - node.kind === 164 /* ArrowFunction */) { + if (node.kind === 204 /* ClassDeclaration */ || node.kind === 203 /* FunctionDeclaration */ || + node.kind === 165 /* FunctionExpression */ || node.kind === 136 /* MethodDeclaration */ || + node.kind === 166 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -14138,15 +14500,16 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var kind = symbol.flags & 32 /* Class */ ? 202 /* ClassDeclaration */ : 203 /* InterfaceDeclaration */; + var kind = symbol.flags & 32 /* Class */ ? 204 /* ClassDeclaration */ : 205 /* InterfaceDeclaration */; return appendOuterTypeParameters(undefined, ts.getDeclarationOfKind(symbol, kind)); } - // The local type parameters are the combined set of type parameters from all declarations of the class or interface. - function getLocalTypeParametersOfClassOrInterface(symbol) { + // The local type parameters are the combined set of type parameters from all declarations of the class, + // interface, or type alias. + function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 203 /* InterfaceDeclaration */ || node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 205 /* InterfaceDeclaration */ || node.kind === 204 /* ClassDeclaration */ || node.kind === 206 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -14158,56 +14521,122 @@ var ts; // The full set of type parameters for a generic class or interface type consists of its outer type parameters plus // its locally declared type parameters. function getTypeParametersOfClassOrInterface(symbol) { - return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterface(symbol)); + return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); + } + function isConstructorType(type) { + return type.flags & 48128 /* ObjectType */ && getSignaturesOfType(type, 1 /* Construct */).length > 0; + } + function getBaseTypeNodeOfClass(type) { + return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); + } + function getConstructorsForTypeArguments(type, typeArgumentNodes) { + var typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; + return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount; }); + } + function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { + var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); + if (typeArgumentNodes) { + var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); + signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments); }); + } + return signatures; + } + // The base constructor of a class can resolve to + // undefinedType if the class has no extends clause, + // unknownType if an error occurred during resolution of the extends expression, + // nullType if the extends expression is the null value, or + // an object type with at least one construct signature. + function getBaseConstructorTypeOfClass(type) { + if (!type.resolvedBaseConstructorType) { + var baseTypeNode = getBaseTypeNodeOfClass(type); + if (!baseTypeNode) { + return type.resolvedBaseConstructorType = undefinedType; + } + if (!pushTypeResolution(type)) { + return unknownType; + } + var baseConstructorType = checkExpression(baseTypeNode.expression); + if (baseConstructorType.flags & 48128 /* ObjectType */) { + // Resolving the members of a class requires us to resolve the base class of that class. + // We force resolution here such that we catch circularities now. + resolveObjectOrUnionTypeMembers(baseConstructorType); + } + if (!popTypeResolution()) { + error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); + return type.resolvedBaseConstructorType = unknownType; + } + if (baseConstructorType !== unknownType && baseConstructorType !== nullType && !isConstructorType(baseConstructorType)) { + error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); + return type.resolvedBaseConstructorType = unknownType; + } + type.resolvedBaseConstructorType = baseConstructorType; + } + return type.resolvedBaseConstructorType; } function getBaseTypes(type) { - var typeWithBaseTypes = type; - if (!typeWithBaseTypes.baseTypes) { + if (!type.resolvedBaseTypes) { if (type.symbol.flags & 32 /* Class */) { - resolveBaseTypesOfClass(typeWithBaseTypes); + resolveBaseTypesOfClass(type); } else if (type.symbol.flags & 64 /* Interface */) { - resolveBaseTypesOfInterface(typeWithBaseTypes); + resolveBaseTypesOfInterface(type); } else { ts.Debug.fail("type must be class or interface"); } } - return typeWithBaseTypes.baseTypes; + return type.resolvedBaseTypes; } function resolveBaseTypesOfClass(type) { - type.baseTypes = []; - var declaration = ts.getDeclarationOfKind(type.symbol, 202 /* ClassDeclaration */); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(declaration); - if (baseTypeNode) { - var baseType = getTypeFromTypeNode(baseTypeNode); - if (baseType !== unknownType) { - if (getTargetType(baseType).flags & 1024 /* Class */) { - if (type !== baseType && !hasBaseType(baseType, type)) { - type.baseTypes.push(baseType); - } - else { - error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); - } - } - else { - error(baseTypeNode, ts.Diagnostics.A_class_may_only_extend_another_class); - } - } + type.resolvedBaseTypes = emptyArray; + var baseContructorType = getBaseConstructorTypeOfClass(type); + if (!(baseContructorType.flags & 48128 /* ObjectType */)) { + return; } + var baseTypeNode = getBaseTypeNodeOfClass(type); + var baseType; + if (baseContructorType.symbol && baseContructorType.symbol.flags & 32 /* Class */) { + // When base constructor type is a class we know that the constructors all have the same type parameters as the + // class and all return the instance type of the class. There is no need for further checks and we can apply the + // type arguments in the same manner as a type reference to get the same error reporting experience. + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseContructorType.symbol); + } + else { + // The class derives from a "class-like" constructor function, check that we have at least one construct signature + // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere + // we check that all instantiated signatures return the same type. + var constructors = getInstantiatedConstructorsForTypeArguments(baseContructorType, baseTypeNode.typeArguments); + if (!constructors.length) { + error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); + return; + } + baseType = getReturnTypeOfSignature(constructors[0]); + } + if (baseType === unknownType) { + return; + } + if (!(getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */))) { + error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); + return; + } + if (type === baseType || hasBaseType(baseType, type)) { + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); + return; + } + type.resolvedBaseTypes = [baseType]; } function resolveBaseTypesOfInterface(type) { - type.baseTypes = []; + type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 203 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 205 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { if (getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */)) { if (type !== baseType && !hasBaseType(baseType, type)) { - type.baseTypes.push(baseType); + type.resolvedBaseTypes.push(baseType); } else { error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); @@ -14227,7 +14656,7 @@ var ts; var kind = symbol.flags & 32 /* Class */ ? 1024 /* Class */ : 2048 /* Interface */; var type = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); - var localTypeParameters = getLocalTypeParametersOfClassOrInterface(symbol); + var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (outerTypeParameters || localTypeParameters) { type.flags |= 4096 /* Reference */; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); @@ -14249,9 +14678,18 @@ var ts; if (!pushTypeResolution(links)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 204 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 206 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); - if (!popTypeResolution()) { + if (popTypeResolution()) { + links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + if (links.typeParameters) { + // Initialize the instantiation cache for generic type aliases. The declared type corresponds to + // an instantiation of the type alias with the type parameters supplied as type arguments. + links.instantiations = {}; + links.instantiations[getTypeListId(links.typeParameters)] = type; + } + } + else { type = unknownType; error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } @@ -14273,7 +14711,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 129 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 130 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -14388,34 +14826,42 @@ var ts; }); setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } - function createSignature(declaration, typeParameters, parameters, resolvedReturnType, minArgumentCount, hasRestParameter, hasStringLiterals) { + function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); sig.declaration = declaration; sig.typeParameters = typeParameters; sig.parameters = parameters; sig.resolvedReturnType = resolvedReturnType; + sig.typePredicate = typePredicate; sig.minArgumentCount = minArgumentCount; sig.hasRestParameter = hasRestParameter; sig.hasStringLiterals = hasStringLiterals; return sig; } function cloneSignature(sig) { - return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); + return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); } function getDefaultConstructSignatures(classType) { - var baseTypes = getBaseTypes(classType); - if (baseTypes.length) { - var baseType = baseTypes[0]; - var baseSignatures = getSignaturesOfType(getTypeOfSymbol(baseType.symbol), 1 /* Construct */); - return ts.map(baseSignatures, function (baseSignature) { - var signature = baseType.flags & 4096 /* Reference */ ? - getSignatureInstantiation(baseSignature, baseType.typeArguments) : cloneSignature(baseSignature); - signature.typeParameters = classType.localTypeParameters; - signature.resolvedReturnType = classType; - return signature; - }); + if (!getBaseTypes(classType).length) { + return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)]; } - return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, 0, false, false)]; + var baseConstructorType = getBaseConstructorTypeOfClass(classType); + var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); + var baseTypeNode = getBaseTypeNodeOfClass(classType); + var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); + var typeArgCount = typeArguments ? typeArguments.length : 0; + var result = []; + for (var _i = 0; _i < baseSignatures.length; _i++) { + var baseSig = baseSignatures[_i]; + var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; + if (typeParamCount === typeArgCount) { + var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + sig.typeParameters = classType.localTypeParameters; + sig.resolvedReturnType = classType; + result.push(sig); + } + } + return result; } function createTupleTypeMemberSymbols(memberTypes) { var members = {}; @@ -14521,10 +14967,10 @@ var ts; if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); } - var baseTypes = getBaseTypes(classType); - if (baseTypes.length) { + var baseConstructorType = getBaseConstructorTypeOfClass(classType); + if (baseConstructorType.flags & 48128 /* ObjectType */) { members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(getTypeOfSymbol(baseTypes[0].symbol))); + addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); } } stringIndexType = undefined; @@ -14745,7 +15191,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 136 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 137 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -14767,24 +15213,33 @@ var ts; minArgumentCount = declaration.parameters.length; } var returnType; + var typePredicate; if (classType) { returnType = classType; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); + if (declaration.type.kind === 143 /* TypePredicate */) { + var typePredicateNode = declaration.type; + typePredicate = { + parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, + parameterIndex: typePredicateNode.parameterName ? getTypePredicateParameterIndex(declaration.parameters, typePredicateNode.parameterName) : undefined, + type: getTypeFromTypeNode(typePredicateNode.type) + }; + } } else { // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 137 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 138 /* SetAccessor */); + if (declaration.kind === 138 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 139 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { returnType = anyType; } } - links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); + links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); } return links.resolvedSignature; } @@ -14795,19 +15250,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: // Don't include signature if node is the implementation of an overloaded function. A node is considered // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). @@ -14884,7 +15339,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 136 /* Constructor */ || signature.declaration.kind === 140 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 137 /* Constructor */ || signature.declaration.kind === 141 /* ConstructSignature */; var type = createObjectType(32768 /* Anonymous */ | 131072 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; @@ -14898,7 +15353,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 120 /* NumberKeyword */ : 122 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 121 /* NumberKeyword */ : 123 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { var len = indexSymbol.declarations.length; @@ -14928,13 +15383,13 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 129 /* TypeParameter */).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 130 /* TypeParameter */).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 129 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 130 /* TypeParameter */).parent); } function getTypeListId(types) { switch (types.length) { @@ -14987,13 +15442,13 @@ var ts; currentNode = currentNode.parent; } // if last step was made from the type parameter this means that path has started somewhere in constraint which is illegal - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 129 /* TypeParameter */; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 130 /* TypeParameter */; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 142 /* TypeReference */ && n.typeName.kind === 65 /* Identifier */) { + if (n.kind === 144 /* TypeReference */ && n.typeName.kind === 65 /* Identifier */) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, undefined, undefined); @@ -15005,7 +15460,7 @@ var ts; // -> typeParameter and symbol.declaration originate from the same type parameter list // -> illegal for all declarations in symbol // forEach === exists - links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent == typeParameter.parent; }); + links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent === typeParameter.parent; }); } } if (links.isIllegalTypeReferenceInConstraint) { @@ -15019,62 +15474,82 @@ var ts; check(typeParameter.constraint); } } - function getTypeFromTypeReferenceOrExpressionWithTypeArguments(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - var type; - // We don't currently support heritage clauses with complex expressions in them. - // For these cases, we just set the type to be the unknownType. - if (node.kind !== 177 /* ExpressionWithTypeArguments */ || ts.isSupportedExpressionWithTypeArguments(node)) { - var typeNameOrExpression = node.kind === 142 /* TypeReference */ - ? node.typeName - : node.expression; - var symbol = resolveEntityName(typeNameOrExpression, 793056 /* Type */); - if (symbol) { - if ((symbol.flags & 262144 /* TypeParameter */) && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { - // TypeScript 1.0 spec (April 2014): 3.4.1 - // Type parameters declared in a particular type parameter list - // may not be referenced in constraints in that type parameter list - // Implementation: such type references are resolved to 'unknown' type that usually denotes error - type = unknownType; - } - else { - type = createTypeReferenceIfGeneric(getDeclaredTypeOfSymbol(symbol), node, node.typeArguments); - } - } + // Get type from reference to class or interface + function getTypeFromClassOrInterfaceReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var typeParameters = type.localTypeParameters; + if (typeParameters) { + if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */), typeParameters.length); + return unknownType; } - links.resolvedType = type || unknownType; - } - return links.resolvedType; - } - function createTypeReferenceIfGeneric(type, node, typeArguments) { - if (type.flags & (1024 /* Class */ | 2048 /* Interface */) && type.flags & 4096 /* Reference */) { // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - var localTypeParameters = type.localTypeParameters; - var expectedTypeArgCount = localTypeParameters ? localTypeParameters.length : 0; - var typeArgCount = typeArguments ? typeArguments.length : 0; - if (typeArgCount === expectedTypeArgCount) { - // When no type arguments are expected we already have the right type because all outer type parameters - // have themselves as default type arguments. - if (typeArgCount) { - return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(typeArguments, getTypeFromTypeNode))); - } - } - else { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */), expectedTypeArgCount); - return undefined; - } + return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); } - else { - if (typeArguments) { - error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); - return undefined; - } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); + return unknownType; } return type; } + // Get type from reference to type alias. When a type alias is generic, the declared type of the type alias may include + // references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the + // declared type. Instantiations are cached using the type identities of the type arguments as the key. + function getTypeFromTypeAliasReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var links = getSymbolLinks(symbol); + var typeParameters = links.typeParameters; + if (typeParameters) { + if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); + return unknownType; + } + var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); + var id = getTypeListId(typeArguments); + return links.instantiations[id] || (links.instantiations[id] = instantiateType(type, createTypeMapper(typeParameters, typeArguments))); + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); + return unknownType; + } + return type; + } + // Get type from reference to named type that cannot be generic (enum or type parameter) + function getTypeFromNonGenericTypeReference(node, symbol) { + if (symbol.flags & 262144 /* TypeParameter */ && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { + // TypeScript 1.0 spec (April 2014): 3.4.1 + // Type parameters declared in a particular type parameter list + // may not be referenced in constraints in that type parameter list + // Implementation: such type references are resolved to 'unknown' type that usually denotes error + return unknownType; + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); + return unknownType; + } + return getDeclaredTypeOfSymbol(symbol); + } + function getTypeFromTypeReference(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + // We only support expressions that are simple qualified names. For other expressions this produces undefined. + var typeNameOrExpression = node.kind === 144 /* TypeReference */ ? node.typeName : + ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : + undefined; + var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; + var type = symbol === unknownSymbol ? unknownType : + symbol.flags & (32 /* Class */ | 64 /* Interface */) ? getTypeFromClassOrInterfaceReference(node, symbol) : + symbol.flags & 524288 /* TypeAlias */ ? getTypeFromTypeAliasReference(node, symbol) : + getTypeFromNonGenericTypeReference(node, symbol); + // Cache both the resolved symbol and the resolved type. The resolved symbol is needed in when we check the + // type reference in checkTypeReferenceOrExpressionWithTypeArguments. + links.resolvedSymbol = symbol; + links.resolvedType = type; + } + return links.resolvedType; + } function getTypeFromTypeQueryNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { @@ -15082,7 +15557,7 @@ var ts; // The expression is processed as an identifier expression (section 4.3) // or property access expression(section 4.10), // the widened type(section 3.9) of which becomes the result. - links.resolvedType = getWidenedType(checkExpressionOrQualifiedName(node.exprName)); + links.resolvedType = getWidenedType(checkExpression(node.exprName)); } return links.resolvedType; } @@ -15092,9 +15567,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: return declaration; } } @@ -15307,40 +15782,42 @@ var ts; switch (node.kind) { case 112 /* AnyKeyword */: return anyType; - case 122 /* StringKeyword */: + case 123 /* StringKeyword */: return stringType; - case 120 /* NumberKeyword */: + case 121 /* NumberKeyword */: return numberType; case 113 /* BooleanKeyword */: return booleanType; - case 123 /* SymbolKeyword */: + case 124 /* SymbolKeyword */: return esSymbolType; case 99 /* VoidKeyword */: return voidType; case 8 /* StringLiteral */: return getTypeFromStringLiteral(node); - case 142 /* TypeReference */: - return getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); - case 177 /* ExpressionWithTypeArguments */: - return getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); - case 145 /* TypeQuery */: + case 144 /* TypeReference */: + return getTypeFromTypeReference(node); + case 143 /* TypePredicate */: + return booleanType; + case 179 /* ExpressionWithTypeArguments */: + return getTypeFromTypeReference(node); + case 147 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 147 /* ArrayType */: + case 149 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 148 /* TupleType */: + case 150 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 149 /* UnionType */: + case 151 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 150 /* ParenthesizedType */: + case 152 /* ParenthesizedType */: return getTypeFromTypeNode(node.type); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 146 /* TypeLiteral */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 148 /* TypeLiteral */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode case 65 /* Identifier */: - case 127 /* QualifiedName */: + case 128 /* QualifiedName */: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -15430,11 +15907,19 @@ var ts; } function instantiateSignature(signature, mapper, eraseTypeParameters) { var freshTypeParameters; + var freshTypePredicate; if (signature.typeParameters && !eraseTypeParameters) { freshTypeParameters = instantiateList(signature.typeParameters, mapper, instantiateTypeParameter); mapper = combineTypeMappers(createTypeMapper(signature.typeParameters, freshTypeParameters), mapper); } - var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + if (signature.typePredicate) { + freshTypePredicate = { + parameterName: signature.typePredicate.parameterName, + parameterIndex: signature.typePredicate.parameterIndex, + type: instantiateType(signature.typePredicate.type, mapper) + }; + } + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -15499,27 +15984,27 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 135 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 155 /* ObjectLiteralExpression */: + case 157 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return node.operatorToken.kind === 49 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 225 /* PropertyAssignment */: + case 227 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -15527,14 +16012,14 @@ var ts; function isContextSensitiveFunctionLikeDeclaration(node) { return !node.typeParameters && node.parameters.length && !ts.forEach(node.parameters, function (p) { return p.type; }); } - function getTypeWithoutConstructors(type) { + function getTypeWithoutSignatures(type) { if (type.flags & 48128 /* ObjectType */) { var resolved = resolveObjectOrUnionTypeMembers(type); if (resolved.constructSignatures.length) { var result = createObjectType(32768 /* Anonymous */, type.symbol); result.members = resolved.members; result.properties = resolved.properties; - result.callSignatures = resolved.callSignatures; + result.callSignatures = emptyArray; result.constructSignatures = emptyArray; type = result; } @@ -15542,9 +16027,6 @@ var ts; return type; } // TYPE CHECKING - var subtypeRelation = {}; - var assignableRelation = {}; - var identityRelation = {}; function isTypeIdenticalTo(source, target) { return checkTypeRelatedTo(source, target, identityRelation, undefined); } @@ -15821,9 +16303,9 @@ var ts; maybeStack[depth][id] = 1 /* Succeeded */; depth++; var saveExpandingFlags = expandingFlags; - if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack)) + if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) expandingFlags |= 1; - if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack)) + if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth)) expandingFlags |= 2; var result; if (expandingFlags === 3) { @@ -15859,27 +16341,6 @@ var ts; } return result; } - // Return true if the given type is part of a deeply nested chain of generic instantiations. We consider this to be the case - // when structural type comparisons have been started for 10 or more instantiations of the same generic type. It is possible, - // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely expanding. - // Effectively, we will generate a false positive when two types are structurally equal to at least 10 levels, but unequal at - // some level beyond that. - function isDeeplyNestedGeneric(type, stack) { - // We track type references (created by createTypeReference) and instantiated types (created by instantiateType) - if (type.flags & (4096 /* Reference */ | 65536 /* Instantiated */) && depth >= 10) { - var symbol = type.symbol; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (t.flags & (4096 /* Reference */ | 65536 /* Instantiated */) && t.symbol === symbol) { - count++; - if (count >= 10) - return true; - } - } - } - return false; - } function propertiesRelatedTo(source, target, reportErrors) { if (relation === identityRelation) { return propertiesIdenticalTo(source, target); @@ -16060,6 +16521,33 @@ var ts; } result &= related; } + if (source.typePredicate && target.typePredicate) { + var hasDifferentParameterIndex = source.typePredicate.parameterIndex !== target.typePredicate.parameterIndex; + var hasDifferentTypes; + if (hasDifferentParameterIndex || + (hasDifferentTypes = !isTypeIdenticalTo(source.typePredicate.type, target.typePredicate.type))) { + if (reportErrors) { + var sourceParamText = source.typePredicate.parameterName; + var targetParamText = target.typePredicate.parameterName; + var sourceTypeText = typeToString(source.typePredicate.type); + var targetTypeText = typeToString(target.typePredicate.type); + if (hasDifferentParameterIndex) { + reportError(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceParamText, targetParamText); + } + else if (hasDifferentTypes) { + reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceTypeText, targetTypeText); + } + reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, sourceParamText + " is " + sourceTypeText, targetParamText + " is " + targetTypeText); + } + return 0 /* False */; + } + } + else if (!source.typePredicate && target.typePredicate) { + if (reportErrors) { + reportError(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); + } + return 0 /* False */; + } var t = getReturnTypeOfSignature(target); if (t === voidType) return result; @@ -16150,6 +16638,27 @@ var ts; return 0 /* False */; } } + // Return true if the given type is part of a deeply nested chain of generic instantiations. We consider this to be the case + // when structural type comparisons have been started for 10 or more instantiations of the same generic type. It is possible, + // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely expanding. + // Effectively, we will generate a false positive when two types are structurally equal to at least 10 levels, but unequal at + // some level beyond that. + function isDeeplyNestedGeneric(type, stack, depth) { + // We track type references (created by createTypeReference) and instantiated types (created by instantiateType) + if (type.flags & (4096 /* Reference */ | 65536 /* Instantiated */) && depth >= 5) { + var symbol = type.symbol; + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (t.flags & (4096 /* Reference */ | 65536 /* Instantiated */) && t.symbol === symbol) { + count++; + if (count >= 5) + return true; + } + } + } + return false; + } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypes) !== 0 /* False */; } @@ -16356,22 +16865,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 130 /* Parameter */: + case 131 /* Parameter */: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -16444,20 +16953,6 @@ var ts; } return false; } - function isWithinDepthLimit(type, stack) { - if (depth >= 5) { - var target_1 = type.target; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (t.flags & 4096 /* Reference */ && t.target === target_1) { - count++; - } - } - return count < 5; - } - return true; - } function inferFromTypes(source, target) { if (source === anyFunctionType) { return; @@ -16527,22 +17022,26 @@ var ts; else if (source.flags & 48128 /* ObjectType */ && (target.flags & (4096 /* Reference */ | 8192 /* Tuple */) || (target.flags & 32768 /* Anonymous */) && target.symbol && target.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */))) { // If source is an object type, and target is a type reference, a tuple type, the type of a method, or a type literal, infer from members - if (!isInProcess(source, target) && isWithinDepthLimit(source, sourceStack) && isWithinDepthLimit(target, targetStack)) { - if (depth === 0) { - sourceStack = []; - targetStack = []; - } - sourceStack[depth] = source; - targetStack[depth] = target; - depth++; - inferFromProperties(source, target); - inferFromSignatures(source, target, 0 /* Call */); - inferFromSignatures(source, target, 1 /* Construct */); - inferFromIndexTypes(source, target, 0 /* String */, 0 /* String */); - inferFromIndexTypes(source, target, 1 /* Number */, 1 /* Number */); - inferFromIndexTypes(source, target, 0 /* String */, 1 /* Number */); - depth--; + if (isInProcess(source, target)) { + return; } + if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { + return; + } + if (depth === 0) { + sourceStack = []; + targetStack = []; + } + sourceStack[depth] = source; + targetStack[depth] = target; + depth++; + inferFromProperties(source, target); + inferFromSignatures(source, target, 0 /* Call */); + inferFromSignatures(source, target, 1 /* Construct */); + inferFromIndexTypes(source, target, 0 /* String */, 0 /* String */); + inferFromIndexTypes(source, target, 1 /* Number */, 1 /* Number */); + inferFromIndexTypes(source, target, 0 /* String */, 1 /* Number */); + depth--; } } function inferFromProperties(source, target) { @@ -16567,7 +17066,17 @@ var ts; } function inferFromSignature(source, target) { forEachMatchingParameterType(source, target, inferFromTypes); - inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + if (source.typePredicate && target.typePredicate) { + if (target.typePredicate.parameterIndex === source.typePredicate.parameterIndex) { + // Return types from type predicates are treated as booleans. In order to infer types + // from type predicates we would need to infer using the type within the type predicate + // (i.e. 'Foo' from 'x is Foo'). + inferFromTypes(source.typePredicate.type, target.typePredicate.type); + } + } + else { + inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + } } function inferFromIndexTypes(source, target, sourceKind, targetKind) { var targetIndexType = getIndexTypeOfType(target, targetKind); @@ -16640,10 +17149,10 @@ var ts; // The expression is restricted to a single identifier or a sequence of identifiers separated by periods while (node) { switch (node.kind) { - case 145 /* TypeQuery */: + case 147 /* TypeQuery */: return true; case 65 /* Identifier */: - case 127 /* QualifiedName */: + case 128 /* QualifiedName */: node = node.parent; continue; default: @@ -16691,7 +17200,7 @@ var ts; function isAssignedInBinaryExpression(node) { if (node.operatorToken.kind >= 53 /* FirstAssignment */ && node.operatorToken.kind <= 64 /* LastAssignment */) { var n = node.left; - while (n.kind === 162 /* ParenthesizedExpression */) { + while (n.kind === 164 /* ParenthesizedExpression */) { n = n.expression; } if (n.kind === 65 /* Identifier */ && getResolvedSymbol(n) === symbol) { @@ -16708,46 +17217,46 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: return isAssignedInVariableDeclaration(node); - case 151 /* ObjectBindingPattern */: - case 152 /* ArrayBindingPattern */: - case 154 /* ArrayLiteralExpression */: - case 155 /* ObjectLiteralExpression */: - case 156 /* PropertyAccessExpression */: - case 157 /* ElementAccessExpression */: - case 158 /* CallExpression */: - case 159 /* NewExpression */: - case 161 /* TypeAssertionExpression */: - case 162 /* ParenthesizedExpression */: - case 168 /* PrefixUnaryExpression */: - case 165 /* DeleteExpression */: - case 166 /* TypeOfExpression */: - case 167 /* VoidExpression */: - case 169 /* PostfixUnaryExpression */: - case 171 /* ConditionalExpression */: - case 174 /* SpreadElementExpression */: - case 180 /* Block */: - case 181 /* VariableStatement */: - case 183 /* ExpressionStatement */: - case 184 /* IfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 192 /* ReturnStatement */: - case 193 /* WithStatement */: - case 194 /* SwitchStatement */: - case 221 /* CaseClause */: - case 222 /* DefaultClause */: - case 195 /* LabeledStatement */: - case 196 /* ThrowStatement */: - case 197 /* TryStatement */: - case 224 /* CatchClause */: + case 153 /* ObjectBindingPattern */: + case 154 /* ArrayBindingPattern */: + case 156 /* ArrayLiteralExpression */: + case 157 /* ObjectLiteralExpression */: + case 158 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: + case 163 /* TypeAssertionExpression */: + case 164 /* ParenthesizedExpression */: + case 170 /* PrefixUnaryExpression */: + case 167 /* DeleteExpression */: + case 168 /* TypeOfExpression */: + case 169 /* VoidExpression */: + case 171 /* PostfixUnaryExpression */: + case 173 /* ConditionalExpression */: + case 176 /* SpreadElementExpression */: + case 182 /* Block */: + case 183 /* VariableStatement */: + case 185 /* ExpressionStatement */: + case 186 /* IfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 194 /* ReturnStatement */: + case 195 /* WithStatement */: + case 196 /* SwitchStatement */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: + case 197 /* LabeledStatement */: + case 198 /* ThrowStatement */: + case 199 /* TryStatement */: + case 226 /* CatchClause */: return ts.forEachChild(node, isAssignedIn); } return false; @@ -16800,19 +17309,19 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 184 /* IfStatement */: + case 186 /* IfStatement */: // In a branch of an if statement, narrow based on controlling expression if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: // In a branch of a conditional expression, narrow based on controlling condition if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: // In the right operand of an && or ||, narrow based on left operand if (child === node.right) { if (node.operatorToken.kind === 48 /* AmpersandAmpersandToken */) { @@ -16823,14 +17332,14 @@ var ts; } } break; - case 228 /* SourceFile */: - case 206 /* ModuleDeclaration */: - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 136 /* Constructor */: + case 230 /* SourceFile */: + case 208 /* ModuleDeclaration */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 137 /* Constructor */: // Stop at the first containing function or module declaration break loop; } @@ -16847,7 +17356,7 @@ var ts; return type; function narrowTypeByEquality(type, expr, assumeTrue) { // Check that we have 'typeof ' on the left and string literal on the right - if (expr.left.kind !== 166 /* TypeOfExpression */ || expr.right.kind !== 8 /* StringLiteral */) { + if (expr.left.kind !== 168 /* TypeOfExpression */ || expr.right.kind !== 8 /* StringLiteral */) { return type; } var left = expr.left; @@ -16923,7 +17432,7 @@ var ts; var targetType; var prototypeProperty = getPropertyOfType(rightType, "prototype"); if (prototypeProperty) { - // Target type is type of the protoype property + // Target type is type of the prototype property var prototypePropertyType = getTypeOfSymbol(prototypeProperty); if (!isTypeAny(prototypePropertyType)) { targetType = prototypePropertyType; @@ -16943,14 +17452,36 @@ var ts; } } if (targetType) { - // Narrow to the target type if it's a subtype of the current type - if (isTypeSubtypeOf(targetType, type)) { - return targetType; - } - // If the current type is a union type, remove all constituents that aren't subtypes of the target. - if (type.flags & 16384 /* Union */) { - return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); })); + return getNarrowedType(type, targetType); + } + return type; + } + function getNarrowedType(originalType, narrowedTypeCandidate) { + // Narrow to the target type if it's a subtype of the current type + if (isTypeSubtypeOf(narrowedTypeCandidate, originalType)) { + return narrowedTypeCandidate; + } + // If the current type is a union type, remove all constituents that aren't subtypes of the target. + if (originalType.flags & 16384 /* Union */) { + return getUnionType(ts.filter(originalType.types, function (t) { return isTypeSubtypeOf(t, narrowedTypeCandidate); })); + } + return originalType; + } + function narrowTypeByTypePredicate(type, expr, assumeTrue) { + if (type.flags & 1 /* Any */) { + return type; + } + var signature = getResolvedSignature(expr); + if (signature.typePredicate && + expr.arguments[signature.typePredicate.parameterIndex] && + getSymbolAtLocation(expr.arguments[signature.typePredicate.parameterIndex]) === symbol) { + if (!assumeTrue) { + if (type.flags & 16384 /* Union */) { + return getUnionType(ts.filter(type.types, function (t) { return !isTypeSubtypeOf(t, signature.typePredicate.type); })); + } + return type; } + return getNarrowedType(type, signature.typePredicate.type); } return type; } @@ -16958,9 +17489,11 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 162 /* ParenthesizedExpression */: + case 160 /* CallExpression */: + return narrowTypeByTypePredicate(type, expr, assumeTrue); + case 164 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: var operator = expr.operatorToken.kind; if (operator === 30 /* EqualsEqualsEqualsToken */ || operator === 31 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -16975,7 +17508,7 @@ var ts; return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 168 /* PrefixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: if (expr.operator === 46 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -16992,7 +17525,7 @@ var ts; // will be bound to non-arrow function that contain this arrow function. This results in inconsistent behavior. // To avoid that we will give an error to users if they use arguments objects in arrow function so that they // can explicitly bound arguments objects - if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 164 /* ArrowFunction */ && languageVersion < 2 /* ES6 */) { + if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 166 /* ArrowFunction */ && languageVersion < 2 /* ES6 */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } if (symbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { @@ -17016,7 +17549,7 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 /* ES6 */ || (symbol.flags & 2 /* BlockScopedVariable */) === 0 || - symbol.valueDeclaration.parent.kind === 224 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 226 /* CatchClause */) { return; } // - check if binding is used in some function @@ -17025,12 +17558,12 @@ var ts; // nesting structure: // (variable declaration or binding element) -> variable declaration list -> container var container = symbol.valueDeclaration; - while (container.kind !== 200 /* VariableDeclarationList */) { + while (container.kind !== 202 /* VariableDeclarationList */) { container = container.parent; } // get the parent of variable declaration list container = container.parent; - if (container.kind === 181 /* VariableStatement */) { + if (container.kind === 183 /* VariableStatement */) { // if parent is variable statement - get its parent container = container.parent; } @@ -17049,9 +17582,9 @@ var ts; } } function captureLexicalThis(node, container) { - var classNode = container.parent && container.parent.kind === 202 /* ClassDeclaration */ ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 204 /* ClassDeclaration */ ? container.parent : undefined; getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 133 /* PropertyDeclaration */ || container.kind === 136 /* Constructor */) { + if (container.kind === 134 /* PropertyDeclaration */ || container.kind === 137 /* Constructor */) { getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } else { @@ -17064,39 +17597,39 @@ var ts; var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 164 /* ArrowFunction */) { + if (container.kind === 166 /* ArrowFunction */) { container = ts.getThisContainer(container, false); // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code needToCaptureLexicalThis = (languageVersion < 2 /* ES6 */); } switch (container.kind) { - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 136 /* Constructor */: + case 137 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: if (container.flags & 128 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } if (needToCaptureLexicalThis) { captureLexicalThis(node, container); } - var classNode = container.parent && container.parent.kind === 202 /* ClassDeclaration */ ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 204 /* ClassDeclaration */ ? container.parent : undefined; if (classNode) { var symbol = getSymbolOfNode(classNode); return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); @@ -17105,23 +17638,21 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 130 /* Parameter */) { + if (n.kind === 131 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 158 /* CallExpression */ && node.parent.expression === node; - var enclosingClass = ts.getAncestor(node, 202 /* ClassDeclaration */); - var baseClass; - if (enclosingClass && ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); - var baseTypes = getBaseTypes(classType); - baseClass = baseTypes.length && baseTypes[0]; - } - if (!baseClass) { - error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); + var isCallExpression = node.parent.kind === 160 /* CallExpression */ && node.parent.expression === node; + var classDeclaration = ts.getAncestor(node, 204 /* ClassDeclaration */); + var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); + var baseClassType = classType && getBaseTypes(classType)[0]; + if (!baseClassType) { + if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { + error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); + } return unknownType; } var container = ts.getSuperContainer(node, true); @@ -17131,7 +17662,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - canUseSuperExpression = container.kind === 136 /* Constructor */; + canUseSuperExpression = container.kind === 137 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -17140,28 +17671,28 @@ var ts; // - In a static member function or static member accessor // super property access might appear in arrow functions with arbitrary deep nesting needToCaptureLexicalThis = false; - while (container && container.kind === 164 /* ArrowFunction */) { + while (container && container.kind === 166 /* ArrowFunction */) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; } // topmost container must be something that is directly nested in the class declaration - if (container && container.parent && container.parent.kind === 202 /* ClassDeclaration */) { + if (container && container.parent && container.parent.kind === 204 /* ClassDeclaration */) { if (container.flags & 128 /* Static */) { canUseSuperExpression = - container.kind === 135 /* MethodDeclaration */ || - container.kind === 134 /* MethodSignature */ || - container.kind === 137 /* GetAccessor */ || - container.kind === 138 /* SetAccessor */; + container.kind === 136 /* MethodDeclaration */ || + container.kind === 135 /* MethodSignature */ || + container.kind === 138 /* GetAccessor */ || + container.kind === 139 /* SetAccessor */; } else { canUseSuperExpression = - container.kind === 135 /* MethodDeclaration */ || - container.kind === 134 /* MethodSignature */ || - container.kind === 137 /* GetAccessor */ || - container.kind === 138 /* SetAccessor */ || - container.kind === 133 /* PropertyDeclaration */ || - container.kind === 132 /* PropertySignature */ || - container.kind === 136 /* Constructor */; + container.kind === 136 /* MethodDeclaration */ || + container.kind === 135 /* MethodSignature */ || + container.kind === 138 /* GetAccessor */ || + container.kind === 139 /* SetAccessor */ || + container.kind === 134 /* PropertyDeclaration */ || + container.kind === 133 /* PropertySignature */ || + container.kind === 137 /* Constructor */; } } } @@ -17169,13 +17700,13 @@ var ts; var returnType; if ((container.flags & 128 /* Static */) || isCallExpression) { getNodeLinks(node).flags |= 32 /* SuperStatic */; - returnType = getTypeOfSymbol(baseClass.symbol); + returnType = getBaseConstructorTypeOfClass(classType); } else { getNodeLinks(node).flags |= 16 /* SuperInstance */; - returnType = baseClass; + returnType = baseClassType; } - if (container.kind === 136 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 137 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); returnType = unknownType; @@ -17189,7 +17720,7 @@ var ts; return returnType; } } - if (container && container.kind === 128 /* ComputedPropertyName */) { + if (container && container.kind === 129 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -17234,7 +17765,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 130 /* Parameter */) { + if (declaration.kind === 131 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -17269,8 +17800,8 @@ var ts; // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed if (functionDecl.type || - functionDecl.kind === 136 /* Constructor */ || - functionDecl.kind === 137 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 138 /* SetAccessor */))) { + functionDecl.kind === 137 /* Constructor */ || + functionDecl.kind === 138 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 139 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -17292,7 +17823,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 160 /* TaggedTemplateExpression */) { + if (template.parent.kind === 162 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -17423,34 +17954,34 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 199 /* VariableDeclaration */: - case 130 /* Parameter */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 153 /* BindingElement */: + case 201 /* VariableDeclaration */: + case 131 /* Parameter */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 155 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 164 /* ArrowFunction */: - case 192 /* ReturnStatement */: + case 166 /* ArrowFunction */: + case 194 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 173 /* YieldExpression */: + case 175 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: return getTypeFromTypeNode(parent.type); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 225 /* PropertyAssignment */: + case 227 /* PropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 178 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 172 /* TemplateExpression */); + case 180 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 174 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return getContextualType(parent); } return undefined; @@ -17467,7 +17998,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 163 /* FunctionExpression */ || node.kind === 164 /* ArrowFunction */; + return node.kind === 165 /* FunctionExpression */ || node.kind === 166 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -17481,7 +18012,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 135 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -17537,13 +18068,13 @@ var ts; // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 170 /* BinaryExpression */ && parent.operatorToken.kind === 53 /* EqualsToken */ && parent.left === node) { + if (parent.kind === 172 /* BinaryExpression */ && parent.operatorToken.kind === 53 /* EqualsToken */ && parent.left === node) { return true; } - if (parent.kind === 225 /* PropertyAssignment */) { + if (parent.kind === 227 /* PropertyAssignment */) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 154 /* ArrayLiteralExpression */) { + if (parent.kind === 156 /* ArrayLiteralExpression */) { return isAssignmentTarget(parent); } return false; @@ -17568,7 +18099,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 174 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 176 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -17592,7 +18123,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 174 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 176 /* SpreadElementExpression */; } if (!hasSpreadElement) { var contextualType = getContextualType(node); @@ -17603,7 +18134,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 128 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 129 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, @@ -17662,18 +18193,18 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 225 /* PropertyAssignment */ || - memberDecl.kind === 226 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 227 /* PropertyAssignment */ || + memberDecl.kind === 228 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 225 /* PropertyAssignment */) { + if (memberDecl.kind === 227 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 135 /* MethodDeclaration */) { + else if (memberDecl.kind === 136 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 226 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 228 /* ShorthandPropertyAssignment */); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -17693,7 +18224,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 137 /* GetAccessor */ || memberDecl.kind === 138 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 138 /* GetAccessor */ || memberDecl.kind === 139 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -17732,7 +18263,7 @@ var ts; // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 133 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 134 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; @@ -17745,7 +18276,7 @@ var ts; } // Property is known to be private or protected at this point // Get the declaring and enclosing class instance types - var enclosingClassDeclaration = ts.getAncestor(node, 202 /* ClassDeclaration */); + var enclosingClassDeclaration = ts.getAncestor(node, 204 /* ClassDeclaration */); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; var declaringClass = getDeclaredTypeOfSymbol(prop.parent); // Private property is accessible if declaring and enclosing class are the same @@ -17781,7 +18312,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { - var type = checkExpressionOrQualifiedName(left); + var type = checkExpression(left); if (isTypeAny(type)) { return type; } @@ -17806,7 +18337,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 135 /* MethodDeclaration */) { + if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 136 /* MethodDeclaration */) { error(right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); } else { @@ -17816,14 +18347,14 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 156 /* PropertyAccessExpression */ + var left = node.kind === 158 /* PropertyAccessExpression */ ? node.expression : node.left; - var type = checkExpressionOrQualifiedName(left); + var type = checkExpression(left); if (type !== unknownType && !isTypeAny(type)) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32 /* Class */) { - if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 135 /* MethodDeclaration */) { + if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 136 /* MethodDeclaration */) { return false; } else { @@ -17839,7 +18370,7 @@ var ts; // Grammar checking if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 159 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 161 /* NewExpression */ && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -17968,7 +18499,7 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 160 /* TaggedTemplateExpression */) { + if (node.kind === 162 /* TaggedTemplateExpression */) { checkExpression(node.template); } else { @@ -18036,7 +18567,7 @@ var ts; } function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { - if (args[i].kind === 174 /* SpreadElementExpression */) { + if (args[i].kind === 176 /* SpreadElementExpression */) { return i; } } @@ -18046,13 +18577,13 @@ var ts; var adjustedArgCount; // Apparent number of arguments we will have in this call var typeArguments; // Type arguments (undefined if none) var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments - if (node.kind === 160 /* TaggedTemplateExpression */) { + if (node.kind === 162 /* TaggedTemplateExpression */) { var tagExpression = node; // Even if the call is incomplete, we'll have a missing expression as our last argument, // so we can say the count is just the arg list length adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 172 /* TemplateExpression */) { + if (tagExpression.template.kind === 174 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var templateExpression = tagExpression.template; @@ -18073,7 +18604,7 @@ var ts; var callExpression = node; if (!callExpression.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(callExpression.kind === 159 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 161 /* NewExpression */); return signature.minArgumentCount === 0; } // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. @@ -18150,10 +18681,10 @@ var ts; // wildcards for all context sensitive function expressions. for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg.kind !== 176 /* OmittedExpression */) { + if (arg.kind !== 178 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = void 0; - if (i === 0 && args[i].parent.kind === 160 /* TaggedTemplateExpression */) { + if (i === 0 && args[i].parent.kind === 162 /* TaggedTemplateExpression */) { argType = globalTemplateStringsArrayType; } else { @@ -18200,12 +18731,12 @@ var ts; function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg.kind !== 176 /* OmittedExpression */) { + if (arg.kind !== 178 /* OmittedExpression */) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) var paramType = getTypeAtPosition(signature, i); // A tagged template expression provides a special first argument, and string literals get string literal types // unless we're reporting errors - var argType = i === 0 && node.kind === 160 /* TaggedTemplateExpression */ + var argType = i === 0 && node.kind === 162 /* TaggedTemplateExpression */ ? globalTemplateStringsArrayType : arg.kind === 8 /* StringLiteral */ && !reportErrors ? getStringLiteralType(arg) @@ -18227,10 +18758,10 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 160 /* TaggedTemplateExpression */) { + if (node.kind === 162 /* TaggedTemplateExpression */) { var template = node.template; args = [template]; - if (template.kind === 172 /* TemplateExpression */) { + if (template.kind === 174 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); @@ -18241,32 +18772,11 @@ var ts; } return args; } - /** - * In a 'super' call, type arguments are not provided within the CallExpression node itself. - * Instead, they must be fetched from the class declaration's base type node. - * - * If 'node' is a 'super' call (e.g. super(...), new super(...)), then we attempt to fetch - * the type arguments off the containing class's first heritage clause (if one exists). Note that if - * type arguments are supplied on the 'super' call, they are ignored (though this is syntactically incorrect). - * - * In all other cases, the call's explicit type arguments are returned. - */ - function getEffectiveTypeArguments(callExpression) { - if (callExpression.expression.kind === 91 /* SuperKeyword */) { - var containingClass = ts.getAncestor(callExpression, 202 /* ClassDeclaration */); - var baseClassTypeNode = containingClass && ts.getClassExtendsHeritageClauseElement(containingClass); - return baseClassTypeNode && baseClassTypeNode.typeArguments; - } - else { - // Ordinary case - simple function invocation. - return callExpression.typeArguments; - } - } function resolveCall(node, signatures, candidatesOutArray) { - var isTaggedTemplate = node.kind === 160 /* TaggedTemplateExpression */; + var isTaggedTemplate = node.kind === 162 /* TaggedTemplateExpression */; var typeArguments; if (!isTaggedTemplate) { - typeArguments = getEffectiveTypeArguments(node); + typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. if (node.expression.kind !== 91 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); @@ -18361,8 +18871,8 @@ var ts; checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); } else if (candidateForTypeArgumentError) { - if (!isTaggedTemplate && node.typeArguments) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], true); + if (!isTaggedTemplate && typeArguments) { + checkTypeArguments(candidateForTypeArgumentError, typeArguments, [], true); } else { ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); @@ -18456,7 +18966,11 @@ var ts; if (node.expression.kind === 91 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { - return resolveCall(node, getSignaturesOfType(superType, 1 /* Construct */), candidatesOutArray); + // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated + // with the type arguments specified in the extends clause. + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getAncestor(node, 204 /* ClassDeclaration */)); + var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + return resolveCall(node, baseConstructors, candidatesOutArray); } return resolveUntypedCall(node); } @@ -18578,13 +19092,13 @@ var ts; // to correctly fill the candidatesOutArray. if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 158 /* CallExpression */) { + if (node.kind === 160 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 159 /* NewExpression */) { + else if (node.kind === 161 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 160 /* TaggedTemplateExpression */) { + else if (node.kind === 162 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } else { @@ -18600,12 +19114,12 @@ var ts; if (node.expression.kind === 91 /* SuperKeyword */) { return voidType; } - if (node.kind === 159 /* NewExpression */) { + if (node.kind === 161 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 136 /* Constructor */ && - declaration.kind !== 140 /* ConstructSignature */ && - declaration.kind !== 144 /* ConstructorType */) { + declaration.kind !== 137 /* Constructor */ && + declaration.kind !== 141 /* ConstructSignature */ && + declaration.kind !== 146 /* ConstructorType */) { // When resolved signature is a call signature (and not a construct signature) the result type is any if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); @@ -18653,7 +19167,7 @@ var ts; return unknownType; } var type; - if (func.body.kind !== 180 /* Block */) { + if (func.body.kind !== 182 /* Block */) { type = checkExpressionCached(func.body, contextualMapper); } else { @@ -18733,7 +19247,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 196 /* ThrowStatement */); + return (body.statements.length === 1) && (body.statements[0].kind === 198 /* ThrowStatement */); } // TypeScript Specification 1.0 (6.3) - July 2014 // An explicitly typed function whose return type isn't the Void or the Any type @@ -18748,7 +19262,7 @@ var ts; return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. - if (ts.nodeIsMissing(func.body) || func.body.kind !== 180 /* Block */) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 182 /* Block */) { return; } var bodyBlock = func.body; @@ -18766,11 +19280,11 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 135 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking - var hasGrammarError = checkGrammarDeclarationNameInStrictMode(node) || checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 163 /* FunctionExpression */) { - checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node); + var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); + if (!hasGrammarError && node.kind === 165 /* FunctionExpression */) { + checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -18801,14 +19315,14 @@ var ts; checkSignatureDeclaration(node); } } - if (produceDiagnostics && node.kind !== 135 /* MethodDeclaration */ && node.kind !== 134 /* MethodSignature */) { + if (produceDiagnostics && node.kind !== 136 /* MethodDeclaration */ && node.kind !== 135 /* MethodSignature */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 135 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 136 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); if (node.type && !node.asteriskToken) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); } @@ -18821,7 +19335,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 180 /* Block */) { + if (node.body.kind === 182 /* Block */) { checkSourceElement(node.body); } else { @@ -18863,17 +19377,17 @@ var ts; // An identifier expression that references any other kind of entity is classified as a value(and therefore cannot be the target of an assignment). return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; } - case 156 /* PropertyAccessExpression */: { + case 158 /* PropertyAccessExpression */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.10 // A property access expression is always classified as a reference. // NOTE (not in spec): assignment to enum members should not be allowed return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; } - case 157 /* ElementAccessExpression */: + case 159 /* ElementAccessExpression */: // old compiler doesn't check indexed assess return true; - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -18882,11 +19396,11 @@ var ts; function isConstVariableReference(n) { switch (n.kind) { case 65 /* Identifier */: - case 156 /* PropertyAccessExpression */: { + case 158 /* PropertyAccessExpression */: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 8192 /* Const */) !== 0; } - case 157 /* ElementAccessExpression */: { + case 159 /* ElementAccessExpression */: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 8 /* StringLiteral */) { @@ -18896,7 +19410,7 @@ var ts; } return false; } - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return isConstVariableReference(n.expression); default: return false; @@ -18913,13 +19427,7 @@ var ts; return true; } function checkDeleteExpression(node) { - // Grammar checking - if (node.parserContextFlags & 1 /* StrictMode */ && node.expression.kind === 65 /* Identifier */) { - // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its - // UnaryExpression is a direct reference to a variable, function argument, or function name - grammarErrorOnNode(node.expression, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); - } - var operandType = checkExpression(node.expression); + checkExpression(node.expression); return booleanType; } function checkTypeOfExpression(node) { @@ -18931,13 +19439,6 @@ var ts; return undefinedType; } function checkPrefixUnaryExpression(node) { - // Grammar checking - // The identifier eval or arguments may not appear as the LeftHandSideExpression of an - // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression - // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator - if ((node.operator === 38 /* PlusPlusToken */ || node.operator === 39 /* MinusMinusToken */)) { - checkGrammarEvalOrArgumentsInStrictMode(node, node.operand); - } var operandType = checkExpression(node.operand); switch (node.operator) { case 33 /* PlusToken */: @@ -18961,11 +19462,6 @@ var ts; return unknownType; } function checkPostfixUnaryExpression(node) { - // Grammar checking - // The identifier eval or arguments may not appear as the LeftHandSideExpression of an - // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression - // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator. - checkGrammarEvalOrArgumentsInStrictMode(node, node.operand); var operandType = checkExpression(node.operand); var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { @@ -19047,7 +19543,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 225 /* PropertyAssignment */ || p.kind === 226 /* ShorthandPropertyAssignment */) { + if (p.kind === 227 /* PropertyAssignment */ || p.kind === 228 /* ShorthandPropertyAssignment */) { // TODO(andersh): Computed property support var name_12 = p.name; var type = isTypeAny(sourceType) @@ -19076,8 +19572,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 176 /* OmittedExpression */) { - if (e.kind !== 174 /* SpreadElementExpression */) { + if (e.kind !== 178 /* OmittedExpression */) { + if (e.kind !== 176 /* SpreadElementExpression */) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -19102,7 +19598,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 170 /* BinaryExpression */ && restExpression.operatorToken.kind === 53 /* EqualsToken */) { + if (restExpression.kind === 172 /* BinaryExpression */ && restExpression.operatorToken.kind === 53 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -19115,14 +19611,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 170 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { + if (target.kind === 172 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 155 /* ObjectLiteralExpression */) { + if (target.kind === 157 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 154 /* ArrayLiteralExpression */) { + if (target.kind === 156 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -19135,14 +19631,8 @@ var ts; return sourceType; } function checkBinaryExpression(node, contextualMapper) { - // Grammar checking - if (ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) { - // ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an - // Assignment operator(11.13) or of a PostfixExpression(11.3) - checkGrammarEvalOrArgumentsInStrictMode(node, node.left); - } var operator = node.operatorToken.kind; - if (operator === 53 /* EqualsToken */ && (node.left.kind === 155 /* ObjectLiteralExpression */ || node.left.kind === 154 /* ArrayLiteralExpression */)) { + if (operator === 53 /* EqualsToken */ && (node.left.kind === 157 /* ObjectLiteralExpression */ || node.left.kind === 156 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); @@ -19317,7 +19807,7 @@ var ts; if (ts.isFunctionLike(parent) && current === parent.body) { return false; } - else if (current.kind === 202 /* ClassDeclaration */ || current.kind === 175 /* ClassExpression */) { + else if (current.kind === 204 /* ClassDeclaration */ || current.kind === 177 /* ClassExpression */) { return true; } current = parent; @@ -19393,7 +19883,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 128 /* ComputedPropertyName */) { + if (node.name.kind === 129 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); @@ -19404,7 +19894,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 128 /* ComputedPropertyName */) { + if (node.name.kind === 129 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -19425,10 +19915,6 @@ var ts; } return type; } - function checkExpression(node, contextualMapper) { - checkGrammarIdentifierInStrictMode(node); - return checkExpressionOrQualifiedName(node, contextualMapper); - } // Checks an expression and returns its type. The contextualMapper parameter serves two purposes: When // contextualMapper is not undefined and not equal to the identityMapper function object it indicates that the // expression is being inferentially typed (section 4.12.2 in spec) and provides the type mapper to use in @@ -19436,9 +19922,9 @@ var ts; // object, it serves as an indicator that all contained function and arrow expressions should be considered to // have the wildcard function type; this form of type check is used during overload resolution to exclude // contextually typed function and arrow expressions in the initial phase. - function checkExpressionOrQualifiedName(node, contextualMapper) { + function checkExpression(node, contextualMapper) { var type; - if (node.kind == 127 /* QualifiedName */) { + if (node.kind === 128 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -19450,9 +19936,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 156 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 157 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 65 /* Identifier */ || node.kind === 127 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 158 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 159 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 65 /* Identifier */ || node.kind === 128 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -19479,61 +19965,60 @@ var ts; return booleanType; case 7 /* NumericLiteral */: return checkNumericLiteral(node); - case 172 /* TemplateExpression */: + case 174 /* TemplateExpression */: return checkTemplateExpression(node); case 8 /* StringLiteral */: case 10 /* NoSubstitutionTemplateLiteral */: return stringType; case 9 /* RegularExpressionLiteral */: return globalRegExpType; - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 155 /* ObjectLiteralExpression */: + case 157 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 156 /* PropertyAccessExpression */: + case 158 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 157 /* ElementAccessExpression */: + case 159 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: return checkCallExpression(node); - case 160 /* TaggedTemplateExpression */: + case 162 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: return checkTypeAssertion(node); - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 175 /* ClassExpression */: + case 177 /* ClassExpression */: return checkClassExpression(node); - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 166 /* TypeOfExpression */: + case 168 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 165 /* DeleteExpression */: + case 167 /* DeleteExpression */: return checkDeleteExpression(node); - case 167 /* VoidExpression */: + case 169 /* VoidExpression */: return checkVoidExpression(node); - case 168 /* PrefixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 169 /* PostfixUnaryExpression */: + case 171 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 174 /* SpreadElementExpression */: + case 176 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 176 /* OmittedExpression */: + case 178 /* OmittedExpression */: return undefinedType; - case 173 /* YieldExpression */: + case 175 /* YieldExpression */: return checkYieldExpression(node); } return unknownType; } // DECLARATION AND STATEMENT TYPE CHECKING function checkTypeParameter(node) { - checkGrammarDeclarationNameInStrictMode(node); // Grammar Checking if (node.expression) { grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); @@ -19550,15 +20035,13 @@ var ts; // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the // Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code // or if its FunctionBody is strict code(11.1.5). - // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a - // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEvalOrArgumentsInStrictMode(node, node.name); + checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (node.flags & 112 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 136 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 137 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -19575,33 +20058,107 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 135 /* MethodDeclaration */ || - node.kind === 201 /* FunctionDeclaration */ || - node.kind === 163 /* FunctionExpression */; + return node.kind === 136 /* MethodDeclaration */ || + node.kind === 203 /* FunctionDeclaration */ || + node.kind === 165 /* FunctionExpression */; + } + function getTypePredicateParameterIndex(parameterList, parameter) { + if (parameterList) { + for (var i = 0; i < parameterList.length; i++) { + var param = parameterList[i]; + if (param.name.kind === 65 /* Identifier */ && + param.name.text === parameter.text) { + return i; + } + } + } + return -1; + } + function isInLegalTypePredicatePosition(node) { + switch (node.parent.kind) { + case 166 /* ArrowFunction */: + case 140 /* CallSignature */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 145 /* FunctionType */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + return node === node.parent.type; + } + return false; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 141 /* IndexSignature */) { + if (node.kind === 142 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 143 /* FunctionType */ || node.kind === 201 /* FunctionDeclaration */ || node.kind === 144 /* ConstructorType */ || - node.kind === 139 /* CallSignature */ || node.kind === 136 /* Constructor */ || - node.kind === 140 /* ConstructSignature */) { + else if (node.kind === 145 /* FunctionType */ || node.kind === 203 /* FunctionDeclaration */ || node.kind === 146 /* ConstructorType */ || + node.kind === 140 /* CallSignature */ || node.kind === 137 /* Constructor */ || + node.kind === 141 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - checkSourceElement(node.type); + if (node.type.kind === 143 /* TypePredicate */) { + var typePredicate = getSignatureFromDeclaration(node).typePredicate; + var typePredicateNode = node.type; + if (isInLegalTypePredicatePosition(typePredicateNode)) { + if (typePredicate.parameterIndex >= 0) { + if (node.parameters[typePredicate.parameterIndex].dotDotDotToken) { + error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); + } + else { + checkTypeAssignableTo(typePredicate.type, getTypeAtLocation(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); + } + } + else if (typePredicateNode.parameterName) { + var hasReportedError = false; + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var param = _a[_i]; + if (hasReportedError) { + break; + } + if (param.name.kind === 153 /* ObjectBindingPattern */ || + param.name.kind === 154 /* ArrayBindingPattern */) { + (function checkBindingPattern(pattern) { + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.name.kind === 65 /* Identifier */ && + element.name.text === typePredicate.parameterName) { + error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); + hasReportedError = true; + break; + } + else if (element.name.kind === 154 /* ArrayBindingPattern */ || + element.name.kind === 153 /* ObjectBindingPattern */) { + checkBindingPattern(element.name); + } + } + })(param.name); + } + } + if (!hasReportedError) { + error(typePredicateNode.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName); + } + } + } + else { + error(typePredicateNode, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + } + } + else { + checkSourceElement(node.type); + } } if (produceDiagnostics) { checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 140 /* ConstructSignature */: + case 141 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 139 /* CallSignature */: + case 140 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -19629,7 +20186,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 203 /* InterfaceDeclaration */) { + if (node.kind === 205 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -19649,7 +20206,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 122 /* StringKeyword */: + case 123 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -19657,7 +20214,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 120 /* NumberKeyword */: + case 121 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -19701,17 +20258,17 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 158 /* CallExpression */ && n.expression.kind === 91 /* SuperKeyword */; + return n.kind === 160 /* CallExpression */ && n.expression.kind === 91 /* SuperKeyword */; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 163 /* FunctionExpression */: - case 201 /* FunctionDeclaration */: - case 164 /* ArrowFunction */: - case 155 /* ObjectLiteralExpression */: return false; + case 165 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: + case 166 /* ArrowFunction */: + case 157 /* ObjectLiteralExpression */: return false; default: return ts.forEachChild(n, containsSuperCall); } } @@ -19719,12 +20276,12 @@ var ts; if (n.kind === 93 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 163 /* FunctionExpression */ && n.kind !== 201 /* FunctionDeclaration */) { + else if (n.kind !== 165 /* FunctionExpression */ && n.kind !== 203 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 133 /* PropertyDeclaration */ && + return n.kind === 134 /* PropertyDeclaration */ && !(n.flags & 128 /* Static */) && !!n.initializer; } @@ -19741,7 +20298,7 @@ var ts; ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 183 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 185 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -19759,7 +20316,7 @@ var ts; if (produceDiagnostics) { // Grammar checking accessors checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 137 /* GetAccessor */) { + if (node.kind === 138 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } @@ -19767,7 +20324,7 @@ var ts; if (!ts.hasDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 137 /* GetAccessor */ ? 138 /* SetAccessor */ : 137 /* GetAccessor */; + var otherKind = node.kind === 138 /* GetAccessor */ ? 139 /* SetAccessor */ : 138 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { @@ -19791,28 +20348,27 @@ var ts; function checkMissingDeclaration(node) { checkDecorators(node); } + function checkTypeArgumentConstraints(typeParameters, typeArguments) { + var result = true; + for (var i = 0; i < typeParameters.length; i++) { + var constraint = getConstraintOfTypeParameter(typeParameters[i]); + if (constraint) { + var typeArgument = typeArguments[i]; + result = result && checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, typeArgument, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + } + } + return result; + } function checkTypeReferenceNode(node) { - checkGrammarTypeReferenceInStrictMode(node.typeName); - return checkTypeReferenceOrExpressionWithTypeArguments(node); - } - function checkExpressionWithTypeArguments(node) { - checkGrammarExpressionWithTypeArgumentsInStrictMode(node.expression); - return checkTypeReferenceOrExpressionWithTypeArguments(node); - } - function checkTypeReferenceOrExpressionWithTypeArguments(node) { - // Grammar checking checkGrammarTypeArguments(node, node.typeArguments); - var type = getTypeFromTypeReferenceOrExpressionWithTypeArguments(node); + var type = getTypeFromTypeReference(node); if (type !== unknownType && node.typeArguments) { // Do type argument local checks only if referenced type is successfully resolved - var len = node.typeArguments.length; - for (var i = 0; i < len; i++) { - checkSourceElement(node.typeArguments[i]); - var constraint = getConstraintOfTypeParameter(type.target.typeParameters[i]); - if (produceDiagnostics && constraint) { - var typeArgument = type.typeArguments[i]; - checkTypeAssignableTo(typeArgument, constraint, node, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); - } + ts.forEach(node.typeArguments, checkSourceElement); + if (produceDiagnostics) { + var symbol = getNodeLinks(node).resolvedSymbol; + var typeParameters = symbol.flags & 524288 /* TypeAlias */ ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; + checkTypeArgumentConstraints(typeParameters, node.typeArguments); } } } @@ -19864,9 +20420,9 @@ var ts; var signaturesToCheck; // Unnamed (call\construct) signatures in interfaces are inherited and not shadowed so examining just node symbol won't give complete answer. // Use declaring type to obtain full list of signatures. - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 203 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 139 /* CallSignature */ || signatureDeclarationNode.kind === 140 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 139 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 205 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 140 /* CallSignature */ || signatureDeclarationNode.kind === 141 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 140 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -19884,7 +20440,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 203 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 205 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported flags |= 1 /* Export */; @@ -19967,7 +20523,7 @@ var ts; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members - ts.Debug.assert(node.kind === 135 /* MethodDeclaration */ || node.kind === 134 /* MethodSignature */); + ts.Debug.assert(node.kind === 136 /* MethodDeclaration */ || node.kind === 135 /* MethodSignature */); ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -19996,7 +20552,7 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 203 /* InterfaceDeclaration */ || node.parent.kind === 146 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 205 /* InterfaceDeclaration */ || node.parent.kind === 148 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -20007,7 +20563,7 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 201 /* FunctionDeclaration */ || node.kind === 135 /* MethodDeclaration */ || node.kind === 134 /* MethodSignature */ || node.kind === 136 /* Constructor */) { + if (node.kind === 203 /* FunctionDeclaration */ || node.kind === 136 /* MethodDeclaration */ || node.kind === 135 /* MethodSignature */ || node.kind === 137 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -20130,16 +20686,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return d.name.kind === 8 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -20154,23 +20710,23 @@ var ts; var expression = node.expression; var exprType = checkExpression(expression); switch (node.parent.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); var classDecoratorType = instantiateSingleCallFunctionType(getGlobalClassDecoratorType(), [classConstructorType]); checkTypeAssignableTo(exprType, classDecoratorType, node); break; - case 133 /* PropertyDeclaration */: + case 134 /* PropertyDeclaration */: checkTypeAssignableTo(exprType, getGlobalPropertyDecoratorType(), node); break; - case 135 /* MethodDeclaration */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 136 /* MethodDeclaration */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var methodDecoratorType = instantiateSingleCallFunctionType(getGlobalMethodDecoratorType(), [methodType]); checkTypeAssignableTo(exprType, methodDecoratorType, node); break; - case 130 /* Parameter */: + case 131 /* Parameter */: checkTypeAssignableTo(exprType, getGlobalParameterDecoratorType(), node); break; } @@ -20180,14 +20736,14 @@ var ts; // When we are emitting type metadata for decorators, we need to try to check the type // as if it were an expression so that we can emit the type in a value position when we // serialize the type metadata. - if (node && node.kind === 142 /* TypeReference */) { + if (node && node.kind === 144 /* TypeReference */) { var type = getTypeFromTypeNode(node); var shouldCheckIfUnknownType = type === unknownType && compilerOptions.isolatedModules; if (!type || (!shouldCheckIfUnknownType && type.flags & (2097279 /* Intrinsic */ | 132 /* NumberLike */ | 258 /* StringLike */))) { return; } if (shouldCheckIfUnknownType || type.symbol.valueDeclaration) { - checkExpressionOrQualifiedName(node.typeName); + checkExpression(node.typeName); } } } @@ -20197,19 +20753,19 @@ var ts; */ function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 133 /* PropertyDeclaration */: + case 134 /* PropertyDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 130 /* Parameter */: + case 131 /* Parameter */: checkTypeNodeAsExpression(node.type); break; - case 135 /* MethodDeclaration */: + case 136 /* MethodDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 137 /* GetAccessor */: + case 138 /* GetAccessor */: checkTypeNodeAsExpression(node.type); break; - case 138 /* SetAccessor */: + case 139 /* SetAccessor */: checkTypeNodeAsExpression(getSetAccessorTypeAnnotationNode(node)); break; } @@ -20238,47 +20794,44 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 135 /* MethodDeclaration */: + case 136 /* MethodDeclaration */: checkParameterTypeAnnotationsAsExpressions(node); // fall-through - case 138 /* SetAccessor */: - case 137 /* GetAccessor */: - case 133 /* PropertyDeclaration */: - case 130 /* Parameter */: + case 139 /* SetAccessor */: + case 138 /* GetAccessor */: + case 134 /* PropertyDeclaration */: + case 131 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 130 /* Parameter */) { + if (node.kind === 131 /* Parameter */) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); } function checkFunctionDeclaration(node) { if (produceDiagnostics) { - checkFunctionLikeDeclaration(node) || - checkGrammarFunctionName(node.name) || - checkGrammarForGenerator(node); + checkFunctionLikeDeclaration(node) || checkGrammarForGenerator(node); checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); } } function checkFunctionLikeDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSignatureDeclaration(node); // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 128 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 129 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -20322,11 +20875,11 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 180 /* Block */) { + if (node.kind === 182 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 207 /* ModuleBlock */) { + if (ts.isFunctionBlock(node) || node.kind === 209 /* ModuleBlock */) { checkFunctionExpressionBodies(node); } } @@ -20345,12 +20898,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 133 /* PropertyDeclaration */ || - node.kind === 132 /* PropertySignature */ || - node.kind === 135 /* MethodDeclaration */ || - node.kind === 134 /* MethodSignature */ || - node.kind === 137 /* GetAccessor */ || - node.kind === 138 /* SetAccessor */) { + if (node.kind === 134 /* PropertyDeclaration */ || + node.kind === 133 /* PropertySignature */ || + node.kind === 136 /* MethodDeclaration */ || + node.kind === 135 /* MethodSignature */ || + node.kind === 138 /* GetAccessor */ || + node.kind === 139 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -20359,7 +20912,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 130 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 131 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -20392,7 +20945,7 @@ var ts; return; } // bubble up and find containing type - var enclosingClass = ts.getAncestor(node, 202 /* ClassDeclaration */); + var enclosingClass = ts.getAncestor(node, 204 /* ClassDeclaration */); // if containing type was not found or it is ambient - exit (no codegen) if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { return; @@ -20412,12 +20965,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 206 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 208 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 228 /* SourceFile */ && ts.isExternalModule(parent)) { + if (parent.kind === 230 /* SourceFile */ && ts.isExternalModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -20452,7 +21005,7 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 199 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 201 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -20462,17 +21015,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 12288 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 200 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 181 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 202 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 183 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 180 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 207 /* ModuleBlock */ || - container.kind === 206 /* ModuleDeclaration */ || - container.kind === 228 /* SourceFile */); + (container.kind === 182 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 209 /* ModuleBlock */ || + container.kind === 208 /* ModuleDeclaration */ || + container.kind === 230 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -20487,7 +21040,7 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 130 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 131 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -20498,7 +21051,7 @@ var ts; // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name and if this entry matches the resolved symbol if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 130 /* Parameter */) { + if (referencedSymbol.valueDeclaration.kind === 131 /* Parameter */) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -20518,14 +21071,13 @@ var ts; } // Check variable, parameter, or property declaration function checkVariableLikeDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSourceElement(node.type); // For a computed property, just check the initializer and exit // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 128 /* ComputedPropertyName */) { + if (node.name.kind === 129 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -20536,7 +21088,7 @@ var ts; ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 130 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 131 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -20568,10 +21120,10 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 133 /* PropertyDeclaration */ && node.kind !== 132 /* PropertySignature */) { + if (node.kind !== 134 /* PropertyDeclaration */ && node.kind !== 133 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 199 /* VariableDeclaration */ || node.kind === 153 /* BindingElement */) { + if (node.kind === 201 /* VariableDeclaration */ || node.kind === 155 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -20601,7 +21153,7 @@ var ts; } function inBlockOrObjectLiteralExpression(node) { while (node) { - if (node.kind === 180 /* Block */ || node.kind === 155 /* ObjectLiteralExpression */) { + if (node.kind === 182 /* Block */ || node.kind === 157 /* ObjectLiteralExpression */) { return true; } node = node.parent; @@ -20634,12 +21186,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind == 200 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 202 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 200 /* VariableDeclarationList */) { + if (node.initializer.kind === 202 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -20659,14 +21211,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 200 /* VariableDeclarationList */) { + if (node.initializer.kind === 202 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); // There may be a destructuring assignment on the left side - if (varExpr.kind === 154 /* ArrayLiteralExpression */ || varExpr.kind === 155 /* ObjectLiteralExpression */) { + if (varExpr.kind === 156 /* ArrayLiteralExpression */ || varExpr.kind === 157 /* ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -20695,7 +21247,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 200 /* VariableDeclarationList */) { + if (node.initializer.kind === 202 /* VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -20709,7 +21261,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 154 /* ArrayLiteralExpression */ || varExpr.kind === 155 /* ObjectLiteralExpression */) { + if (varExpr.kind === 156 /* ArrayLiteralExpression */ || varExpr.kind === 157 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */)) { @@ -20948,7 +21500,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 137 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 138 /* SetAccessor */))); + return !!(node.kind === 138 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 139 /* SetAccessor */))); } function checkReturnStatement(node) { // Grammar checking @@ -20961,7 +21513,8 @@ var ts; if (node.expression) { var func = ts.getContainingFunction(node); if (func) { - var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); + var signature = getSignatureFromDeclaration(func); + var returnType = getReturnTypeOfSignature(signature); var exprType = checkExpressionCached(node.expression); if (func.asteriskToken) { // A generator does not need its return expressions checked against its return type. @@ -20970,27 +21523,22 @@ var ts; // for generators. return; } - if (func.kind === 138 /* SetAccessor */) { + if (func.kind === 139 /* SetAccessor */) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 136 /* Constructor */) { + else if (func.kind === 137 /* Constructor */) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } - else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func)) { + else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { checkTypeAssignableTo(exprType, returnType, node.expression, undefined); } } } } function checkWithStatement(node) { - // Grammar checking for withStatement - if (!checkGrammarStatementInAmbientContext(node)) { - if (node.parserContextFlags & 1 /* StrictMode */) { - grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); - } - } + checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); } @@ -21002,7 +21550,7 @@ var ts; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 222 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 224 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -21014,7 +21562,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 221 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 223 /* CaseClause */) { var caseClause = clause; // TypeScript 1.0 spec (April 2014):5.9 // In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from the type of the 'switch' expression. @@ -21035,7 +21583,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 195 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 197 /* LabeledStatement */ && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -21083,9 +21631,6 @@ var ts; grammarErrorOnNode(localSymbol.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); } } - // It is a SyntaxError if a TryStatement with a Catch occurs within strict code and the Identifier of the - // Catch production is eval or arguments - checkGrammarEvalOrArgumentsInStrictMode(node, catchClause.variableDeclaration.name); } } checkBlock(catchClause.block); @@ -21105,7 +21650,7 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); }); - if (type.flags & 1024 /* Class */ && type.symbol.valueDeclaration.kind === 202 /* ClassDeclaration */) { + if (type.flags & 1024 /* Class */ && type.symbol.valueDeclaration.kind === 204 /* ClassDeclaration */) { var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -21143,7 +21688,7 @@ var ts; // perform property check if property or indexer is declared in 'type' // this allows to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (prop.valueDeclaration.name.kind === 128 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 129 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -21199,7 +21744,6 @@ var ts; return unknownType; } function checkClassDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node); // Grammar checking if (!node.name && !(node.flags & 256 /* Default */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); @@ -21218,36 +21762,42 @@ var ts; var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - if (!ts.isSupportedExpressionWithTypeArguments(baseTypeNode)) { - error(baseTypeNode.expression, ts.Diagnostics.Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses); - } emitExtends = emitExtends || !ts.isInAmbientContext(node); - checkExpressionWithTypeArguments(baseTypeNode); - } - var baseTypes = getBaseTypes(type); - if (baseTypes.length) { - if (produceDiagnostics) { + var baseTypes = getBaseTypes(type); + if (baseTypes.length && produceDiagnostics) { var baseType = baseTypes[0]; + var staticBaseType = getBaseConstructorTypeOfClass(type); + if (baseTypeNode.typeArguments) { + ts.forEach(baseTypeNode.typeArguments, checkSourceElement); + for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { + var constructor = _a[_i]; + if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { + break; + } + } + } checkTypeAssignableTo(type, baseType, node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); - var staticBaseType = getTypeOfSymbol(baseType.symbol); - checkTypeAssignableTo(staticType, getTypeWithoutConstructors(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseType.symbol !== resolveEntityName(baseTypeNode.expression, 107455 /* Value */)) { - error(baseTypeNode, ts.Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType)); + checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */)) { + // When the static base type is a "class-like" constructor function (but not actually a class), we verify + // that all instantiated base constructor signatures return the same type. We can simply compare the type + // references (as opposed to checking the structure of the types) because elsewhere we have already checked + // that the base type is a class or interface type (and not, for example, an anonymous object type). + var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); + if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType; })) { + error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); + } } checkKindsOfPropertyMemberOverrides(type, baseType); } } - if (baseTypes.length || (baseTypeNode && compilerOptions.isolatedModules)) { - // Check that base type can be evaluated as expression - checkExpressionOrQualifiedName(baseTypeNode.expression); - } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { ts.forEach(implementedTypeNodes, function (typeRefNode) { if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } - checkExpressionWithTypeArguments(typeRefNode); + checkTypeReferenceNode(typeRefNode); if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { @@ -21335,7 +21885,7 @@ var ts; } } function isAccessor(kind) { - return kind === 137 /* GetAccessor */ || kind === 138 /* SetAccessor */; + return kind === 138 /* GetAccessor */ || kind === 139 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -21399,13 +21949,13 @@ var ts; } function checkInterfaceDeclaration(node) { // Grammar checking - checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); checkTypeParameters(node.typeParameters); if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 203 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 205 /* InterfaceDeclaration */); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -21427,7 +21977,7 @@ var ts; if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) { error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments); } - checkExpressionWithTypeArguments(heritageElement); + checkTypeReferenceNode(heritageElement); }); ts.forEach(node.members, checkSourceElement); if (produceDiagnostics) { @@ -21449,7 +21999,7 @@ var ts; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 128 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 129 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; @@ -21489,7 +22039,7 @@ var ts; return evalConstant(initializer); function evalConstant(e) { switch (e.kind) { - case 168 /* PrefixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: var value = evalConstant(e.operand); if (value === undefined) { return undefined; @@ -21500,7 +22050,7 @@ var ts; case 47 /* TildeToken */: return ~value; } return undefined; - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -21525,11 +22075,11 @@ var ts; return undefined; case 7 /* NumericLiteral */: return +e.text; - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return evalConstant(e.expression); case 65 /* Identifier */: - case 157 /* ElementAccessExpression */: - case 156 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + case 158 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType; @@ -21542,7 +22092,7 @@ var ts; } else { var expression; - if (e.kind === 157 /* ElementAccessExpression */) { + if (e.kind === 159 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 8 /* StringLiteral */) { return undefined; @@ -21560,7 +22110,7 @@ var ts; if (current.kind === 65 /* Identifier */) { break; } - else if (current.kind === 156 /* PropertyAccessExpression */) { + else if (current.kind === 158 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -21599,7 +22149,7 @@ var ts; return; } // Grammar checking - checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -21629,7 +22179,7 @@ var ts; var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 205 /* EnumDeclaration */) { + if (declaration.kind !== 207 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -21652,8 +22202,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 202 /* ClassDeclaration */ || - (declaration.kind === 201 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 204 /* ClassDeclaration */ || + (declaration.kind === 203 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -21676,7 +22226,15 @@ var ts; function checkModuleDeclaration(node) { if (produceDiagnostics) { // Grammar checking - if (!checkGrammarDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { + var isAmbientExternalModule = node.name.kind === 8 /* StringLiteral */; + var contextErrorMessage = isAmbientExternalModule + ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file + : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; + if (checkGrammarModuleElementContext(node, contextErrorMessage)) { + // If we hit a module declaration in an illegal context, just bail out to avoid cascading errors. + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { if (!ts.isInAmbientContext(node) && node.name.kind === 8 /* StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } @@ -21701,14 +22259,14 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 202 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 204 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 2048 /* LexicalModuleMergesWithClass */; } } // Checks for ambient external modules. - if (node.name.kind === 8 /* StringLiteral */) { + if (isAmbientExternalModule) { if (!isGlobalSourceFile(node.parent)) { error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules); } @@ -21721,10 +22279,10 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 127 /* QualifiedName */) { + if (node.kind === 128 /* QualifiedName */) { node = node.left; } - else if (node.kind === 156 /* PropertyAccessExpression */) { + else if (node.kind === 158 /* PropertyAccessExpression */) { node = node.expression; } else { @@ -21740,9 +22298,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 207 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 228 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 216 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 209 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; + if (node.parent.kind !== 230 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 218 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -21765,7 +22323,7 @@ var ts; (symbol.flags & 793056 /* Type */ ? 793056 /* Type */ : 0) | (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 218 /* ExportSpecifier */ ? + var message = node.kind === 220 /* ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -21778,7 +22336,11 @@ var ts; checkAliasSymbol(node); } function checkImportDeclaration(node) { - if (!checkGrammarImportDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { + // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -21788,7 +22350,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 212 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 214 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -21799,7 +22361,11 @@ var ts; } } function checkImportEqualsDeclaration(node) { - checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node); + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { + // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. + return; + } + checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); if (node.flags & 1 /* Export */) { @@ -21829,6 +22395,10 @@ var ts; } } function checkExportDeclaration(node) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { + // If we hit an export in an illegal context, just bail out to avoid cascading errors. + return; + } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } @@ -21837,8 +22407,8 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 207 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 228 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 209 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; + if (node.parent.kind !== 230 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -21851,6 +22421,11 @@ var ts; } } } + function checkGrammarModuleElementContext(node, errorMessage) { + if (node.parent.kind !== 230 /* SourceFile */ && node.parent.kind !== 209 /* ModuleBlock */ && node.parent.kind !== 208 /* ModuleDeclaration */) { + return grammarErrorOnFirstToken(node, errorMessage); + } + } function checkExportSpecifier(node) { checkAliasSymbol(node); if (!node.parent.parent.moduleSpecifier) { @@ -21858,8 +22433,12 @@ var ts; } } function checkExportAssignment(node) { - var container = node.parent.kind === 228 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 206 /* ModuleDeclaration */ && container.name.kind === 65 /* Identifier */) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { + // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. + return; + } + var container = node.parent.kind === 230 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 208 /* ModuleDeclaration */ && container.name.kind === 65 /* Identifier */) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -21886,10 +22465,10 @@ var ts; } } function getModuleStatements(node) { - if (node.kind === 228 /* SourceFile */) { + if (node.kind === 230 /* SourceFile */) { return node.statements; } - if (node.kind === 206 /* ModuleDeclaration */ && node.body.kind === 207 /* ModuleBlock */) { + if (node.kind === 208 /* ModuleDeclaration */ && node.body.kind === 209 /* ModuleBlock */) { return node.body.statements; } return emptyArray; @@ -21914,111 +22493,118 @@ var ts; links.exportsChecked = true; } } + function checkTypePredicate(node) { + if (!isInLegalTypePredicatePosition(node)) { + error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + } + } function checkSourceElement(node) { if (!node) return; switch (node.kind) { - case 129 /* TypeParameter */: + case 130 /* TypeParameter */: return checkTypeParameter(node); - case 130 /* Parameter */: + case 131 /* Parameter */: return checkParameter(node); - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return checkPropertyDeclaration(node); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 141 /* IndexSignature */: + case 142 /* IndexSignature */: return checkSignatureDeclaration(node); - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return checkMethodDeclaration(node); - case 136 /* Constructor */: + case 137 /* Constructor */: return checkConstructorDeclaration(node); - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: return checkAccessorDeclaration(node); - case 142 /* TypeReference */: + case 144 /* TypeReference */: return checkTypeReferenceNode(node); - case 145 /* TypeQuery */: + case 143 /* TypePredicate */: + return checkTypePredicate(node); + case 147 /* TypeQuery */: return checkTypeQuery(node); - case 146 /* TypeLiteral */: + case 148 /* TypeLiteral */: return checkTypeLiteral(node); - case 147 /* ArrayType */: + case 149 /* ArrayType */: return checkArrayType(node); - case 148 /* TupleType */: + case 150 /* TupleType */: return checkTupleType(node); - case 149 /* UnionType */: + case 151 /* UnionType */: return checkUnionType(node); - case 150 /* ParenthesizedType */: + case 152 /* ParenthesizedType */: return checkSourceElement(node.type); - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 180 /* Block */: - case 207 /* ModuleBlock */: + case 182 /* Block */: + case 209 /* ModuleBlock */: return checkBlock(node); - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: return checkVariableStatement(node); - case 183 /* ExpressionStatement */: + case 185 /* ExpressionStatement */: return checkExpressionStatement(node); - case 184 /* IfStatement */: + case 186 /* IfStatement */: return checkIfStatement(node); - case 185 /* DoStatement */: + case 187 /* DoStatement */: return checkDoStatement(node); - case 186 /* WhileStatement */: + case 188 /* WhileStatement */: return checkWhileStatement(node); - case 187 /* ForStatement */: + case 189 /* ForStatement */: return checkForStatement(node); - case 188 /* ForInStatement */: + case 190 /* ForInStatement */: return checkForInStatement(node); - case 189 /* ForOfStatement */: + case 191 /* ForOfStatement */: return checkForOfStatement(node); - case 190 /* ContinueStatement */: - case 191 /* BreakStatement */: + case 192 /* ContinueStatement */: + case 193 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 192 /* ReturnStatement */: + case 194 /* ReturnStatement */: return checkReturnStatement(node); - case 193 /* WithStatement */: + case 195 /* WithStatement */: return checkWithStatement(node); - case 194 /* SwitchStatement */: + case 196 /* SwitchStatement */: return checkSwitchStatement(node); - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: return checkLabeledStatement(node); - case 196 /* ThrowStatement */: + case 198 /* ThrowStatement */: return checkThrowStatement(node); - case 197 /* TryStatement */: + case 199 /* TryStatement */: return checkTryStatement(node); - case 199 /* VariableDeclaration */: + case 201 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 153 /* BindingElement */: + case 155 /* BindingElement */: return checkBindingElement(node); - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: return checkClassDeclaration(node); - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 204 /* TypeAliasDeclaration */: + case 206 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: return checkImportDeclaration(node); - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: return checkExportDeclaration(node); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return checkExportAssignment(node); - case 182 /* EmptyStatement */: + case 184 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 198 /* DebuggerStatement */: + case 200 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 219 /* MissingDeclaration */: + case 221 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -22033,83 +22619,83 @@ var ts; // Delaying the type check of the body ensures foo has been assigned a type. function checkFunctionExpressionBodies(node) { switch (node.kind) { - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: ts.forEach(node.parameters, checkFunctionExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: ts.forEach(node.decorators, checkFunctionExpressionBodies); ts.forEach(node.parameters, checkFunctionExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 201 /* FunctionDeclaration */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 203 /* FunctionDeclaration */: ts.forEach(node.parameters, checkFunctionExpressionBodies); break; - case 193 /* WithStatement */: + case 195 /* WithStatement */: checkFunctionExpressionBodies(node.expression); break; - case 131 /* Decorator */: - case 130 /* Parameter */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 151 /* ObjectBindingPattern */: - case 152 /* ArrayBindingPattern */: - case 153 /* BindingElement */: - case 154 /* ArrayLiteralExpression */: - case 155 /* ObjectLiteralExpression */: - case 225 /* PropertyAssignment */: - case 156 /* PropertyAccessExpression */: - case 157 /* ElementAccessExpression */: - case 158 /* CallExpression */: - case 159 /* NewExpression */: - case 160 /* TaggedTemplateExpression */: - case 172 /* TemplateExpression */: - case 178 /* TemplateSpan */: - case 161 /* TypeAssertionExpression */: - case 162 /* ParenthesizedExpression */: - case 166 /* TypeOfExpression */: - case 167 /* VoidExpression */: - case 165 /* DeleteExpression */: - case 168 /* PrefixUnaryExpression */: - case 169 /* PostfixUnaryExpression */: - case 170 /* BinaryExpression */: - case 171 /* ConditionalExpression */: - case 174 /* SpreadElementExpression */: - case 180 /* Block */: - case 207 /* ModuleBlock */: - case 181 /* VariableStatement */: - case 183 /* ExpressionStatement */: - case 184 /* IfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 190 /* ContinueStatement */: - case 191 /* BreakStatement */: - case 192 /* ReturnStatement */: - case 194 /* SwitchStatement */: - case 208 /* CaseBlock */: - case 221 /* CaseClause */: - case 222 /* DefaultClause */: - case 195 /* LabeledStatement */: - case 196 /* ThrowStatement */: - case 197 /* TryStatement */: - case 224 /* CatchClause */: - case 199 /* VariableDeclaration */: - case 200 /* VariableDeclarationList */: - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: - case 227 /* EnumMember */: - case 215 /* ExportAssignment */: - case 228 /* SourceFile */: + case 132 /* Decorator */: + case 131 /* Parameter */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 153 /* ObjectBindingPattern */: + case 154 /* ArrayBindingPattern */: + case 155 /* BindingElement */: + case 156 /* ArrayLiteralExpression */: + case 157 /* ObjectLiteralExpression */: + case 227 /* PropertyAssignment */: + case 158 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: + case 162 /* TaggedTemplateExpression */: + case 174 /* TemplateExpression */: + case 180 /* TemplateSpan */: + case 163 /* TypeAssertionExpression */: + case 164 /* ParenthesizedExpression */: + case 168 /* TypeOfExpression */: + case 169 /* VoidExpression */: + case 167 /* DeleteExpression */: + case 170 /* PrefixUnaryExpression */: + case 171 /* PostfixUnaryExpression */: + case 172 /* BinaryExpression */: + case 173 /* ConditionalExpression */: + case 176 /* SpreadElementExpression */: + case 182 /* Block */: + case 209 /* ModuleBlock */: + case 183 /* VariableStatement */: + case 185 /* ExpressionStatement */: + case 186 /* IfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 192 /* ContinueStatement */: + case 193 /* BreakStatement */: + case 194 /* ReturnStatement */: + case 196 /* SwitchStatement */: + case 210 /* CaseBlock */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: + case 197 /* LabeledStatement */: + case 198 /* ThrowStatement */: + case 199 /* TryStatement */: + case 226 /* CatchClause */: + case 201 /* VariableDeclaration */: + case 202 /* VariableDeclarationList */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 229 /* EnumMember */: + case 217 /* ExportAssignment */: + case 230 /* SourceFile */: ts.forEachChild(node, checkFunctionExpressionBodies); break; } @@ -22123,6 +22709,11 @@ var ts; function checkSourceFileWorker(node) { var links = getNodeLinks(node); if (!(links.flags & 1 /* TypeChecked */)) { + // Check whether the file has declared it is the default lib, + // and whether the user has specifically chosen to avoid checking it. + if (node.isDefaultLib && compilerOptions.skipDefaultLibCheck) { + return; + } // Grammar checking checkGrammarSourceFile(node); emitExtends = false; @@ -22172,7 +22763,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 193 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 195 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -22195,23 +22786,23 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 228 /* SourceFile */: + case 230 /* SourceFile */: if (!ts.isExternalModule(location)) { break; } - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: if (!(memberFlags & 128 /* Static */)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 163 /* FunctionExpression */: + case 165 /* FunctionExpression */: if (location.name) { copySymbol(location.symbol, meaning); } @@ -22249,22 +22840,22 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 228 /* SourceFile */: + case 230 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: if (!(memberFlags & 128 /* Static */)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 163 /* FunctionExpression */: + case 165 /* FunctionExpression */: if (location.name) { copySymbol(location.symbol, meaning); } @@ -22277,43 +22868,43 @@ var ts; return symbolsToArray(symbols); } function isTypeDeclarationName(name) { - return name.kind == 65 /* Identifier */ && + return name.kind === 65 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 129 /* TypeParameter */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 205 /* EnumDeclaration */: + case 130 /* TypeParameter */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 207 /* EnumDeclaration */: return true; } } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 127 /* QualifiedName */) { + while (node.parent && node.parent.kind === 128 /* QualifiedName */) { node = node.parent; } - return node.parent && node.parent.kind === 142 /* TypeReference */; + return node.parent && node.parent.kind === 144 /* TypeReference */; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 156 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 158 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 177 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 179 /* ExpressionWithTypeArguments */; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 127 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 128 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 209 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 211 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 215 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 217 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -22325,11 +22916,11 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 215 /* ExportAssignment */) { + if (entityName.parent.kind === 217 /* ExportAssignment */) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 156 /* PropertyAccessExpression */) { + if (entityName.kind !== 158 /* PropertyAccessExpression */) { if (isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); @@ -22339,7 +22930,7 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 177 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 179 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } @@ -22354,14 +22945,14 @@ var ts; var meaning = 107455 /* Value */ | 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 156 /* PropertyAccessExpression */) { + else if (entityName.kind === 158 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 127 /* QualifiedName */) { + else if (entityName.kind === 128 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -22370,7 +22961,7 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 142 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 144 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. meaning |= 8388608 /* Alias */; @@ -22389,14 +22980,14 @@ var ts; return getSymbolOfNode(node.parent); } if (node.kind === 65 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 215 /* ExportAssignment */ + return node.parent.kind === 217 /* ExportAssignment */ ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } switch (node.kind) { case 65 /* Identifier */: - case 156 /* PropertyAccessExpression */: - case 127 /* QualifiedName */: + case 158 /* PropertyAccessExpression */: + case 128 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 93 /* ThisKeyword */: case 91 /* SuperKeyword */: @@ -22405,7 +22996,7 @@ var ts; case 114 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 136 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 137 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -22414,14 +23005,14 @@ var ts; var moduleName; if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 210 /* ImportDeclaration */ || node.parent.kind === 216 /* ExportDeclaration */) && + ((node.parent.kind === 212 /* ImportDeclaration */ || node.parent.kind === 218 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } // Intentional fall-through case 7 /* NumericLiteral */: // index access - if (node.parent.kind == 157 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 159 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -22438,7 +23029,7 @@ var ts; // The function returns a value symbol of an identifier in the short-hand property assignment. // This is necessary as an identifier in short-hand property assignment can contains two meaning: // property name and property value. - if (location && location.kind === 226 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 228 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */); } return undefined; @@ -22454,6 +23045,11 @@ var ts; if (ts.isExpression(node)) { return getTypeOfExpression(node); } + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(node)) { + // A SyntaxKind.ExpressionWithTypeArguments is considered a type node, except when it occurs in the + // extends clause of a class. We handle that case here. + return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; + } if (isTypeDeclaration(node)) { // In this case, we call getSymbolOfNode instead of getSymbolInfo because it is a declaration var symbol = getSymbolOfNode(node); @@ -22517,93 +23113,92 @@ var ts; return [symbol]; } // Emitter support - function isExternalModuleSymbol(symbol) { - return symbol.flags & 512 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 228 /* SourceFile */; - } - function getAliasNameSubstitution(symbol, getGeneratedNameForNode) { - // If this is es6 or higher, just use the name of the export - // no need to qualify it. - if (languageVersion >= 2 /* ES6 */) { - return undefined; - } - var node = getDeclarationOfAliasSymbol(symbol); - if (node) { - if (node.kind === 211 /* ImportClause */) { - var defaultKeyword; - if (languageVersion === 0 /* ES3 */) { - defaultKeyword = "[\"default\"]"; - } - else { - defaultKeyword = ".default"; - } - return getGeneratedNameForNode(node.parent) + defaultKeyword; - } - if (node.kind === 214 /* ImportSpecifier */) { - var moduleName = getGeneratedNameForNode(node.parent.parent.parent); - var propertyName = node.propertyName || node.name; - return moduleName + "." + ts.unescapeIdentifier(propertyName.text); - } - } - } - function getExportNameSubstitution(symbol, location, getGeneratedNameForNode) { - if (isExternalModuleSymbol(symbol.parent)) { - // 1. If this is es6 or higher, just use the name of the export - // no need to qualify it. - // 2. export mechanism for System modules is different from CJS\AMD - // and it does not need qualifications for exports - if (languageVersion >= 2 /* ES6 */ || compilerOptions.module === 4 /* System */) { - return undefined; - } - return "exports." + ts.unescapeIdentifier(symbol.name); - } - var node = location; - var containerSymbol = getParentOfSymbol(symbol); - while (node) { - if ((node.kind === 206 /* ModuleDeclaration */ || node.kind === 205 /* EnumDeclaration */) && getSymbolOfNode(node) === containerSymbol) { - return getGeneratedNameForNode(node) + "." + ts.unescapeIdentifier(symbol.name); - } - node = node.parent; - } - } - function getExpressionNameSubstitution(node, getGeneratedNameForNode) { - var symbol = getNodeLinks(node).resolvedSymbol || (ts.isDeclarationName(node) ? getSymbolOfNode(node.parent) : undefined); + // When resolved as an expression identifier, if the given node references an exported entity, return the declaration + // node of the exported entity's container. Otherwise, return undefined. + function getReferencedExportContainer(node) { + var symbol = getReferencedValueSymbol(node); if (symbol) { - // Whan an identifier resolves to a parented symbol, it references an exported entity from - // another declaration of the same internal module. - if (symbol.parent) { - return getExportNameSubstitution(symbol, node.parent, getGeneratedNameForNode); + if (symbol.flags & 1048576 /* ExportValue */) { + // If we reference an exported entity within the same module declaration, then whether + // we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the + // kinds that we do NOT prefix. + var exportSymbol = getMergedSymbol(symbol.exportSymbol); + if (exportSymbol.flags & 944 /* ExportHasLocal */) { + return undefined; + } + symbol = exportSymbol; } - // If we reference an exported entity within the same module declaration, then whether - // we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the - // kinds that we do NOT prefix. - var exportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); - if (symbol !== exportSymbol && !(exportSymbol.flags & 944 /* ExportHasLocal */)) { - return getExportNameSubstitution(exportSymbol, node.parent, getGeneratedNameForNode); - } - // Named imports from ES6 import declarations are rewritten - if (symbol.flags & 8388608 /* Alias */) { - return getAliasNameSubstitution(symbol, getGeneratedNameForNode); + var parentSymbol = getParentOfSymbol(symbol); + if (parentSymbol) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 230 /* SourceFile */) { + return parentSymbol.valueDeclaration; + } + for (var n = node.parent; n; n = n.parent) { + if ((n.kind === 208 /* ModuleDeclaration */ || n.kind === 207 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { + return n; + } + } } } } + // When resolved as an expression identifier, if the given node references an import, return the declaration of + // that import. Otherwise, return undefined. + function getReferencedImportDeclaration(node) { + var symbol = getReferencedValueSymbol(node); + return symbol && symbol.flags & 8388608 /* Alias */ ? getDeclarationOfAliasSymbol(symbol) : undefined; + } + function isStatementWithLocals(node) { + switch (node.kind) { + case 182 /* Block */: + case 210 /* CaseBlock */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + return true; + } + return false; + } + function isNestedRedeclarationSymbol(symbol) { + if (symbol.flags & 418 /* BlockScoped */) { + var links = getSymbolLinks(symbol); + if (links.isNestedRedeclaration === undefined) { + var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); + links.isNestedRedeclaration = isStatementWithLocals(container) && + !!resolveName(container.parent, symbol.name, 107455 /* Value */, undefined, undefined); + } + return links.isNestedRedeclaration; + } + return false; + } + // When resolved as an expression identifier, if the given node references a nested block scoped entity with + // a name that hides an existing name, return the declaration of that entity. Otherwise, return undefined. + function getReferencedNestedRedeclaration(node) { + var symbol = getReferencedValueSymbol(node); + return symbol && isNestedRedeclarationSymbol(symbol) ? symbol.valueDeclaration : undefined; + } + // Return true if the given node is a declaration of a nested block scoped entity with a name that hides an + // existing name. + function isNestedRedeclaration(node) { + return isNestedRedeclarationSymbol(getSymbolOfNode(node)); + } function isValueAliasDeclaration(node) { switch (node.kind) { - case 209 /* ImportEqualsDeclaration */: - case 211 /* ImportClause */: - case 212 /* NamespaceImport */: - case 214 /* ImportSpecifier */: - case 218 /* ExportSpecifier */: + case 211 /* ImportEqualsDeclaration */: + case 213 /* ImportClause */: + case 214 /* NamespaceImport */: + case 216 /* ImportSpecifier */: + case 220 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return node.expression && node.expression.kind === 65 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 228 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 230 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -22661,7 +23256,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 227 /* EnumMember */) { + if (node.kind === 229 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -22674,10 +23269,13 @@ var ts; return undefined; } /** Serializes an EntityName (with substitutions) to an appropriate JS constructor value. Used by the __metadata decorator. */ - function serializeEntityName(node, getGeneratedNameForNode, fallbackPath) { + function serializeEntityName(node, fallbackPath) { if (node.kind === 65 /* Identifier */) { - var substitution = getExpressionNameSubstitution(node, getGeneratedNameForNode); - var text = substitution || node.text; + // TODO(ron.buckton): The getExpressionNameSubstitution function has been removed, but calling it + // here has no effect anyway as an identifier in a type name is not an expression. + // var substitution = getExpressionNameSubstitution(node, getGeneratedNameForNode); + // var text = substitution || (node).text; + var text = node.text; if (fallbackPath) { fallbackPath.push(text); } @@ -22686,15 +23284,15 @@ var ts; } } else { - var left = serializeEntityName(node.left, getGeneratedNameForNode, fallbackPath); - var right = serializeEntityName(node.right, getGeneratedNameForNode, fallbackPath); + var left = serializeEntityName(node.left, fallbackPath); + var right = serializeEntityName(node.right, fallbackPath); if (!fallbackPath) { return left + "." + right; } } } /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ - function serializeTypeReferenceNode(node, getGeneratedNameForNode) { + function serializeTypeReferenceNode(node) { // serialization of a TypeReferenceNode uses the following rules: // // * The serialized type of a TypeReference that is `void` is "void 0". @@ -22727,11 +23325,11 @@ var ts; } else if (type === unknownType) { var fallbackPath = []; - serializeEntityName(node.typeName, getGeneratedNameForNode, fallbackPath); + serializeEntityName(node.typeName, fallbackPath); return fallbackPath; } else if (type.symbol && type.symbol.valueDeclaration) { - return serializeEntityName(node.typeName, getGeneratedNameForNode); + return serializeEntityName(node.typeName); } else if (typeHasCallOrConstructSignatures(type)) { return "Function"; @@ -22739,7 +23337,7 @@ var ts; return "Object"; } /** Serializes a TypeNode to an appropriate JS constructor value. Used by the __metadata decorator. */ - function serializeTypeNode(node, getGeneratedNameForNode) { + function serializeTypeNode(node) { // serialization of a TypeNode uses the following rules: // // * The serialized type of `void` is "void 0" (undefined). @@ -22754,26 +23352,26 @@ var ts; switch (node.kind) { case 99 /* VoidKeyword */: return "void 0"; - case 150 /* ParenthesizedType */: - return serializeTypeNode(node.type, getGeneratedNameForNode); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: + case 152 /* ParenthesizedType */: + return serializeTypeNode(node.type); + case 145 /* FunctionType */: + case 146 /* ConstructorType */: return "Function"; - case 147 /* ArrayType */: - case 148 /* TupleType */: + case 149 /* ArrayType */: + case 150 /* TupleType */: return "Array"; case 113 /* BooleanKeyword */: return "Boolean"; - case 122 /* StringKeyword */: + case 123 /* StringKeyword */: case 8 /* StringLiteral */: return "String"; - case 120 /* NumberKeyword */: + case 121 /* NumberKeyword */: return "Number"; - case 142 /* TypeReference */: - return serializeTypeReferenceNode(node, getGeneratedNameForNode); - case 145 /* TypeQuery */: - case 146 /* TypeLiteral */: - case 149 /* UnionType */: + case 144 /* TypeReference */: + return serializeTypeReferenceNode(node); + case 147 /* TypeQuery */: + case 148 /* TypeLiteral */: + case 151 /* UnionType */: case 112 /* AnyKeyword */: break; default: @@ -22784,7 +23382,7 @@ var ts; return "Object"; } /** Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member. */ - function serializeTypeOfNode(node, getGeneratedNameForNode) { + function serializeTypeOfNode(node) { // serialization of the type of a declaration uses the following rules: // // * The serialized type of a ClassDeclaration is "Function" @@ -22796,11 +23394,11 @@ var ts; // // For rules on serializing type annotations, see `serializeTypeNode`. switch (node.kind) { - case 202 /* ClassDeclaration */: return "Function"; - case 133 /* PropertyDeclaration */: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 130 /* Parameter */: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 137 /* GetAccessor */: return serializeTypeNode(node.type, getGeneratedNameForNode); - case 138 /* SetAccessor */: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node), getGeneratedNameForNode); + case 204 /* ClassDeclaration */: return "Function"; + case 134 /* PropertyDeclaration */: return serializeTypeNode(node.type); + case 131 /* Parameter */: return serializeTypeNode(node.type); + case 138 /* GetAccessor */: return serializeTypeNode(node.type); + case 139 /* SetAccessor */: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node)); } if (ts.isFunctionLike(node)) { return "Function"; @@ -22808,7 +23406,7 @@ var ts; return "void 0"; } /** Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor. */ - function serializeParameterTypesOfNode(node, getGeneratedNameForNode) { + function serializeParameterTypesOfNode(node) { // serialization of parameter types uses the following rules: // // * If the declaration is a class, the parameters of the first constructor with a body are used. @@ -22817,7 +23415,7 @@ var ts; // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. if (node) { var valueDeclaration; - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -22832,19 +23430,19 @@ var ts; for (var i = 0; i < parameterCount; i++) { if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 147 /* ArrayType */) { + if (parameterType.kind === 149 /* ArrayType */) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 142 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 144 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { parameterType = undefined; } - result[i] = serializeTypeNode(parameterType, getGeneratedNameForNode); + result[i] = serializeTypeNode(parameterType); } else { - result[i] = serializeTypeOfNode(parameters[i], getGeneratedNameForNode); + result[i] = serializeTypeOfNode(parameters[i]); } } return result; @@ -22854,9 +23452,9 @@ var ts; return emptyArray; } /** Serializes the return type of function. Used by the __metadata decorator for a method. */ - function serializeReturnTypeOfNode(node, getGeneratedNameForNode) { + function serializeReturnTypeOfNode(node) { if (node && ts.isFunctionLike(node)) { - return serializeTypeNode(node.type, getGeneratedNameForNode); + return serializeTypeNode(node.type); } return "void 0"; } @@ -22879,25 +23477,25 @@ var ts; function hasGlobalName(name) { return ts.hasProperty(globals, name); } - function resolvesToSomeValue(location, name) { - ts.Debug.assert(!ts.nodeIsSynthesized(location), "resolvesToSomeValue called with a synthesized location"); - return !!resolveName(location, name, 107455 /* Value */, undefined, undefined); + function getReferencedValueSymbol(reference) { + return getNodeLinks(reference).resolvedSymbol || + resolveName(reference, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, + /*nodeNotFoundMessage*/ undefined, undefined); } function getReferencedValueDeclaration(reference) { ts.Debug.assert(!ts.nodeIsSynthesized(reference)); - var symbol = getNodeLinks(reference).resolvedSymbol || - resolveName(reference, reference.text, 107455 /* Value */ | 8388608 /* Alias */, undefined, undefined); + var symbol = getReferencedValueSymbol(reference); return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 153 /* BindingElement */ || (n.parent.kind === 199 /* VariableDeclaration */ && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 155 /* BindingElement */ || (n.parent.kind === 201 /* VariableDeclaration */ && n.parent.name === n); var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, undefined, undefined); var isLetOrConst = symbol && (symbol.flags & 2 /* BlockScopedVariable */) && - symbol.valueDeclaration.parent.kind !== 224 /* CatchClause */; + symbol.valueDeclaration.parent.kind !== 226 /* CatchClause */; if (isLetOrConst) { // side-effect of calling this method: // assign id to symbol if it was not yet set @@ -22919,7 +23517,10 @@ var ts; } function createResolver() { return { - getExpressionNameSubstitution: getExpressionNameSubstitution, + getReferencedExportContainer: getReferencedExportContainer, + getReferencedImportDeclaration: getReferencedImportDeclaration, + getReferencedNestedRedeclaration: getReferencedNestedRedeclaration, + isNestedRedeclaration: isNestedRedeclaration, isValueAliasDeclaration: isValueAliasDeclaration, hasGlobalName: hasGlobalName, isReferencedAliasDeclaration: isReferencedAliasDeclaration, @@ -22933,7 +23534,6 @@ var ts; isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, getConstantValue: getConstantValue, - resolvesToSomeValue: resolvesToSomeValue, collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, @@ -22994,137 +23594,6 @@ var ts; anyArrayType = createArrayType(anyType); } // GRAMMAR CHECKING - function isReservedWordInStrictMode(node) { - // Check that originalKeywordKind is less than LastFutureReservedWord to see if an Identifier is a strict-mode reserved word - return (node.parserContextFlags & 1 /* StrictMode */) && - (102 /* FirstFutureReservedWord */ <= node.originalKeywordKind && node.originalKeywordKind <= 110 /* LastFutureReservedWord */); - } - function reportStrictModeGrammarErrorInClassDeclaration(identifier, message, arg0, arg1, arg2) { - // We are checking if this name is inside class declaration or class expression (which are under class definitions inside ES6 spec.) - // if so, we would like to give more explicit invalid usage error. - if (ts.getAncestor(identifier, 202 /* ClassDeclaration */) || ts.getAncestor(identifier, 175 /* ClassExpression */)) { - return grammarErrorOnNode(identifier, message, arg0); - } - return false; - } - function checkGrammarImportDeclarationNameInStrictMode(node) { - // Check if the import declaration used strict-mode reserved word in its names bindings - if (node.importClause) { - var impotClause = node.importClause; - if (impotClause.namedBindings) { - var nameBindings = impotClause.namedBindings; - if (nameBindings.kind === 212 /* NamespaceImport */) { - var name_15 = nameBindings.name; - if (isReservedWordInStrictMode(name_15)) { - var nameText = ts.declarationNameToString(name_15); - return grammarErrorOnNode(name_15, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - } - } - else if (nameBindings.kind === 213 /* NamedImports */) { - var reportError = false; - for (var _i = 0, _a = nameBindings.elements; _i < _a.length; _i++) { - var element = _a[_i]; - var name_16 = element.name; - if (isReservedWordInStrictMode(name_16)) { - var nameText = ts.declarationNameToString(name_16); - reportError = reportError || grammarErrorOnNode(name_16, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - } - } - return reportError; - } - } - } - return false; - } - function checkGrammarDeclarationNameInStrictMode(node) { - var name = node.name; - if (name && name.kind === 65 /* Identifier */ && isReservedWordInStrictMode(name)) { - var nameText = ts.declarationNameToString(name); - switch (node.kind) { - case 130 /* Parameter */: - case 199 /* VariableDeclaration */: - case 201 /* FunctionDeclaration */: - case 129 /* TypeParameter */: - case 153 /* BindingElement */: - case 203 /* InterfaceDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 205 /* EnumDeclaration */: - return checkGrammarIdentifierInStrictMode(name); - case 202 /* ClassDeclaration */: - // Report an error if the class declaration uses strict-mode reserved word. - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText); - case 206 /* ModuleDeclaration */: - // Report an error if the module declaration uses strict-mode reserved word. - // TODO(yuisu): fix this when having external module in strict mode - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - case 209 /* ImportEqualsDeclaration */: - // TODO(yuisu): fix this when having external module in strict mode - return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - } - } - return false; - } - function checkGrammarTypeReferenceInStrictMode(typeName) { - // Check if the type reference is using strict mode keyword - // Example: - // class C { - // foo(x: public){} // Error. - // } - if (typeName.kind === 65 /* Identifier */) { - checkGrammarTypeNameInStrictMode(typeName); - } - else if (typeName.kind === 127 /* QualifiedName */) { - // Walk from right to left and report a possible error at each Identifier in QualifiedName - // Example: - // x1: public.private.package // error at public and private - checkGrammarTypeNameInStrictMode(typeName.right); - checkGrammarTypeReferenceInStrictMode(typeName.left); - } - } - // This function will report an error for every identifier in property access expression - // whether it violates strict mode reserved words. - // Example: - // public // error at public - // public.private.package // error at public - // B.private.B // no error - function checkGrammarExpressionWithTypeArgumentsInStrictMode(expression) { - // Example: - // class C extends public // error at public - if (expression && expression.kind === 65 /* Identifier */) { - return checkGrammarIdentifierInStrictMode(expression); - } - else if (expression && expression.kind === 156 /* PropertyAccessExpression */) { - // Walk from left to right in PropertyAccessExpression until we are at the left most expression - // in PropertyAccessExpression. According to grammar production of MemberExpression, - // the left component expression is a PrimaryExpression (i.e. Identifier) while the other - // component after dots can be IdentifierName. - checkGrammarExpressionWithTypeArgumentsInStrictMode(expression.expression); - } - } - // The function takes an identifier itself or an expression which has SyntaxKind.Identifier. - function checkGrammarIdentifierInStrictMode(node, nameText) { - if (node && node.kind === 65 /* Identifier */ && isReservedWordInStrictMode(node)) { - if (!nameText) { - nameText = ts.declarationNameToString(node); - } - // TODO (yuisu): Fix when module is a strict mode - var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) || - grammarErrorOnNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); - return errorReport; - } - return false; - } - // The function takes an identifier when uses as a typeName in TypeReferenceNode - function checkGrammarTypeNameInStrictMode(node) { - if (node && node.kind === 65 /* Identifier */ && isReservedWordInStrictMode(node)) { - var nameText = ts.declarationNameToString(node); - // TODO (yuisu): Fix when module is a strict mode - var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) || - grammarErrorOnNode(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode, nameText); - return errorReport; - } - return false; - } function checkGrammarDecorators(node) { if (!node.decorators) { return false; @@ -23135,7 +23604,7 @@ var ts; else if (languageVersion < 1 /* ES5 */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); } - else if (node.kind === 137 /* GetAccessor */ || node.kind === 138 /* SetAccessor */) { + else if (node.kind === 138 /* GetAccessor */ || node.kind === 139 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -23145,33 +23614,33 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 136 /* Constructor */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 141 /* IndexSignature */: - case 206 /* ModuleDeclaration */: - case 210 /* ImportDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 216 /* ExportDeclaration */: - case 215 /* ExportAssignment */: - case 130 /* Parameter */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 137 /* Constructor */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 142 /* IndexSignature */: + case 208 /* ModuleDeclaration */: + case 212 /* ImportDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 218 /* ExportDeclaration */: + case 217 /* ExportAssignment */: + case 131 /* Parameter */: break; - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 181 /* VariableStatement */: - case 201 /* FunctionDeclaration */: - case 204 /* TypeAliasDeclaration */: - if (node.modifiers && node.parent.kind !== 207 /* ModuleBlock */ && node.parent.kind !== 228 /* SourceFile */) { + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 183 /* VariableStatement */: + case 203 /* FunctionDeclaration */: + case 206 /* TypeAliasDeclaration */: + if (node.modifiers && node.parent.kind !== 209 /* ModuleBlock */ && node.parent.kind !== 230 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 70 /* ConstKeyword */) && - node.parent.kind !== 207 /* ModuleBlock */ && node.parent.kind !== 228 /* SourceFile */) { + node.parent.kind !== 209 /* ModuleBlock */ && node.parent.kind !== 230 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -23207,7 +23676,7 @@ var ts; else if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (node.parent.kind === 207 /* ModuleBlock */ || node.parent.kind === 228 /* SourceFile */) { + else if (node.parent.kind === 209 /* ModuleBlock */ || node.parent.kind === 230 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } flags |= ts.modifierToFlag(modifier.kind); @@ -23216,10 +23685,10 @@ var ts; if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (node.parent.kind === 207 /* ModuleBlock */ || node.parent.kind === 228 /* SourceFile */) { + else if (node.parent.kind === 209 /* ModuleBlock */ || node.parent.kind === 230 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 130 /* Parameter */) { + else if (node.kind === 131 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } flags |= 128 /* Static */; @@ -23232,10 +23701,10 @@ var ts; else if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (node.parent.kind === 202 /* ClassDeclaration */) { + else if (node.parent.kind === 204 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 130 /* Parameter */) { + else if (node.kind === 131 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; @@ -23244,13 +23713,13 @@ var ts; if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (node.parent.kind === 202 /* ClassDeclaration */) { + else if (node.parent.kind === 204 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 130 /* Parameter */) { + else if (node.kind === 131 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 207 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 209 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -23258,7 +23727,7 @@ var ts; break; } } - if (node.kind === 136 /* Constructor */) { + if (node.kind === 137 /* Constructor */) { if (flags & 128 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -23269,10 +23738,10 @@ var ts; return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } } - else if ((node.kind === 210 /* ImportDeclaration */ || node.kind === 209 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 212 /* ImportDeclaration */ || node.kind === 211 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 130 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 131 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } } @@ -23336,7 +23805,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 164 /* ArrowFunction */) { + if (node.kind === 166 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -23371,7 +23840,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 122 /* StringKeyword */ && parameter.type.kind !== 120 /* NumberKeyword */) { + if (parameter.type.kind !== 123 /* StringKeyword */ && parameter.type.kind !== 121 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -23404,7 +23873,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < arguments.length; _i++) { var arg = arguments[_i]; - if (arg.kind === 176 /* OmittedExpression */) { + if (arg.kind === 178 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -23478,19 +23947,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 128 /* ComputedPropertyName */) { + if (node.kind !== 129 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 170 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 23 /* CommaToken */) { + if (computedPropertyName.expression.kind === 172 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 23 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 201 /* FunctionDeclaration */ || - node.kind === 163 /* FunctionExpression */ || - node.kind === 135 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 203 /* FunctionDeclaration */ || + node.kind === 165 /* FunctionExpression */ || + node.kind === 136 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -23502,10 +23971,6 @@ var ts; } } } - function checkGrammarFunctionName(name) { - // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a strict mode FunctionDeclaration or FunctionExpression (13.1)) - return checkGrammarEvalOrArgumentsInStrictMode(name, name); - } function checkGrammarForInvalidQuestionMark(node, questionToken, message) { if (questionToken) { return grammarErrorOnNode(questionToken, message); @@ -23517,14 +23982,13 @@ var ts; var GetAccessor = 2; var SetAccesor = 4; var GetOrSetAccessor = GetAccessor | SetAccesor; - var inStrictMode = (node.parserContextFlags & 1 /* StrictMode */) !== 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_17 = prop.name; - if (prop.kind === 176 /* OmittedExpression */ || - name_17.kind === 128 /* ComputedPropertyName */) { + var name_15 = prop.name; + if (prop.kind === 178 /* OmittedExpression */ || + name_15.kind === 129 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it - checkGrammarComputedPropertyName(name_17); + checkGrammarComputedPropertyName(name_15); continue; } // ECMA-262 11.1.5 Object Initialiser @@ -23536,46 +24000,44 @@ var ts; // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; - if (prop.kind === 225 /* PropertyAssignment */ || prop.kind === 226 /* ShorthandPropertyAssignment */) { + if (prop.kind === 227 /* PropertyAssignment */ || prop.kind === 228 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_17.kind === 7 /* NumericLiteral */) { - checkGrammarNumericLiteral(name_17); + if (name_15.kind === 7 /* NumericLiteral */) { + checkGrammarNumericLiteral(name_15); } currentKind = Property; } - else if (prop.kind === 135 /* MethodDeclaration */) { + else if (prop.kind === 136 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 137 /* GetAccessor */) { + else if (prop.kind === 138 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 138 /* SetAccessor */) { + else if (prop.kind === 139 /* SetAccessor */) { currentKind = SetAccesor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, name_17.text)) { - seen[name_17.text] = currentKind; + if (!ts.hasProperty(seen, name_15.text)) { + seen[name_15.text] = currentKind; } else { - var existingKind = seen[name_17.text]; + var existingKind = seen[name_15.text]; if (currentKind === Property && existingKind === Property) { - if (inStrictMode) { - grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); - } + continue; } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_17.text] = currentKind | existingKind; + seen[name_15.text] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_15, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_15, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -23584,24 +24046,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 200 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 202 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 188 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 190 /* ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 188 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 190 /* ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 188 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 190 /* ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -23624,10 +24086,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 137 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 138 /* GetAccessor */ && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 138 /* SetAccessor */) { + else if (kind === 139 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -23652,7 +24114,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 128 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 129 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -23662,7 +24124,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 155 /* ObjectLiteralExpression */) { + if (node.parent.kind === 157 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -23670,7 +24132,7 @@ var ts; return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } - if (node.parent.kind === 202 /* ClassDeclaration */) { + if (node.parent.kind === 204 /* ClassDeclaration */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -23686,22 +24148,22 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 203 /* InterfaceDeclaration */) { + else if (node.parent.kind === 205 /* InterfaceDeclaration */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 146 /* TypeLiteral */) { + else if (node.parent.kind === 148 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: return true; - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -23713,11 +24175,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: if (node.label && current.label.text === node.label.text) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 190 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 192 /* ContinueStatement */ && !isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -23725,8 +24187,8 @@ var ts; return false; } break; - case 194 /* SwitchStatement */: - if (node.kind === 191 /* BreakStatement */ && !node.label) { + case 196 /* SwitchStatement */: + if (node.kind === 193 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -23741,13 +24203,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 191 /* BreakStatement */ + var message = node.kind === 193 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 191 /* BreakStatement */ + var message = node.kind === 193 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -23759,7 +24221,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 152 /* ArrayBindingPattern */ || node.name.kind === 151 /* ObjectBindingPattern */) { + if (node.name.kind === 154 /* ArrayBindingPattern */ || node.name.kind === 153 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -23767,12 +24229,9 @@ var ts; return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } } - // It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code - // and its Identifier is eval or arguments - return checkGrammarEvalOrArgumentsInStrictMode(node, node.name); } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 188 /* ForInStatement */ && node.parent.parent.kind !== 189 /* ForOfStatement */) { + if (node.parent.parent.kind !== 190 /* ForInStatement */ && node.parent.parent.kind !== 191 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { // Error on equals token which immediate precedes the initializer @@ -23796,8 +24255,7 @@ var ts; // It is a Syntax Error if the BoundNames of ForDeclaration contains "let". // It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code // and its Identifier is eval or arguments - return (checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name)) || - checkGrammarEvalOrArgumentsInStrictMode(node, node.name); + return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { if (name.kind === 65 /* Identifier */) { @@ -23809,7 +24267,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 176 /* OmittedExpression */) { + if (element.kind !== 178 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -23826,15 +24284,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 184 /* IfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: - case 193 /* WithStatement */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: + case 186 /* IfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: + case 195 /* WithStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: return false; - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -23850,7 +24308,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 168 /* PrefixUnaryExpression */) { + if (expression.kind === 170 /* PrefixUnaryExpression */) { var unaryExpression = expression; if (unaryExpression.operator === 33 /* PlusToken */ || unaryExpression.operator === 34 /* MinusToken */) { expression = unaryExpression.operand; @@ -23879,7 +24337,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 128 /* ComputedPropertyName */) { + if (node.name.kind === 129 /* ComputedPropertyName */) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -23921,26 +24379,6 @@ var ts; return true; } } - function checkGrammarEvalOrArgumentsInStrictMode(contextNode, name) { - if (name && name.kind === 65 /* Identifier */) { - var identifier = name; - if (contextNode && (contextNode.parserContextFlags & 1 /* StrictMode */) && isEvalOrArgumentsIdentifier(identifier)) { - var nameText = ts.declarationNameToString(identifier); - // We check first if the name is inside class declaration or class expression; if so give explicit message - // otherwise report generic error message. - // reportGrammarErrorInClassDeclaration only return true if grammar error is successfully reported and false otherwise - var reportErrorInClassDeclaration = reportStrictModeGrammarErrorInClassDeclaration(identifier, ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText); - if (!reportErrorInClassDeclaration) { - return grammarErrorOnNode(identifier, ts.Diagnostics.Invalid_use_of_0_in_strict_mode, nameText); - } - return reportErrorInClassDeclaration; - } - } - } - function isEvalOrArgumentsIdentifier(node) { - return node.kind === 65 /* Identifier */ && - (node.text === "eval" || node.text === "arguments"); - } function checkGrammarConstructorTypeParameters(node) { if (node.typeParameters) { return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); @@ -23952,18 +24390,18 @@ var ts; } } function checkGrammarProperty(node) { - if (node.parent.kind === 202 /* ClassDeclaration */) { + if (node.parent.kind === 204 /* ClassDeclaration */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 203 /* InterfaceDeclaration */) { + else if (node.parent.kind === 205 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 146 /* TypeLiteral */) { + else if (node.parent.kind === 148 /* TypeLiteral */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -23983,11 +24421,11 @@ var ts; // export_opt ExternalImportDeclaration // export_opt AmbientDeclaration // - if (node.kind === 203 /* InterfaceDeclaration */ || - node.kind === 210 /* ImportDeclaration */ || - node.kind === 209 /* ImportEqualsDeclaration */ || - node.kind === 216 /* ExportDeclaration */ || - node.kind === 215 /* ExportAssignment */ || + if (node.kind === 205 /* InterfaceDeclaration */ || + node.kind === 212 /* ImportDeclaration */ || + node.kind === 211 /* ImportEqualsDeclaration */ || + node.kind === 218 /* ExportDeclaration */ || + node.kind === 217 /* ExportAssignment */ || (node.flags & 2 /* Ambient */) || (node.flags & (1 /* Export */ | 256 /* Default */))) { return false; @@ -23997,7 +24435,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 181 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 183 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -24023,7 +24461,7 @@ var ts; // to prevent noisyness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 180 /* Block */ || node.parent.kind === 207 /* ModuleBlock */ || node.parent.kind === 228 /* SourceFile */) { + if (node.parent.kind === 182 /* Block */ || node.parent.kind === 209 /* ModuleBlock */ || node.parent.kind === 230 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -24036,13 +24474,8 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.flags & 16384 /* OctalLiteral */) { - if (node.parserContextFlags & 1 /* StrictMode */) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode); - } - else if (languageVersion >= 1 /* ES5 */) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); - } + if (node.flags & 16384 /* OctalLiteral */ && languageVersion >= 1 /* ES5 */) { + return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { @@ -24053,8 +24486,6 @@ var ts; return true; } } - initializeTypeChecker(); - return checker; } ts.createTypeChecker = createTypeChecker; })(ts || (ts = {})); @@ -24113,7 +24544,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 210 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 212 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -24189,10 +24620,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 199 /* VariableDeclaration */) { + if (declaration.kind === 201 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 213 /* NamedImports */ || declaration.kind === 214 /* ImportSpecifier */ || declaration.kind === 211 /* ImportClause */) { + else if (declaration.kind === 215 /* NamedImports */ || declaration.kind === 216 /* ImportSpecifier */ || declaration.kind === 213 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -24210,7 +24641,7 @@ var ts; // Writing of function bar would mark alias declaration foo as visible but we haven't yet visited that declaration so do nothing, // we would write alias foo declaration when we visit it since it would now be marked as visible if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 210 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 212 /* ImportDeclaration */) { // we have to create asynchronous output only after we have collected complete information // because it is possible to enable multiple bindings as asynchronously visible moduleElementEmitInfo.isVisible = true; @@ -24220,12 +24651,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 206 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 208 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 206 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 208 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -24318,41 +24749,41 @@ var ts; function emitType(type) { switch (type.kind) { case 112 /* AnyKeyword */: - case 122 /* StringKeyword */: - case 120 /* NumberKeyword */: + case 123 /* StringKeyword */: + case 121 /* NumberKeyword */: case 113 /* BooleanKeyword */: - case 123 /* SymbolKeyword */: + case 124 /* SymbolKeyword */: case 99 /* VoidKeyword */: case 8 /* StringLiteral */: return writeTextOfNode(currentSourceFile, type); - case 177 /* ExpressionWithTypeArguments */: + case 179 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 142 /* TypeReference */: + case 144 /* TypeReference */: return emitTypeReference(type); - case 145 /* TypeQuery */: + case 147 /* TypeQuery */: return emitTypeQuery(type); - case 147 /* ArrayType */: + case 149 /* ArrayType */: return emitArrayType(type); - case 148 /* TupleType */: + case 150 /* TupleType */: return emitTupleType(type); - case 149 /* UnionType */: + case 151 /* UnionType */: return emitUnionType(type); - case 150 /* ParenthesizedType */: + case 152 /* ParenthesizedType */: return emitParenType(type); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 146 /* TypeLiteral */: + case 148 /* TypeLiteral */: return emitTypeLiteral(type); case 65 /* Identifier */: return emitEntityName(type); - case 127 /* QualifiedName */: + case 128 /* QualifiedName */: return emitEntityName(type); } function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 209 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 211 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); function writeEntityName(entityName) { @@ -24360,8 +24791,8 @@ var ts; writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 127 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 127 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 128 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 128 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); @@ -24370,7 +24801,7 @@ var ts; } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 65 /* Identifier */ || node.expression.kind === 156 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 65 /* Identifier */ || node.expression.kind === 158 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -24436,9 +24867,9 @@ var ts; } var count = 0; while (true) { - var name_18 = baseName + "_" + (++count); - if (!ts.hasProperty(currentSourceFile.identifiers, name_18)) { - return name_18; + var name_16 = baseName + "_" + (++count); + if (!ts.hasProperty(currentSourceFile.identifiers, name_16)) { + return name_16; } } } @@ -24482,10 +24913,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 209 /* ImportEqualsDeclaration */ || - (node.parent.kind === 228 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 211 /* ImportEqualsDeclaration */ || + (node.parent.kind === 230 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 228 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 230 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -24495,7 +24926,7 @@ var ts; }); } else { - if (node.kind === 210 /* ImportDeclaration */) { + if (node.kind === 212 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -24513,23 +24944,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: return writeVariableStatement(node); - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: return writeClassDeclaration(node); - case 204 /* TypeAliasDeclaration */: + case 206 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -24545,7 +24976,7 @@ var ts; if (node.flags & 256 /* Default */) { write("default "); } - else if (node.kind !== 203 /* InterfaceDeclaration */) { + else if (node.kind !== 205 /* InterfaceDeclaration */) { write("declare "); } } @@ -24591,7 +25022,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 212 /* NamespaceImport */) { + if (namedBindings.kind === 214 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -24619,7 +25050,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 212 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 214 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -24670,9 +25101,14 @@ var ts; function writeModuleDeclaration(node) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - write("module "); + if (node.flags & 32768 /* Namespace */) { + write("namespace "); + } + else { + write("module "); + } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 207 /* ModuleBlock */) { + while (node.body.kind !== 209 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -24733,7 +25169,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 135 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + return node.parent.kind === 136 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -24744,15 +25180,15 @@ var ts; // If there is constraint present and this is not a type parameter of the private method emit the constraint if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 143 /* FunctionType */ || - node.parent.kind === 144 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 146 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 135 /* MethodDeclaration */ || - node.parent.kind === 134 /* MethodSignature */ || - node.parent.kind === 143 /* FunctionType */ || - node.parent.kind === 144 /* ConstructorType */ || - node.parent.kind === 139 /* CallSignature */ || - node.parent.kind === 140 /* ConstructSignature */); + if (node.parent.kind === 145 /* FunctionType */ || + node.parent.kind === 146 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 148 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 136 /* MethodDeclaration */ || + node.parent.kind === 135 /* MethodSignature */ || + node.parent.kind === 145 /* FunctionType */ || + node.parent.kind === 146 /* ConstructorType */ || + node.parent.kind === 140 /* CallSignature */ || + node.parent.kind === 141 /* ConstructSignature */); emitType(node.constraint); } else { @@ -24763,31 +25199,31 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 140 /* ConstructSignature */: + case 141 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 139 /* CallSignature */: + case 140 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 202 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 204 /* ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -24818,7 +25254,7 @@ var ts; function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 202 /* ClassDeclaration */) { + if (node.parent.parent.kind === 204 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -24899,7 +25335,7 @@ var ts; function emitVariableDeclaration(node) { // If we are emitting property it isn't moduleElement and hence we already know it needs to be emitted // so there is no check needed to see if declaration is visible - if (node.kind !== 199 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 201 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -24909,10 +25345,10 @@ var ts; // what we want, namely the name expression enclosed in brackets. writeTextOfNode(currentSourceFile, node.name); // If optional property emit ? - if ((node.kind === 133 /* PropertyDeclaration */ || node.kind === 132 /* PropertySignature */) && ts.hasQuestionToken(node)) { + if ((node.kind === 134 /* PropertyDeclaration */ || node.kind === 133 /* PropertySignature */) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 133 /* PropertyDeclaration */ || node.kind === 132 /* PropertySignature */) && node.parent.kind === 146 /* TypeLiteral */) { + if ((node.kind === 134 /* PropertyDeclaration */ || node.kind === 133 /* PropertySignature */) && node.parent.kind === 148 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32 /* Private */)) { @@ -24921,14 +25357,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 199 /* VariableDeclaration */) { + if (node.kind === 201 /* VariableDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 133 /* PropertyDeclaration */ || node.kind === 132 /* PropertySignature */) { + else if (node.kind === 134 /* PropertyDeclaration */ || node.kind === 133 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (node.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? @@ -24937,7 +25373,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 202 /* ClassDeclaration */) { + else if (node.parent.kind === 204 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -24969,7 +25405,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 176 /* OmittedExpression */) { + if (element.kind !== 178 /* OmittedExpression */) { elements.push(element); } } @@ -25039,7 +25475,7 @@ var ts; var type = getTypeAnnotationFromAccessor(node); if (!type) { // couldn't get type for the first accessor, try the another one - var anotherAccessor = node.kind === 137 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 138 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -25052,7 +25488,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 137 /* GetAccessor */ + return accessor.kind === 138 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -25061,7 +25497,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 138 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 139 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? @@ -25111,17 +25547,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 201 /* FunctionDeclaration */) { + if (node.kind === 203 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 135 /* MethodDeclaration */) { + else if (node.kind === 136 /* MethodDeclaration */) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 201 /* FunctionDeclaration */) { + if (node.kind === 203 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 136 /* Constructor */) { + else if (node.kind === 137 /* Constructor */) { write("constructor"); } else { @@ -25139,11 +25575,11 @@ var ts; } function emitSignatureDeclaration(node) { // Construct signature or constructor type write new Signature - if (node.kind === 140 /* ConstructSignature */ || node.kind === 144 /* ConstructorType */) { + if (node.kind === 141 /* ConstructSignature */ || node.kind === 146 /* ConstructorType */) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 141 /* IndexSignature */) { + if (node.kind === 142 /* IndexSignature */) { write("["); } else { @@ -25153,22 +25589,22 @@ var ts; enclosingDeclaration = node; // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 141 /* IndexSignature */) { + if (node.kind === 142 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 143 /* FunctionType */ || node.kind === 144 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 146 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 145 /* FunctionType */ || node.kind === 146 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 148 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 136 /* Constructor */ && !(node.flags & 32 /* Private */)) { + else if (node.kind !== 137 /* Constructor */ && !(node.flags & 32 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -25179,26 +25615,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 140 /* ConstructSignature */: + case 141 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 139 /* CallSignature */: + case 140 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 141 /* IndexSignature */: + case 142 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -25206,7 +25642,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 202 /* ClassDeclaration */) { + else if (node.parent.kind === 204 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -25220,7 +25656,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -25255,9 +25691,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 143 /* FunctionType */ || - node.parent.kind === 144 /* ConstructorType */ || - node.parent.parent.kind === 146 /* TypeLiteral */) { + if (node.parent.kind === 145 /* FunctionType */ || + node.parent.kind === 146 /* ConstructorType */ || + node.parent.parent.kind === 148 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32 /* Private */)) { @@ -25273,24 +25709,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 136 /* Constructor */: + case 137 /* Constructor */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 140 /* ConstructSignature */: + case 141 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 139 /* CallSignature */: + case 140 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -25298,7 +25734,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 202 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 204 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -25311,7 +25747,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -25323,12 +25759,12 @@ var ts; } function emitBindingPattern(bindingPattern) { // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node. - if (bindingPattern.kind === 151 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 153 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 152 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 154 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -25347,7 +25783,7 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 176 /* OmittedExpression */) { + if (bindingElement.kind === 178 /* OmittedExpression */) { // If bindingElement is an omittedExpression (i.e. containing elision), // we will emit blank space (although this may differ from users' original code, // it allows emitSeparatedList to write separator appropriately) @@ -25356,7 +25792,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 153 /* BindingElement */) { + else if (bindingElement.kind === 155 /* BindingElement */) { if (bindingElement.propertyName) { // bindingElement has propertyName property in the following case: // { y: [a,b,c] ...} -> bindingPattern will have a property called propertyName for "y" @@ -25397,40 +25833,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 201 /* FunctionDeclaration */: - case 206 /* ModuleDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 203 /* InterfaceDeclaration */: - case 202 /* ClassDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 205 /* EnumDeclaration */: + case 203 /* FunctionDeclaration */: + case 208 /* ModuleDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 205 /* InterfaceDeclaration */: + case 204 /* ClassDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 207 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, !node.importClause); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: return emitExportDeclaration(node); - case 136 /* Constructor */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 137 /* Constructor */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return writeFunctionDeclaration(node); - case 140 /* ConstructSignature */: - case 139 /* CallSignature */: - case 141 /* IndexSignature */: + case 141 /* ConstructSignature */: + case 140 /* CallSignature */: + case 142 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: return emitAccessorDeclaration(node); - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return emitPropertyDeclaration(node); - case 227 /* EnumMember */: + case 229 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return emitExportAssignment(node); - case 228 /* SourceFile */: + case 230 /* SourceFile */: return emitSourceFile(node); } } @@ -25491,7 +25927,7 @@ var ts; // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature function emitFiles(resolver, host, targetSourceFile) { // emit output for the __extends helper function - var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n __.prototype = b.prototype;\n d.prototype = new __();\n};"; + var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; // emit output for the __decorate helper function var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; // emit output for the __metadata helper function @@ -25567,7 +26003,6 @@ var ts; var exportFunctionForFile; var generatedNameSet = {}; var nodeToGeneratedName = []; - var blockScopedVariableToGeneratedName; var computedPropertyNamesToGeneratedNames; var extendsEmitted = false; var decorateEmitted = false; @@ -25647,9 +26082,9 @@ var ts; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { - var name_19 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_19)) { - return name_19; + var name_17 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); + if (isUniqueName(name_17)) { + return name_17; } } } @@ -25672,73 +26107,40 @@ var ts; i++; } } - function assignGeneratedName(node, name) { - nodeToGeneratedName[ts.getNodeId(node)] = ts.unescapeIdentifier(name); - } - function generateNameForFunctionOrClassDeclaration(node) { - if (!node.name) { - assignGeneratedName(node, makeUniqueName("default")); - } - } function generateNameForModuleOrEnum(node) { - if (node.name.kind === 65 /* Identifier */) { - var name_20 = node.name.text; - // Use module/enum name itself if it is unique, otherwise make a unique variation - assignGeneratedName(node, isUniqueLocalName(name_20, node) ? name_20 : makeUniqueName(name_20)); - } + var name = node.name.text; + // Use module/enum name itself if it is unique, otherwise make a unique variation + return isUniqueLocalName(name, node) ? name : makeUniqueName(name); } function generateNameForImportOrExportDeclaration(node) { var expr = ts.getExternalModuleName(node); var baseName = expr.kind === 8 /* StringLiteral */ ? ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; - assignGeneratedName(node, makeUniqueName(baseName)); + return makeUniqueName(baseName); } - function generateNameForImportDeclaration(node) { - if (node.importClause) { - generateNameForImportOrExportDeclaration(node); - } - } - function generateNameForExportDeclaration(node) { - if (node.moduleSpecifier) { - generateNameForImportOrExportDeclaration(node); - } - } - function generateNameForExportAssignment(node) { - if (node.expression && node.expression.kind !== 65 /* Identifier */) { - assignGeneratedName(node, makeUniqueName("default")); - } + function generateNameForExportDefault() { + return makeUniqueName("default"); } function generateNameForNode(node) { switch (node.kind) { - case 201 /* FunctionDeclaration */: - case 202 /* ClassDeclaration */: - case 175 /* ClassExpression */: - generateNameForFunctionOrClassDeclaration(node); - break; - case 206 /* ModuleDeclaration */: - generateNameForModuleOrEnum(node); - generateNameForNode(node.body); - break; - case 205 /* EnumDeclaration */: - generateNameForModuleOrEnum(node); - break; - case 210 /* ImportDeclaration */: - generateNameForImportDeclaration(node); - break; - case 216 /* ExportDeclaration */: - generateNameForExportDeclaration(node); - break; - case 215 /* ExportAssignment */: - generateNameForExportAssignment(node); - break; + case 65 /* Identifier */: + return makeUniqueName(node.text); + case 208 /* ModuleDeclaration */: + case 207 /* EnumDeclaration */: + return generateNameForModuleOrEnum(node); + case 212 /* ImportDeclaration */: + case 218 /* ExportDeclaration */: + return generateNameForImportOrExportDeclaration(node); + case 203 /* FunctionDeclaration */: + case 204 /* ClassDeclaration */: + case 177 /* ClassExpression */: + case 217 /* ExportAssignment */: + return generateNameForExportDefault(); } } function getGeneratedNameForNode(node) { - var nodeId = ts.getNodeId(node); - if (!nodeToGeneratedName[nodeId]) { - generateNameForNode(node); - } - return nodeToGeneratedName[nodeId]; + var id = ts.getNodeId(node); + return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); } function initializeEmitterWithSourceMaps() { var sourceMapDir; // The directory in which sourcemap will be @@ -25767,7 +26169,7 @@ var ts; } var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; // Line/Comma delimiters - if (lastEncodedSourceMapSpan.emittedLine == lastRecordedSourceMapSpan.emittedLine) { + if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { // Emit comma to separate the entry if (sourceMapData.sourceMapMappings) { sourceMapData.sourceMapMappings += ","; @@ -25836,8 +26238,8 @@ var ts; var emittedColumn = writer.getColumn(); // If this location wasn't recorded or the location in source is going backwards, record the span if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine != emittedLine || - lastRecordedSourceMapSpan.emittedColumn != emittedColumn || + lastRecordedSourceMapSpan.emittedLine !== emittedLine || + lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { @@ -25903,8 +26305,8 @@ var ts; // Child scopes are always shown with a dot (even if they have no name), // unless it is a computed property. Then it is shown with brackets, // but the brackets are included in the name. - var name_21 = node.name; - if (!name_21 || name_21.kind !== 128 /* ComputedPropertyName */) { + var name_18 = node.name; + if (!name_18 || name_18.kind !== 129 /* ComputedPropertyName */) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -25922,21 +26324,21 @@ var ts; // The scope was already given a name use it recordScopeNameStart(scopeName); } - else if (node.kind === 201 /* FunctionDeclaration */ || - node.kind === 163 /* FunctionExpression */ || - node.kind === 135 /* MethodDeclaration */ || - node.kind === 134 /* MethodSignature */ || - node.kind === 137 /* GetAccessor */ || - node.kind === 138 /* SetAccessor */ || - node.kind === 206 /* ModuleDeclaration */ || - node.kind === 202 /* ClassDeclaration */ || - node.kind === 205 /* EnumDeclaration */) { + else if (node.kind === 203 /* FunctionDeclaration */ || + node.kind === 165 /* FunctionExpression */ || + node.kind === 136 /* MethodDeclaration */ || + node.kind === 135 /* MethodSignature */ || + node.kind === 138 /* GetAccessor */ || + node.kind === 139 /* SetAccessor */ || + node.kind === 208 /* ModuleDeclaration */ || + node.kind === 204 /* ClassDeclaration */ || + node.kind === 207 /* EnumDeclaration */) { // Declaration and has associated name use it if (node.name) { - var name_22 = node.name; + var name_19 = node.name; // For computed property names, the text will include the brackets - scopeName = name_22.kind === 128 /* ComputedPropertyName */ - ? ts.getTextOfNode(name_22) + scopeName = name_19.kind === 129 /* ComputedPropertyName */ + ? ts.getTextOfNode(name_19) : node.name.text; } recordScopeNameStart(scopeName); @@ -26040,19 +26442,19 @@ var ts; else { sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); } - function emitNodeWithSourceMap(node, allowGeneratedIdentifiers) { + function emitNodeWithSourceMap(node) { if (node) { if (ts.nodeIsSynthesized(node)) { - return emitNodeWithoutSourceMap(node, false); + return emitNodeWithoutSourceMap(node); } - if (node.kind != 228 /* SourceFile */) { + if (node.kind !== 230 /* SourceFile */) { recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers); + emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); } else { recordNewSourceFileStart(node); - emitNodeWithoutSourceMap(node, false); + emitNodeWithoutSourceMap(node); } } } @@ -26308,10 +26710,10 @@ var ts; write("("); emit(tempVariable); // Now we emit the expressions - if (node.template.kind === 172 /* TemplateExpression */) { + if (node.template.kind === 174 /* TemplateExpression */) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 170 /* BinaryExpression */ + var needsParens = templateSpan.expression.kind === 172 /* BinaryExpression */ && templateSpan.expression.operatorToken.kind === 23 /* CommaToken */; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -26346,7 +26748,7 @@ var ts; // ("abc" + 1) << (2 + "") // rather than // "abc" + (1 << 2) + "" - var needsParens = templateSpan.expression.kind !== 162 /* ParenthesizedExpression */ + var needsParens = templateSpan.expression.kind !== 164 /* ParenthesizedExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; if (i > 0 || headEmitted) { // If this is the first span and the head was not emitted, then this templateSpan's @@ -26388,11 +26790,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: return parent.expression === template; - case 160 /* TaggedTemplateExpression */: - case 162 /* ParenthesizedExpression */: + case 162 /* TaggedTemplateExpression */: + case 164 /* ParenthesizedExpression */: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; @@ -26413,7 +26815,7 @@ var ts; // TODO (drosen): Note that we need to account for the upcoming 'yield' and // spread ('...') unary operators that are anticipated for ES6. switch (expression.kind) { - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: switch (expression.operatorToken.kind) { case 35 /* AsteriskToken */: case 36 /* SlashToken */: @@ -26425,8 +26827,8 @@ var ts; default: return -1 /* LessThan */; } - case 173 /* YieldExpression */: - case 171 /* ConditionalExpression */: + case 175 /* YieldExpression */: + case 173 /* ConditionalExpression */: return -1 /* LessThan */; default: return 1 /* GreaterThan */; @@ -26441,11 +26843,11 @@ var ts; // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. // For example, this is utilized when feeding in a result to Object.defineProperty. function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 153 /* BindingElement */); + ts.Debug.assert(node.kind !== 155 /* BindingElement */); if (node.kind === 8 /* StringLiteral */) { emitLiteral(node); } - else if (node.kind === 128 /* ComputedPropertyName */) { + else if (node.kind === 129 /* ComputedPropertyName */) { // if this is a decorated computed property, we will need to capture the result // of the property expression so that we can apply decorators later. This is to ensure // we don't introduce unintended side effects: @@ -26486,75 +26888,126 @@ var ts; write("\""); } } - function isNotExpressionIdentifier(node) { + function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 130 /* Parameter */: - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 225 /* PropertyAssignment */: - case 226 /* ShorthandPropertyAssignment */: - case 227 /* EnumMember */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 201 /* FunctionDeclaration */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 163 /* FunctionExpression */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 206 /* ModuleDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 211 /* ImportClause */: - case 212 /* NamespaceImport */: - return parent.name === node; - case 214 /* ImportSpecifier */: - case 218 /* ExportSpecifier */: - return parent.name === node || parent.propertyName === node; - case 191 /* BreakStatement */: - case 190 /* ContinueStatement */: - case 215 /* ExportAssignment */: - return false; - case 195 /* LabeledStatement */: - return node.parent.label === node; + case 156 /* ArrayLiteralExpression */: + case 172 /* BinaryExpression */: + case 160 /* CallExpression */: + case 223 /* CaseClause */: + case 129 /* ComputedPropertyName */: + case 173 /* ConditionalExpression */: + case 132 /* Decorator */: + case 167 /* DeleteExpression */: + case 187 /* DoStatement */: + case 159 /* ElementAccessExpression */: + case 217 /* ExportAssignment */: + case 185 /* ExpressionStatement */: + case 179 /* ExpressionWithTypeArguments */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 186 /* IfStatement */: + case 161 /* NewExpression */: + case 164 /* ParenthesizedExpression */: + case 171 /* PostfixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: + case 194 /* ReturnStatement */: + case 228 /* ShorthandPropertyAssignment */: + case 176 /* SpreadElementExpression */: + case 196 /* SwitchStatement */: + case 162 /* TaggedTemplateExpression */: + case 180 /* TemplateSpan */: + case 198 /* ThrowStatement */: + case 163 /* TypeAssertionExpression */: + case 168 /* TypeOfExpression */: + case 169 /* VoidExpression */: + case 188 /* WhileStatement */: + case 195 /* WithStatement */: + case 175 /* YieldExpression */: + return true; + case 155 /* BindingElement */: + case 229 /* EnumMember */: + case 131 /* Parameter */: + case 227 /* PropertyAssignment */: + case 134 /* PropertyDeclaration */: + case 201 /* VariableDeclaration */: + return parent.initializer === node; + case 158 /* PropertyAccessExpression */: + return parent.expression === node; + case 166 /* ArrowFunction */: + case 165 /* FunctionExpression */: + return parent.body === node; + case 211 /* ImportEqualsDeclaration */: + return parent.moduleReference === node; + case 128 /* QualifiedName */: + return parent.left === node; } + return false; } function emitExpressionIdentifier(node) { - var substitution = resolver.getExpressionNameSubstitution(node, getGeneratedNameForNode); - if (substitution) { - write(substitution); + var container = resolver.getReferencedExportContainer(node); + if (container) { + if (container.kind === 230 /* SourceFile */) { + // Identifier references module export + if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 4 /* System */) { + write("exports."); + } + } + else { + // Identifier references namespace export + write(getGeneratedNameForNode(container)); + write("."); + } } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function getGeneratedNameForIdentifier(node) { - if (ts.nodeIsSynthesized(node) || !blockScopedVariableToGeneratedName) { - return undefined; - } - var variableId = resolver.getBlockScopedVariableId(node); - if (variableId === undefined) { - return undefined; - } - return blockScopedVariableToGeneratedName[variableId]; - } - function emitIdentifier(node, allowGeneratedIdentifiers) { - if (allowGeneratedIdentifiers) { - var generatedName = getGeneratedNameForIdentifier(node); - if (generatedName) { - write(generatedName); + else if (languageVersion < 2 /* ES6 */) { + var declaration = resolver.getReferencedImportDeclaration(node); + if (declaration) { + if (declaration.kind === 213 /* ImportClause */) { + // Identifier references default import + write(getGeneratedNameForNode(declaration.parent)); + write(languageVersion === 0 /* ES3 */ ? '["default"]' : ".default"); + return; + } + else if (declaration.kind === 216 /* ImportSpecifier */) { + // Identifier references named import + write(getGeneratedNameForNode(declaration.parent.parent.parent)); + write("."); + writeTextOfNode(currentSourceFile, declaration.propertyName || declaration.name); + return; + } + } + declaration = resolver.getReferencedNestedRedeclaration(node); + if (declaration) { + write(getGeneratedNameForNode(declaration.name)); return; } } + writeTextOfNode(currentSourceFile, node); + } + function isNameOfNestedRedeclaration(node) { + if (languageVersion < 2 /* ES6 */) { + var parent_7 = node.parent; + switch (parent_7.kind) { + case 155 /* BindingElement */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 201 /* VariableDeclaration */: + return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); + } + } + return false; + } + function emitIdentifier(node) { if (!node.parent) { write(node.text); } - else if (!isNotExpressionIdentifier(node)) { + else if (isExpressionIdentifier(node)) { emitExpressionIdentifier(node); } + else if (isNameOfNestedRedeclaration(node)) { + write(getGeneratedNameForNode(node)); + } else { writeTextOfNode(currentSourceFile, node); } @@ -26595,7 +27048,7 @@ var ts; } function emitBindingElement(node) { if (node.propertyName) { - emit(node.propertyName, false); + emit(node.propertyName); write(": "); } if (node.dotDotDotToken) { @@ -26626,11 +27079,11 @@ var ts; function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { case 65 /* Identifier */: - case 154 /* ArrayLiteralExpression */: - case 156 /* PropertyAccessExpression */: - case 157 /* ElementAccessExpression */: - case 158 /* CallExpression */: - case 162 /* ParenthesizedExpression */: + case 156 /* ArrayLiteralExpression */: + case 158 /* PropertyAccessExpression */: + case 159 /* ElementAccessExpression */: + case 160 /* CallExpression */: + case 164 /* ParenthesizedExpression */: // This list is not exhaustive and only includes those cases that are relevant // to the check in emitArrayLiteral. More cases can be added as needed. return false; @@ -26650,17 +27103,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 174 /* SpreadElementExpression */) { + if (e.kind === 176 /* SpreadElementExpression */) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 154 /* ArrayLiteralExpression */) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 156 /* ArrayLiteralExpression */) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 174 /* SpreadElementExpression */) { + while (i < length && elements[i].kind !== 176 /* SpreadElementExpression */) { i++; } write("["); @@ -26683,7 +27136,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 174 /* SpreadElementExpression */; + return node.kind === 176 /* SpreadElementExpression */; } function emitArrayLiteral(node) { var elements = node.elements; @@ -26753,7 +27206,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 137 /* GetAccessor */ || property.kind === 138 /* SetAccessor */) { + if (property.kind === 138 /* GetAccessor */ || property.kind === 139 /* SetAccessor */) { // TODO (drosen): Reconcile with 'emitMemberFunctions'. var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { @@ -26805,13 +27258,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 225 /* PropertyAssignment */) { + if (property.kind === 227 /* PropertyAssignment */) { emit(property.initializer); } - else if (property.kind === 226 /* ShorthandPropertyAssignment */) { + else if (property.kind === 228 /* ShorthandPropertyAssignment */) { emitExpressionIdentifier(property.name); } - else if (property.kind === 135 /* MethodDeclaration */) { + else if (property.kind === 136 /* MethodDeclaration */) { emitFunctionDeclaration(property); } else { @@ -26845,7 +27298,7 @@ var ts; // Everything until that point can be emitted as part of the initial object literal. var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 128 /* ComputedPropertyName */) { + if (properties[i].name.kind === 129 /* ComputedPropertyName */) { numInitialNonComputedProperties = i; break; } @@ -26861,21 +27314,21 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(170 /* BinaryExpression */, startsOnNewLine); + var result = ts.createSynthesizedNode(172 /* BinaryExpression */, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(156 /* PropertyAccessExpression */); + var result = ts.createSynthesizedNode(158 /* PropertyAccessExpression */); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(20 /* DotToken */); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(157 /* ElementAccessExpression */); + var result = ts.createSynthesizedNode(159 /* ElementAccessExpression */); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; @@ -26883,7 +27336,7 @@ var ts; function parenthesizeForAccess(expr) { // When diagnosing whether the expression needs parentheses, the decision should be based // on the innermost expression in a chain of nested type assertions. - while (expr.kind === 161 /* TypeAssertionExpression */) { + while (expr.kind === 163 /* TypeAssertionExpression */) { expr = expr.expression; } // isLeftHandSideExpression is almost the correct criterion for when it is not necessary @@ -26895,11 +27348,11 @@ var ts; // 1.x -> not the same as (1).x // if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 159 /* NewExpression */ && + expr.kind !== 161 /* NewExpression */ && expr.kind !== 7 /* NumericLiteral */) { return expr; } - var node = ts.createSynthesizedNode(162 /* ParenthesizedExpression */); + var node = ts.createSynthesizedNode(164 /* ParenthesizedExpression */); node.expression = expr; return node; } @@ -26912,46 +27365,39 @@ var ts; if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { write("*"); } - emit(node.name, false); + emit(node.name); if (languageVersion < 2 /* ES6 */) { write(": function "); } emitSignatureAndBody(node); } function emitPropertyAssignment(node) { - emit(node.name, false); + emit(node.name); write(": "); emit(node.initializer); } + // Return true if identifier resolves to an exported member of a namespace + function isNamespaceExportReference(node) { + var container = resolver.getReferencedExportContainer(node); + return container && container.kind !== 230 /* SourceFile */; + } function emitShorthandPropertyAssignment(node) { - emit(node.name, false); - // If short-hand property has a prefix, then regardless of the target version, we will emit it as normal property assignment. For example: - // module m { - // export let y; - // } - // module m { - // export let obj = { y }; - // } - // The short-hand property in obj need to emit as such ... = { y : m.y } regardless of the TargetScript version - if (languageVersion < 2 /* ES6 */) { + // The name property of a short-hand property assignment is considered an expression position, so here + // we manually emit the identifier to avoid rewriting. + writeTextOfNode(currentSourceFile, node.name); + // If emitting pre-ES6 code, or if the name requires rewriting when resolved as an expression identifier, + // we emit a normal property assignment. For example: + // module m { + // export let y; + // } + // module m { + // let obj = { y }; + // } + // Here we need to emit obj = { y : m.y } regardless of the output target. + if (languageVersion < 2 /* ES6 */ || isNamespaceExportReference(node.name)) { // Emit identifier as an identifier write(": "); - var generatedName = getGeneratedNameForIdentifier(node.name); - if (generatedName) { - write(generatedName); - } - else { - // Even though this is stored as identifier treat it as an expression - // Short-hand, { x }, is equivalent of normal form { x: x } - emitExpressionIdentifier(node.name); - } - } - else if (resolver.getExpressionNameSubstitution(node.name, getGeneratedNameForNode)) { - // Emit identifier as an identifier - write(": "); - // Even though this is stored as identifier treat it as an expression - // Short-hand, { x }, is equivalent of normal form { x: x } - emitExpressionIdentifier(node.name); + emit(node.name); } } function tryEmitConstantValue(node) { @@ -26963,7 +27409,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 156 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 158 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -26997,7 +27443,7 @@ var ts; var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); write("."); var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); - emit(node.name, false); + emit(node.name); decreaseIndentIf(indentedBeforeDot, indentedAfterDot); } function emitQualifiedName(node) { @@ -27015,10 +27461,10 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 174 /* SpreadElementExpression */; }); + return ts.forEach(elements, function (e) { return e.kind === 176 /* SpreadElementExpression */; }); } function skipParentheses(node) { - while (node.kind === 162 /* ParenthesizedExpression */ || node.kind === 161 /* TypeAssertionExpression */) { + while (node.kind === 164 /* ParenthesizedExpression */ || node.kind === 163 /* TypeAssertionExpression */) { node = node.expression; } return node; @@ -27039,13 +27485,13 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 156 /* PropertyAccessExpression */) { + if (expr.kind === 158 /* PropertyAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 157 /* ElementAccessExpression */) { + else if (expr.kind === 159 /* ElementAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("["); @@ -27090,7 +27536,7 @@ var ts; } else { emit(node.expression); - superCall = node.expression.kind === 156 /* PropertyAccessExpression */ && node.expression.expression.kind === 91 /* SuperKeyword */; + superCall = node.expression.kind === 158 /* PropertyAccessExpression */ && node.expression.expression.kind === 91 /* SuperKeyword */; } if (superCall && languageVersion < 2 /* ES6 */) { write(".call("); @@ -27109,23 +27555,21 @@ var ts; } function emitNewExpression(node) { write("new "); - // Spread operator logic can be supported in new expressions in ES5 using a combination + // Spread operator logic is supported in new expressions in ES5 using a combination // of Function.prototype.bind() and Function.prototype.apply(). // // Example: // - // var arguments = [1, 2, 3, 4, 5]; - // new Array(...arguments); + // var args = [1, 2, 3, 4, 5]; + // new Array(...args); // - // Could be transpiled into ES5: + // is compiled into the following ES5: // - // var arguments = [1, 2, 3, 4, 5]; - // new (Array.bind.apply(Array, [void 0].concat(arguments))); + // var args = [1, 2, 3, 4, 5]; + // new (Array.bind.apply(Array, [void 0].concat(args))); // - // `[void 0]` is the first argument which represents `thisArg` to the bind method above. - // And `thisArg` will be set to the return value of the constructor when instantiated - // with the new operator — regardless of any value we set `thisArg` to. Thus, we set it - // to an undefined, `void 0`. + // The 'thisArg' to 'bind' is ignored when invoking the result of 'bind' with 'new', + // Thus, we set it to undefined ('void 0'). if (languageVersion === 1 /* ES5 */ && node.arguments && hasSpreadElement(node.arguments)) { @@ -27161,12 +27605,12 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 164 /* ArrowFunction */) { - if (node.expression.kind === 161 /* TypeAssertionExpression */) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 166 /* ArrowFunction */) { + if (node.expression.kind === 163 /* TypeAssertionExpression */) { var operand = node.expression.expression; // Make sure we consider all nested cast expressions, e.g.: // (-A).x; - while (operand.kind == 161 /* TypeAssertionExpression */) { + while (operand.kind === 163 /* TypeAssertionExpression */) { operand = operand.expression; } // We have an expression of the form: (SubExpr) @@ -27177,14 +27621,14 @@ var ts; // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() // new (A()) should be emitted as new (A()) and not new A() // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () - if (operand.kind !== 168 /* PrefixUnaryExpression */ && - operand.kind !== 167 /* VoidExpression */ && - operand.kind !== 166 /* TypeOfExpression */ && - operand.kind !== 165 /* DeleteExpression */ && - operand.kind !== 169 /* PostfixUnaryExpression */ && - operand.kind !== 159 /* NewExpression */ && - !(operand.kind === 158 /* CallExpression */ && node.parent.kind === 159 /* NewExpression */) && - !(operand.kind === 163 /* FunctionExpression */ && node.parent.kind === 158 /* CallExpression */)) { + if (operand.kind !== 170 /* PrefixUnaryExpression */ && + operand.kind !== 169 /* VoidExpression */ && + operand.kind !== 168 /* TypeOfExpression */ && + operand.kind !== 167 /* DeleteExpression */ && + operand.kind !== 171 /* PostfixUnaryExpression */ && + operand.kind !== 161 /* NewExpression */ && + !(operand.kind === 160 /* CallExpression */ && node.parent.kind === 161 /* NewExpression */) && + !(operand.kind === 165 /* FunctionExpression */ && node.parent.kind === 160 /* CallExpression */)) { emit(operand); return; } @@ -27213,7 +27657,7 @@ var ts; if (!isCurrentFileSystemExternalModule() || node.kind !== 65 /* Identifier */ || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 199 /* VariableDeclaration */ || node.parent.kind === 153 /* BindingElement */); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 201 /* VariableDeclaration */ || node.parent.kind === 155 /* BindingElement */); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -27243,7 +27687,7 @@ var ts; // the resulting expression a prefix increment operation. And in the second, it will make the resulting // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. - if (node.operand.kind === 168 /* PrefixUnaryExpression */) { + if (node.operand.kind === 170 /* PrefixUnaryExpression */) { var operand = node.operand; if (node.operator === 33 /* PlusToken */ && (operand.operator === 33 /* PlusToken */ || operand.operator === 38 /* PlusPlusToken */)) { write(" "); @@ -27299,10 +27743,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 228 /* SourceFile */) { + if (current.kind === 230 /* SourceFile */) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 207 /* ModuleBlock */) { + else if (ts.isFunctionLike(current) || current.kind === 209 /* ModuleBlock */) { return false; } else { @@ -27312,8 +27756,8 @@ var ts; } function emitBinaryExpression(node) { if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 53 /* EqualsToken */ && - (node.left.kind === 155 /* ObjectLiteralExpression */ || node.left.kind === 154 /* ArrayLiteralExpression */)) { - emitDestructuring(node, node.parent.kind === 183 /* ExpressionStatement */); + (node.left.kind === 157 /* ObjectLiteralExpression */ || node.left.kind === 156 /* ArrayLiteralExpression */)) { + emitDestructuring(node, node.parent.kind === 185 /* ExpressionStatement */); } else { var exportChanged = node.operatorToken.kind >= 53 /* FirstAssignment */ && @@ -27365,7 +27809,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 180 /* Block */) { + if (node && node.kind === 182 /* Block */) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -27380,12 +27824,12 @@ var ts; emitToken(14 /* OpenBraceToken */, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 207 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 206 /* ModuleDeclaration */); + if (node.kind === 209 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 208 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 207 /* ModuleBlock */) { + if (node.kind === 209 /* ModuleBlock */) { emitTempDeclarations(true); } decreaseIndent(); @@ -27394,7 +27838,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 180 /* Block */) { + if (node.kind === 182 /* Block */) { write(" "); emit(node); } @@ -27406,7 +27850,7 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 164 /* ArrowFunction */); + emitParenthesizedIf(node.expression, node.expression.kind === 166 /* ArrowFunction */); write(";"); } function emitIfStatement(node) { @@ -27419,7 +27863,7 @@ var ts; if (node.elseStatement) { writeLine(); emitToken(76 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 184 /* IfStatement */) { + if (node.elseStatement.kind === 186 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -27431,7 +27875,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 180 /* Block */) { + if (node.statement.kind === 182 /* Block */) { write(" "); } else { @@ -27506,7 +27950,7 @@ var ts; var endPos = emitToken(82 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer && node.initializer.kind === 200 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 202 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -27527,13 +27971,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 /* ES6 */ && node.kind === 189 /* ForOfStatement */) { + if (languageVersion < 2 /* ES6 */ && node.kind === 191 /* ForOfStatement */) { return emitDownLevelForOfStatement(node); } var endPos = emitToken(82 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer.kind === 200 /* VariableDeclarationList */) { + if (node.initializer.kind === 202 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -27543,7 +27987,7 @@ var ts; else { emit(node.initializer); } - if (node.kind === 188 /* ForInStatement */) { + if (node.kind === 190 /* ForInStatement */) { write(" in "); } else { @@ -27628,7 +28072,7 @@ var ts; // let v = _a[_i]; var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 200 /* VariableDeclarationList */) { + if (node.initializer.kind === 202 /* VariableDeclarationList */) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -27658,7 +28102,7 @@ var ts; // Initializer is an expression. Emit the expression in the body, so that it's // evaluated on every iteration. var assignmentExpression = createBinaryExpression(node.initializer, 53 /* EqualsToken */, rhsIterationValue, false); - if (node.initializer.kind === 154 /* ArrayLiteralExpression */ || node.initializer.kind === 155 /* ObjectLiteralExpression */) { + if (node.initializer.kind === 156 /* ArrayLiteralExpression */ || node.initializer.kind === 157 /* ObjectLiteralExpression */) { // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. emitDestructuring(assignmentExpression, true, undefined); @@ -27669,7 +28113,7 @@ var ts; } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 180 /* Block */) { + if (node.statement.kind === 182 /* Block */) { emitLines(node.statement.statements); } else { @@ -27681,7 +28125,7 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 191 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 193 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } @@ -27726,7 +28170,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 221 /* CaseClause */) { + if (node.kind === 223 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -27781,7 +28225,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 206 /* ModuleDeclaration */); + } while (node && node.kind !== 208 /* ModuleDeclaration */); return node; } function emitContainingModuleName(node) { @@ -27806,7 +28250,7 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(7 /* NumericLiteral */); zero.text = "0"; - var result = ts.createSynthesizedNode(167 /* VoidExpression */); + var result = ts.createSynthesizedNode(169 /* VoidExpression */); result.expression = zero; return result; } @@ -27882,15 +28326,15 @@ var ts; // Also temporary variables should be explicitly allocated for source level declarations when module target is system // because actual variable declarations are hoisted var canDefineTempVariablesInPlace = false; - if (root.kind === 199 /* VariableDeclaration */) { + if (root.kind === 201 /* VariableDeclaration */) { var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 130 /* Parameter */) { + else if (root.kind === 131 /* Parameter */) { canDefineTempVariablesInPlace = true; } - if (root.kind === 170 /* BinaryExpression */) { + if (root.kind === 172 /* BinaryExpression */) { emitAssignmentExpression(root); } else { @@ -27901,8 +28345,7 @@ var ts; if (emitCount++) { write(", "); } - renameNonTopLevelLetAndConst(name); - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 199 /* VariableDeclaration */ || name.parent.kind === 153 /* BindingElement */); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 201 /* VariableDeclaration */ || name.parent.kind === 155 /* BindingElement */); var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(exportFunctionForFile + "(\""); @@ -27937,14 +28380,14 @@ var ts; // we need to generate a temporary variable value = ensureIdentifier(value); // Return the expression 'value === void 0 ? defaultValue : value' - var equals = ts.createSynthesizedNode(170 /* BinaryExpression */); + var equals = ts.createSynthesizedNode(172 /* BinaryExpression */); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(30 /* EqualsEqualsEqualsToken */); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(171 /* ConditionalExpression */); + var cond = ts.createSynthesizedNode(173 /* ConditionalExpression */); cond.condition = condition; cond.questionToken = ts.createSynthesizedNode(50 /* QuestionToken */); cond.whenTrue = whenTrue; @@ -27958,13 +28401,17 @@ var ts; return node; } function createPropertyAccessForDestructuringProperty(object, propName) { - if (propName.kind !== 65 /* Identifier */) { - return createElementAccessExpression(object, propName); + // We create a synthetic copy of the identifier in order to avoid the rewriting that might + // otherwise occur when the identifier is emitted. + var syntheticName = ts.createSynthesizedNode(propName.kind); + syntheticName.text = propName.text; + if (syntheticName.kind !== 65 /* Identifier */) { + return createElementAccessExpression(object, syntheticName); } - return createPropertyAccessExpression(object, propName); + return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(158 /* CallExpression */); + var call = ts.createSynthesizedNode(160 /* CallExpression */); var sliceIdentifier = ts.createSynthesizedNode(65 /* Identifier */); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); @@ -27981,9 +28428,8 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 225 /* PropertyAssignment */ || p.kind === 226 /* ShorthandPropertyAssignment */) { - // TODO(andersh): Computed property support - var propName = (p.name); + if (p.kind === 227 /* PropertyAssignment */ || p.kind === 228 /* ShorthandPropertyAssignment */) { + var propName = p.name; emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } } @@ -27997,8 +28443,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 176 /* OmittedExpression */) { - if (e.kind !== 174 /* SpreadElementExpression */) { + if (e.kind !== 178 /* OmittedExpression */) { + if (e.kind !== 176 /* SpreadElementExpression */) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -28008,14 +28454,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 170 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { + if (target.kind === 172 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 155 /* ObjectLiteralExpression */) { + if (target.kind === 157 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 154 /* ArrayLiteralExpression */) { + else if (target.kind === 156 /* ArrayLiteralExpression */) { emitArrayLiteralAssignment(target, value); } else { @@ -28029,14 +28475,14 @@ var ts; emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 162 /* ParenthesizedExpression */) { + if (root.parent.kind !== 164 /* ParenthesizedExpression */) { write("("); } value = ensureIdentifier(value); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 162 /* ParenthesizedExpression */) { + if (root.parent.kind !== 164 /* ParenthesizedExpression */) { write(")"); } } @@ -28060,12 +28506,12 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 151 /* ObjectBindingPattern */) { + if (pattern.kind === 153 /* ObjectBindingPattern */) { // Rewrite element to a declaration with an initializer that fetches property var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 176 /* OmittedExpression */) { + else if (element.kind !== 178 /* OmittedExpression */) { if (!element.dotDotDotToken) { // Rewrite element to a declaration that accesses array element at index i emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); @@ -28092,7 +28538,6 @@ var ts; } } else { - renameNonTopLevelLetAndConst(node.name); var initializer = node.initializer; if (!initializer && languageVersion < 2 /* ES6 */) { // downlevel emit for non-initialized let bindings defined in loops @@ -28105,8 +28550,8 @@ var ts; (getCombinedFlagsForIdentifier(node.name) & 4096 /* Let */); // NOTE: default initialization should not be added to let bindings in for-in\for-of statements if (isUninitializedLet && - node.parent.parent.kind !== 188 /* ForInStatement */ && - node.parent.parent.kind !== 189 /* ForOfStatement */) { + node.parent.parent.kind !== 190 /* ForInStatement */ && + node.parent.parent.kind !== 191 /* ForOfStatement */) { initializer = createVoidZero(); } } @@ -28124,7 +28569,7 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 176 /* OmittedExpression */) { + if (node.kind === 178 /* OmittedExpression */) { return; } var name = node.name; @@ -28136,56 +28581,15 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 199 /* VariableDeclaration */ && node.parent.kind !== 153 /* BindingElement */)) { + if (!node.parent || (node.parent.kind !== 201 /* VariableDeclaration */ && node.parent.kind !== 155 /* BindingElement */)) { return 0; } return ts.getCombinedNodeFlags(node.parent); } - function renameNonTopLevelLetAndConst(node) { - // do not rename if - // - language version is ES6+ - // - node is synthesized - // - node is not identifier (can happen when tree is malformed) - // - node is definitely not name of variable declaration. - // it still can be part of parameter declaration, this check will be done next - if (languageVersion >= 2 /* ES6 */ || - ts.nodeIsSynthesized(node) || - node.kind !== 65 /* Identifier */ || - (node.parent.kind !== 199 /* VariableDeclaration */ && node.parent.kind !== 153 /* BindingElement */)) { - return; - } - var combinedFlags = getCombinedFlagsForIdentifier(node); - if (((combinedFlags & 12288 /* BlockScoped */) === 0) || combinedFlags & 1 /* Export */) { - // do not rename exported or non-block scoped variables - return; - } - // here it is known that node is a block scoped variable - var list = ts.getAncestor(node, 200 /* VariableDeclarationList */); - if (list.parent.kind === 181 /* VariableStatement */) { - var isSourceFileLevelBinding = list.parent.parent.kind === 228 /* SourceFile */; - var isModuleLevelBinding = list.parent.parent.kind === 207 /* ModuleBlock */; - var isFunctionLevelBinding = list.parent.parent.kind === 180 /* Block */ && ts.isFunctionLike(list.parent.parent.parent); - if (isSourceFileLevelBinding || isModuleLevelBinding || isFunctionLevelBinding) { - return; - } - } - var blockScopeContainer = ts.getEnclosingBlockScopeContainer(node); - var parent = blockScopeContainer.kind === 228 /* SourceFile */ - ? blockScopeContainer - : blockScopeContainer.parent; - if (resolver.resolvesToSomeValue(parent, node.text)) { - var variableId = resolver.getBlockScopedVariableId(node); - if (!blockScopedVariableToGeneratedName) { - blockScopedVariableToGeneratedName = []; - } - var generatedName = makeUniqueName(node.text); - blockScopedVariableToGeneratedName[variableId] = generatedName; - } - } function isES6ExportedDeclaration(node) { return !!(node.flags & 1 /* Export */) && languageVersion >= 2 /* ES6 */ && - node.parent.kind === 228 /* SourceFile */; + node.parent.kind === 230 /* SourceFile */; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -28236,12 +28640,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2 /* ES6 */) { if (ts.isBindingPattern(node.name)) { - var name_23 = createTempVariable(0 /* Auto */); + var name_20 = createTempVariable(0 /* Auto */); if (!tempParameters) { tempParameters = []; } - tempParameters.push(name_23); - emit(name_23); + tempParameters.push(name_20); + emit(name_20); } else { emit(node.name); @@ -28332,12 +28736,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 137 /* GetAccessor */ ? "get " : "set "); - emit(node.name, false); + write(node.kind === 138 /* GetAccessor */ ? "get " : "set "); + emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 164 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; + return node.kind === 166 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; } function emitDeclarationName(node) { if (node.name) { @@ -28348,11 +28752,11 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 163 /* FunctionExpression */) { + if (node.kind === 165 /* FunctionExpression */) { // Emit name if one is present return !!node.name; } - if (node.kind === 201 /* FunctionDeclaration */) { + if (node.kind === 203 /* FunctionDeclaration */) { // Emit name if one is present, or emit generated name in down-level case (for export default case) return !!node.name || languageVersion < 2 /* ES6 */; } @@ -28361,7 +28765,7 @@ var ts; if (ts.nodeIsMissing(node.body)) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 135 /* MethodDeclaration */ && node.kind !== 134 /* MethodSignature */) { + if (node.kind !== 136 /* MethodDeclaration */ && node.kind !== 135 /* MethodSignature */) { // Methods will emit the comments as part of emitting method declaration emitLeadingComments(node); } @@ -28384,10 +28788,10 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 /* ES6 */ && node.kind === 201 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 /* ES6 */ && node.kind === 203 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 135 /* MethodDeclaration */ && node.kind !== 134 /* MethodSignature */) { + if (node.kind !== 136 /* MethodDeclaration */ && node.kind !== 135 /* MethodSignature */) { emitTrailingComments(node); } } @@ -28438,7 +28842,7 @@ var ts; // in that case. write(" { }"); } - else if (node.body.kind === 180 /* Block */) { + else if (node.body.kind === 182 /* Block */) { emitBlockFunctionBody(node, node.body); } else { @@ -28469,10 +28873,10 @@ var ts; write(" "); // Unwrap all type assertions. var current = body; - while (current.kind === 161 /* TypeAssertionExpression */) { + while (current.kind === 163 /* TypeAssertionExpression */) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 155 /* ObjectLiteralExpression */); + emitParenthesizedIf(body, current.kind === 157 /* ObjectLiteralExpression */); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -28548,9 +28952,9 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 183 /* ExpressionStatement */) { + if (statement && statement.kind === 185 /* ExpressionStatement */) { var expr = statement.expression; - if (expr && expr.kind === 158 /* CallExpression */) { + if (expr && expr.kind === 160 /* CallExpression */) { var func = expr.expression; if (func && func.kind === 91 /* SuperKeyword */) { return statement; @@ -28582,7 +28986,7 @@ var ts; emitNodeWithoutSourceMap(memberName); write("]"); } - else if (memberName.kind === 128 /* ComputedPropertyName */) { + else if (memberName.kind === 129 /* ComputedPropertyName */) { emitComputedPropertyName(memberName); } else { @@ -28594,7 +28998,7 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 133 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { + if (member.kind === 134 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { properties.push(member); } } @@ -28634,11 +29038,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 179 /* SemicolonClassElement */) { + if (member.kind === 181 /* SemicolonClassElement */) { writeLine(); write(";"); } - else if (member.kind === 135 /* MethodDeclaration */ || node.kind === 134 /* MethodSignature */) { + else if (member.kind === 136 /* MethodDeclaration */ || node.kind === 135 /* MethodSignature */) { if (!member.body) { return emitOnlyPinnedOrTripleSlashComments(member); } @@ -28657,7 +29061,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 137 /* GetAccessor */ || member.kind === 138 /* SetAccessor */) { + else if (member.kind === 138 /* GetAccessor */ || member.kind === 139 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -28707,22 +29111,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 135 /* MethodDeclaration */ || node.kind === 134 /* MethodSignature */) && !member.body) { + if ((member.kind === 136 /* MethodDeclaration */ || node.kind === 135 /* MethodSignature */) && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - else if (member.kind === 135 /* MethodDeclaration */ || - member.kind === 137 /* GetAccessor */ || - member.kind === 138 /* SetAccessor */) { + else if (member.kind === 136 /* MethodDeclaration */ || + member.kind === 138 /* GetAccessor */ || + member.kind === 139 /* SetAccessor */) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128 /* Static */) { write("static "); } - if (member.kind === 137 /* GetAccessor */) { + if (member.kind === 138 /* GetAccessor */) { write("get "); } - else if (member.kind === 138 /* SetAccessor */) { + else if (member.kind === 139 /* SetAccessor */) { write("set "); } if (member.asteriskToken) { @@ -28733,7 +29137,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 179 /* SemicolonClassElement */) { + else if (member.kind === 181 /* SemicolonClassElement */) { writeLine(); write(";"); } @@ -28758,11 +29162,11 @@ var ts; var hasInstancePropertyWithInitializer = false; // Emit the constructor overload pinned comments ts.forEach(node.members, function (member) { - if (member.kind === 136 /* Constructor */ && !member.body) { + if (member.kind === 137 /* Constructor */ && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } // Check if there is any non-static property assignment - if (member.kind === 133 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { + if (member.kind === 134 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -28870,7 +29274,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { if (thisNodeIsDecorated) { // To preserve the correct runtime semantics when decorators are applied to the class, // the emit needs to follow one of the following rules: @@ -28950,7 +29354,7 @@ var ts; // This keeps the expression as an expression, while ensuring that the static parts // of it have been initialized by the time it is used. var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 175 /* ClassExpression */; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 177 /* ClassExpression */; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0 /* Auto */); @@ -29034,7 +29438,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { // source file level classes in system modules are hoisted so 'var's for them are already defined if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); @@ -29093,11 +29497,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { write(";"); } emitEnd(node); - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { emitExportMemberAssignment(node); } if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile && node.name) { @@ -29189,7 +29593,7 @@ var ts; else { decorators = member.decorators; // we only decorate the parameters here if this is a method - if (member.kind === 135 /* MethodDeclaration */) { + if (member.kind === 136 /* MethodDeclaration */) { functionLikeMember = member; } } @@ -29227,7 +29631,7 @@ var ts; // writeLine(); emitStart(member); - if (member.kind !== 133 /* PropertyDeclaration */) { + if (member.kind !== 134 /* PropertyDeclaration */) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -29257,7 +29661,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 133 /* PropertyDeclaration */) { + if (member.kind !== 134 /* PropertyDeclaration */) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -29299,10 +29703,10 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 135 /* MethodDeclaration */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 133 /* PropertyDeclaration */: + case 136 /* MethodDeclaration */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 134 /* PropertyDeclaration */: return true; } return false; @@ -29312,7 +29716,7 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 135 /* MethodDeclaration */: + case 136 /* MethodDeclaration */: return true; } return false; @@ -29322,9 +29726,9 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 202 /* ClassDeclaration */: - case 135 /* MethodDeclaration */: - case 138 /* SetAccessor */: + case 204 /* ClassDeclaration */: + case 136 /* MethodDeclaration */: + case 139 /* SetAccessor */: return true; } return false; @@ -29335,7 +29739,7 @@ var ts; var argumentsWritten = 0; if (compilerOptions.emitDecoratorMetadata) { if (shouldEmitTypeMetadata(node)) { - var serializedType = resolver.serializeTypeOfNode(node, getGeneratedNameForNode); + var serializedType = resolver.serializeTypeOfNode(node); if (serializedType) { if (writeComma) { write(", "); @@ -29348,7 +29752,7 @@ var ts; } } if (shouldEmitParamTypesMetadata(node)) { - var serializedTypes = resolver.serializeParameterTypesOfNode(node, getGeneratedNameForNode); + var serializedTypes = resolver.serializeParameterTypesOfNode(node); if (serializedTypes) { if (writeComma || argumentsWritten) { write(", "); @@ -29366,7 +29770,7 @@ var ts; } } if (shouldEmitReturnTypeMetadata(node)) { - var serializedType = resolver.serializeReturnTypeOfNode(node, getGeneratedNameForNode); + var serializedType = resolver.serializeReturnTypeOfNode(node); if (serializedType) { if (writeComma || argumentsWritten) { write(", "); @@ -29500,7 +29904,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 206 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 208 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -29536,7 +29940,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 207 /* ModuleBlock */) { + if (node.body.kind === 209 /* ModuleBlock */) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -29594,16 +29998,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 209 /* ImportEqualsDeclaration */) { + if (node.kind === 211 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 212 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 214 /* NamespaceImport */) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 210 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + return node.kind === 212 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -29631,7 +30035,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 212 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 214 /* NamespaceImport */) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -29657,7 +30061,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 209 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; + var isExportedImport = node.kind === 211 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2 /* AMD */) { emitLeadingComments(node); @@ -29676,7 +30080,7 @@ var ts; // import { x, y } from "foo" // import d, * as x from "foo" // import d, { x, y } from "foo" - var isNakedImport = 210 /* ImportDeclaration */ && !node.importClause; + var isNakedImport = 212 /* ImportDeclaration */ && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -29840,8 +30244,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 201 /* FunctionDeclaration */ && - expression.kind !== 202 /* ClassDeclaration */) { + if (expression.kind !== 203 /* FunctionDeclaration */ && + expression.kind !== 204 /* ClassDeclaration */) { write(";"); } emitEnd(node); @@ -29877,7 +30281,7 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { // import "mod" @@ -29887,13 +30291,13 @@ var ts; externalImports.push(node); } break; - case 209 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 220 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { + case 211 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 222 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { // import x = require("mod") where x is referenced externalImports.push(node); } break; - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -29909,12 +30313,12 @@ var ts; // export { x, y } for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; - var name_24 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_24] || (exportSpecifiers[name_24] = [])).push(specifier); + var name_21 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_21] || (exportSpecifiers[name_21] = [])).push(specifier); } } break; - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -29935,13 +30339,16 @@ var ts; write("}"); } } - function getLocalNameForExternalImport(importNode) { - var namespaceDeclaration = getNamespaceDeclarationNode(importNode); - if (namespaceDeclaration && !isDefaultImport(importNode)) { + function getLocalNameForExternalImport(node) { + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - else { - return getGeneratedNameForNode(importNode); + if (node.kind === 212 /* ImportDeclaration */ && node.importClause) { + return getGeneratedNameForNode(node); + } + if (node.kind === 218 /* ExportDeclaration */ && node.moduleSpecifier) { + return getGeneratedNameForNode(node); } } function getExternalModuleNameText(importNode) { @@ -29960,8 +30367,8 @@ var ts; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; // do not create variable declaration for exports and imports that lack import clause - var skipNode = importNode.kind === 216 /* ExportDeclaration */ || - (importNode.kind === 210 /* ImportDeclaration */ && !importNode.importClause); + var skipNode = importNode.kind === 218 /* ExportDeclaration */ || + (importNode.kind === 212 /* ImportDeclaration */ && !importNode.importClause); if (skipNode) { continue; } @@ -29994,7 +30401,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 216 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 218 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -30026,7 +30433,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 216 /* ExportDeclaration */) { + if (externalImport.kind !== 218 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -30110,12 +30517,12 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_25 = local.kind === 65 /* Identifier */ + var name_22 = local.kind === 65 /* Identifier */ ? local : local.name; - if (name_25) { + if (name_22) { // do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables - var text = ts.unescapeIdentifier(name_25.text); + var text = ts.unescapeIdentifier(name_22.text); if (ts.hasProperty(seen, text)) { continue; } @@ -30126,7 +30533,7 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 202 /* ClassDeclaration */ || local.kind === 206 /* ModuleDeclaration */ || local.kind === 205 /* EnumDeclaration */) { + if (local.kind === 204 /* ClassDeclaration */ || local.kind === 208 /* ModuleDeclaration */ || local.kind === 207 /* EnumDeclaration */) { emitDeclarationName(local); } else { @@ -30160,21 +30567,21 @@ var ts; if (node.flags & 2 /* Ambient */) { return; } - if (node.kind === 201 /* FunctionDeclaration */) { + if (node.kind === 203 /* FunctionDeclaration */) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 202 /* ClassDeclaration */) { + if (node.kind === 204 /* ClassDeclaration */) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 205 /* EnumDeclaration */) { + if (node.kind === 207 /* EnumDeclaration */) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -30183,7 +30590,7 @@ var ts; } return; } - if (node.kind === 206 /* ModuleDeclaration */) { + if (node.kind === 208 /* ModuleDeclaration */) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -30192,17 +30599,17 @@ var ts; } return; } - if (node.kind === 199 /* VariableDeclaration */ || node.kind === 153 /* BindingElement */) { + if (node.kind === 201 /* VariableDeclaration */ || node.kind === 155 /* BindingElement */) { if (shouldHoistVariable(node, false)) { - var name_26 = node.name; - if (name_26.kind === 65 /* Identifier */) { + var name_23 = node.name; + if (name_23.kind === 65 /* Identifier */) { if (!hoistedVars) { hoistedVars = []; } - hoistedVars.push(name_26); + hoistedVars.push(name_23); } else { - ts.forEachChild(name_26, visit); + ts.forEachChild(name_23, visit); } } return; @@ -30226,7 +30633,7 @@ var ts; // if block scoped variables are nested in some another block then // no other functions can use them except ones that are defined at least in the same block return (ts.getCombinedNodeFlags(node) & 12288 /* BlockScoped */) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 228 /* SourceFile */; + ts.getEnclosingBlockScopeContainer(node).kind === 230 /* SourceFile */; } function isCurrentFileSystemExternalModule() { return compilerOptions.module === 4 /* System */ && ts.isExternalModule(currentSourceFile); @@ -30279,10 +30686,10 @@ var ts; emitSetters(exportStarFunction); writeLine(); emitExecute(node, startIndex); - emitTempDeclarations(true); decreaseIndent(); writeLine(); write("}"); // return + emitTempDeclarations(true); } function emitSetters(exportStarFunction) { write("setters:["); @@ -30297,21 +30704,21 @@ var ts; var parameterName = "_" + importVariableName; write("function (" + parameterName + ") {"); switch (importNode.kind) { - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: if (!importNode.importClause) { // 'import "..."' case // module is imported only for side-effects, setter body will be empty break; } // fall-through - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== ""); increaseIndent(); writeLine(); // save import into the local write(importVariableName + " = " + parameterName + ";"); writeLine(); - var defaultName = importNode.kind === 210 /* ImportDeclaration */ + var defaultName = importNode.kind === 212 /* ImportDeclaration */ ? importNode.importClause.name : importNode.name; if (defaultName) { @@ -30323,10 +30730,10 @@ var ts; emitExportMemberAssignments(defaultName); writeLine(); } - if (importNode.kind === 210 /* ImportDeclaration */ && + if (importNode.kind === 212 /* ImportDeclaration */ && importNode.importClause.namedBindings) { var namedBindings = importNode.importClause.namedBindings; - if (namedBindings.kind === 212 /* NamespaceImport */) { + if (namedBindings.kind === 214 /* NamespaceImport */) { // emit re-export for namespace // import * as n from 'foo' // export {n} @@ -30346,7 +30753,7 @@ var ts; } decreaseIndent(); break; - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== ""); increaseIndent(); if (importNode.exportClause) { @@ -30389,10 +30796,10 @@ var ts; // - imports/exports are not emitted for system modules // - function declarations are not emitted because they were already hoisted switch (statement.kind) { - case 216 /* ExportDeclaration */: - case 210 /* ImportDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 201 /* FunctionDeclaration */: + case 218 /* ExportDeclaration */: + case 212 /* ImportDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 203 /* FunctionDeclaration */: continue; } writeLine(); @@ -30415,7 +30822,11 @@ var ts; ts.Debug.assert(!exportFunctionForFile); // make sure that name of 'exports' function does not conflict with existing identifiers exportFunctionForFile = makeUniqueName("exports"); - write("System.register(["); + write("System.register("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + write("["); for (var i = 0; i < externalImports.length; ++i) { var text = getExternalModuleNameText(externalImports[i]); if (i !== 0) { @@ -30495,8 +30906,8 @@ var ts; collectExternalModuleInfo(node); writeLine(); write("define("); - if (node.amdModuleName) { - write("\"" + node.amdModuleName + "\", "); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); } emitAMDDependencies(node, true); write(") {"); @@ -30634,7 +31045,7 @@ var ts; } emitLeadingComments(node.endOfFileToken); } - function emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers) { + function emitNodeWithoutSourceMap(node) { if (!node) { return; } @@ -30645,7 +31056,7 @@ var ts; if (emitComments) { emitLeadingComments(node); } - emitJavaScriptWorker(node, allowGeneratedIdentifiers); + emitJavaScriptWorker(node); if (emitComments) { emitTrailingComments(node); } @@ -30654,20 +31065,20 @@ var ts; switch (node.kind) { // All of these entities are emitted in a specialized fashion. As such, we allow // the specialized methods for each to handle the comments on the nodes. - case 203 /* InterfaceDeclaration */: - case 201 /* FunctionDeclaration */: - case 210 /* ImportDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 215 /* ExportAssignment */: + case 205 /* InterfaceDeclaration */: + case 203 /* FunctionDeclaration */: + case 212 /* ImportDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 217 /* ExportAssignment */: return false; - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: // Only emit the leading/trailing comments for a module if we're actually // emitting the module as well. return shouldEmitModuleDeclaration(node); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: // Only emit the leading/trailing comments for an enum if we're actually // emitting the module as well. return shouldEmitEnumDeclaration(node); @@ -30676,9 +31087,9 @@ var ts; // then we don't want to emit comments when we emit the body. It will have already // been taken care of when we emitted the 'return' statement for the function // expression body. - if (node.kind !== 180 /* Block */ && + if (node.kind !== 182 /* Block */ && node.parent && - node.parent.kind === 164 /* ArrowFunction */ && + node.parent.kind === 166 /* ArrowFunction */ && node.parent.body === node && compilerOptions.target <= 1 /* ES5 */) { return false; @@ -30686,19 +31097,18 @@ var ts; // Emit comments for everything else. return true; } - function emitJavaScriptWorker(node, allowGeneratedIdentifiers) { - if (allowGeneratedIdentifiers === void 0) { allowGeneratedIdentifiers = true; } + function emitJavaScriptWorker(node) { // Check if the node can be emitted regardless of the ScriptTarget switch (node.kind) { case 65 /* Identifier */: - return emitIdentifier(node, allowGeneratedIdentifiers); - case 130 /* Parameter */: + return emitIdentifier(node); + case 131 /* Parameter */: return emitParameter(node); - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return emitMethod(node); - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: return emitAccessor(node); case 93 /* ThisKeyword */: return emitThis(node); @@ -30718,131 +31128,131 @@ var ts; case 12 /* TemplateMiddle */: case 13 /* TemplateTail */: return emitLiteral(node); - case 172 /* TemplateExpression */: + case 174 /* TemplateExpression */: return emitTemplateExpression(node); - case 178 /* TemplateSpan */: + case 180 /* TemplateSpan */: return emitTemplateSpan(node); - case 127 /* QualifiedName */: + case 128 /* QualifiedName */: return emitQualifiedName(node); - case 151 /* ObjectBindingPattern */: + case 153 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 152 /* ArrayBindingPattern */: + case 154 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 153 /* BindingElement */: + case 155 /* BindingElement */: return emitBindingElement(node); - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: return emitArrayLiteral(node); - case 155 /* ObjectLiteralExpression */: + case 157 /* ObjectLiteralExpression */: return emitObjectLiteral(node); - case 225 /* PropertyAssignment */: + case 227 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 226 /* ShorthandPropertyAssignment */: + case 228 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 128 /* ComputedPropertyName */: + case 129 /* ComputedPropertyName */: return emitComputedPropertyName(node); - case 156 /* PropertyAccessExpression */: + case 158 /* PropertyAccessExpression */: return emitPropertyAccess(node); - case 157 /* ElementAccessExpression */: + case 159 /* ElementAccessExpression */: return emitIndexedAccess(node); - case 158 /* CallExpression */: + case 160 /* CallExpression */: return emitCallExpression(node); - case 159 /* NewExpression */: + case 161 /* NewExpression */: return emitNewExpression(node); - case 160 /* TaggedTemplateExpression */: + case 162 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: return emit(node.expression); - case 162 /* ParenthesizedExpression */: + case 164 /* ParenthesizedExpression */: return emitParenExpression(node); - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 165 /* DeleteExpression */: + case 167 /* DeleteExpression */: return emitDeleteExpression(node); - case 166 /* TypeOfExpression */: + case 168 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 167 /* VoidExpression */: + case 169 /* VoidExpression */: return emitVoidExpression(node); - case 168 /* PrefixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 169 /* PostfixUnaryExpression */: + case 171 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return emitBinaryExpression(node); - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: return emitConditionalExpression(node); - case 174 /* SpreadElementExpression */: + case 176 /* SpreadElementExpression */: return emitSpreadElementExpression(node); - case 173 /* YieldExpression */: + case 175 /* YieldExpression */: return emitYieldExpression(node); - case 176 /* OmittedExpression */: + case 178 /* OmittedExpression */: return; - case 180 /* Block */: - case 207 /* ModuleBlock */: + case 182 /* Block */: + case 209 /* ModuleBlock */: return emitBlock(node); - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: return emitVariableStatement(node); - case 182 /* EmptyStatement */: + case 184 /* EmptyStatement */: return write(";"); - case 183 /* ExpressionStatement */: + case 185 /* ExpressionStatement */: return emitExpressionStatement(node); - case 184 /* IfStatement */: + case 186 /* IfStatement */: return emitIfStatement(node); - case 185 /* DoStatement */: + case 187 /* DoStatement */: return emitDoStatement(node); - case 186 /* WhileStatement */: + case 188 /* WhileStatement */: return emitWhileStatement(node); - case 187 /* ForStatement */: + case 189 /* ForStatement */: return emitForStatement(node); - case 189 /* ForOfStatement */: - case 188 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 190 /* ForInStatement */: return emitForInOrForOfStatement(node); - case 190 /* ContinueStatement */: - case 191 /* BreakStatement */: + case 192 /* ContinueStatement */: + case 193 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 192 /* ReturnStatement */: + case 194 /* ReturnStatement */: return emitReturnStatement(node); - case 193 /* WithStatement */: + case 195 /* WithStatement */: return emitWithStatement(node); - case 194 /* SwitchStatement */: + case 196 /* SwitchStatement */: return emitSwitchStatement(node); - case 221 /* CaseClause */: - case 222 /* DefaultClause */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: return emitLabelledStatement(node); - case 196 /* ThrowStatement */: + case 198 /* ThrowStatement */: return emitThrowStatement(node); - case 197 /* TryStatement */: + case 199 /* TryStatement */: return emitTryStatement(node); - case 224 /* CatchClause */: + case 226 /* CatchClause */: return emitCatchClause(node); - case 198 /* DebuggerStatement */: + case 200 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 199 /* VariableDeclaration */: + case 201 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 175 /* ClassExpression */: + case 177 /* ClassExpression */: return emitClassExpression(node); - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: return emitClassDeclaration(node); - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 227 /* EnumMember */: + case 229 /* EnumMember */: return emitEnumMember(node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: return emitImportDeclaration(node); - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: return emitExportDeclaration(node); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: return emitExportAssignment(node); - case 228 /* SourceFile */: + case 230 /* SourceFile */: return emitSourceFileNode(node); } } @@ -30874,7 +31284,7 @@ var ts; function getLeadingCommentsToEmit(node) { // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 228 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 230 /* SourceFile */ || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { // get comments without detached comments return getLeadingCommentsWithoutDetachedComments(); @@ -30889,7 +31299,7 @@ var ts; function getTrailingCommentsToEmit(node) { // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 228 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 230 /* SourceFile */ || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } @@ -31086,7 +31496,7 @@ var ts; } ts.createCompilerHost = createCompilerHost; function getPreEmitDiagnostics(program, sourceFile) { - var diagnostics = program.getSyntacticDiagnostics(sourceFile).concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics(sourceFile)); + var diagnostics = program.getOptionsDiagnostics().concat(program.getSyntacticDiagnostics(sourceFile), program.getGlobalDiagnostics(), program.getSemanticDiagnostics(sourceFile)); if (program.getCompilerOptions().declaration) { diagnostics.concat(program.getDeclarationDiagnostics(sourceFile)); } @@ -31119,16 +31529,21 @@ var ts; function createProgram(rootNames, options, host) { var program; var files = []; - var filesByName = {}; var diagnostics = ts.createDiagnosticCollection(); - var seenNoDefaultLib = options.noLib; var commonSourceDirectory; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; + var classifiableNames; + var skipDefaultLib = options.noLib; var start = new Date().getTime(); host = host || createCompilerHost(options); + var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); }); ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - if (!seenNoDefaultLib) { + // Do not process the default library if: + // - The '--noLib' flag is used. + // - A 'no-default-lib' reference comment is encountered in + // processing the root files. + if (!skipDefaultLib) { processRootFile(host.getDefaultLibFileName(options), true); } verifyCompilerOptions(); @@ -31138,11 +31553,12 @@ var ts; getSourceFiles: function () { return files; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, + getOptionsDiagnostics: getOptionsDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, getSemanticDiagnostics: getSemanticDiagnostics, getDeclarationDiagnostics: getDeclarationDiagnostics, - getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics, getTypeChecker: getTypeChecker, + getClassifiableNames: getClassifiableNames, getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker, getCommonSourceDirectory: function () { return commonSourceDirectory; }, emit: emit, @@ -31153,6 +31569,18 @@ var ts; getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); } }; return program; + function getClassifiableNames() { + if (!classifiableNames) { + // Initialize a checker so that all our files are bound. + getTypeChecker(); + classifiableNames = {}; + for (var _i = 0; _i < files.length; _i++) { + var sourceFile = files[_i]; + ts.copyMap(sourceFile.classifiableNames, classifiableNames); + } + } + return classifiableNames; + } function getEmitHost(writeFileCallback) { return { getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, @@ -31192,8 +31620,7 @@ var ts; return emitResult; } function getSourceFile(fileName) { - fileName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - return ts.hasProperty(filesByName, fileName) ? filesByName[fileName] : undefined; + return filesByName.get(fileName); } function getDiagnosticsHelper(sourceFile, getDiagnostics) { if (sourceFile) { @@ -31233,16 +31660,14 @@ var ts; return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); } } - function getCompilerOptionsDiagnostics() { + function getOptionsDiagnostics() { var allDiagnostics = []; ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function getGlobalDiagnostics() { - var typeChecker = getDiagnosticsProducingTypeChecker(); var allDiagnostics = []; - ts.addRange(allDiagnostics, typeChecker.getGlobalDiagnostics()); - ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); + ts.addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function hasExtension(fileName) { @@ -31276,14 +31701,17 @@ var ts; } } else { - if (options.allowNonTsExtensions && !findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd)) { - diagnostic = ts.Diagnostics.File_0_not_found; - diagnosticArgument = [fileName]; - } - else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, isDefaultLib, refFile, refPos, refEnd); })) { - diagnostic = ts.Diagnostics.File_0_not_found; - fileName += ".ts"; - diagnosticArgument = [fileName]; + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd); + if (!nonTsFile) { + if (options.allowNonTsExtensions) { + diagnostic = ts.Diagnostics.File_0_not_found; + diagnosticArgument = [fileName]; + } + else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, isDefaultLib, refFile, refPos, refEnd); })) { + diagnostic = ts.Diagnostics.File_0_not_found; + fileName += ".ts"; + diagnosticArgument = [fileName]; + } } } if (diagnostic) { @@ -31298,18 +31726,18 @@ var ts; // Get source file from normalized fileName function findSourceFile(fileName, isDefaultLib, refFile, refStart, refLength) { var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - if (ts.hasProperty(filesByName, canonicalName)) { + if (filesByName.contains(canonicalName)) { // We've already looked for this file, use cached result return getSourceFileFromCache(fileName, canonicalName, false); } else { var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); - if (ts.hasProperty(filesByName, canonicalAbsolutePath)) { + if (filesByName.contains(canonicalAbsolutePath)) { return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); } // We haven't looked for this file, do so now and cache result - var file = filesByName[canonicalName] = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { if (refFile) { diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } @@ -31317,16 +31745,18 @@ var ts; diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } }); + filesByName.set(canonicalName, file); if (file) { - seenNoDefaultLib = seenNoDefaultLib || file.hasNoDefaultLib; + skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; // Set the source file for normalized absolute path - filesByName[canonicalAbsolutePath] = file; + filesByName.set(canonicalAbsolutePath, file); if (!options.noResolve) { var basePath = ts.getDirectoryPath(fileName); processReferencedFiles(file, basePath); processImportedModules(file, basePath); } if (isDefaultLib) { + file.isDefaultLib = true; files.unshift(file); } else { @@ -31336,7 +31766,7 @@ var ts; return file; } function getSourceFileFromCache(fileName, canonicalName, useAbsolutePath) { - var file = filesByName[canonicalName]; + var file = filesByName.get(canonicalName); if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { @@ -31354,7 +31784,7 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 210 /* ImportDeclaration */ || node.kind === 209 /* ImportEqualsDeclaration */ || node.kind === 216 /* ExportDeclaration */) { + if (node.kind === 212 /* ImportDeclaration */ || node.kind === 211 /* ImportEqualsDeclaration */ || node.kind === 218 /* ExportDeclaration */) { var moduleNameExpr = ts.getExternalModuleName(node); if (moduleNameExpr && moduleNameExpr.kind === 8 /* StringLiteral */) { var moduleNameText = moduleNameExpr.text; @@ -31375,7 +31805,7 @@ var ts; } } } - else if (node.kind === 206 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { + else if (node.kind === 208 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { // TypeScript 1.0 spec (April 2014): 12.1.6 // An AmbientExternalModuleDeclaration declares an external module. // This type of declaration is permitted only in the global module. @@ -31656,9 +32086,14 @@ var ts; name: "noResolve", type: "boolean" }, + { + name: "skipDefaultLibCheck", + type: "boolean" + }, { name: "out", type: "string", + isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: ts.Diagnostics.FILE }, @@ -32033,7 +32468,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 164 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 166 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -32045,30 +32480,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 180 /* Block */: + case 182 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_7 = n.parent; + var parent_8 = n.parent; var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collaps the block, but consider its hint span // to be the entire span of the parent. - if (parent_7.kind === 185 /* DoStatement */ || - parent_7.kind === 188 /* ForInStatement */ || - parent_7.kind === 189 /* ForOfStatement */ || - parent_7.kind === 187 /* ForStatement */ || - parent_7.kind === 184 /* IfStatement */ || - parent_7.kind === 186 /* WhileStatement */ || - parent_7.kind === 193 /* WithStatement */ || - parent_7.kind === 224 /* CatchClause */) { - addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); + if (parent_8.kind === 187 /* DoStatement */ || + parent_8.kind === 190 /* ForInStatement */ || + parent_8.kind === 191 /* ForOfStatement */ || + parent_8.kind === 189 /* ForStatement */ || + parent_8.kind === 186 /* IfStatement */ || + parent_8.kind === 188 /* WhileStatement */ || + parent_8.kind === 195 /* WithStatement */ || + parent_8.kind === 226 /* CatchClause */) { + addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_7.kind === 197 /* TryStatement */) { + if (parent_8.kind === 199 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_7; + var tryStatement = parent_8; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -32091,23 +32526,23 @@ var ts; break; } // Fallthrough. - case 207 /* ModuleBlock */: { + case 209 /* ModuleBlock */: { var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 155 /* ObjectLiteralExpression */: - case 208 /* CaseBlock */: { + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 157 /* ObjectLiteralExpression */: + case 210 /* CaseBlock */: { var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 18 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -32135,12 +32570,12 @@ var ts; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_27 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_27); + for (var name_24 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_24); if (declarations) { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_27); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_24); if (!matches) { continue; } @@ -32153,14 +32588,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_27); + matches = patternMatcher.getMatches(containers, name_24); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_27, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_24, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -32198,7 +32633,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 128 /* ComputedPropertyName */) { + else if (declaration.name.kind === 129 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -32219,7 +32654,7 @@ var ts; } return true; } - if (expression.kind === 156 /* PropertyAccessExpression */) { + if (expression.kind === 158 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -32232,7 +32667,7 @@ var ts; var containers = []; // First, if we started with a computed property name, then add all but the last // portion into the container array. - if (declaration.name.kind === 128 /* ComputedPropertyName */) { + if (declaration.name.kind === 129 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -32308,17 +32743,17 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: // If we have a module declared as A.B.C, it is more "intuitive" // to say it only has a single layer of depth do { current = current.parent; - } while (current.kind === 206 /* ModuleDeclaration */); + } while (current.kind === 208 /* ModuleDeclaration */); // fall through - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: - case 203 /* InterfaceDeclaration */: - case 201 /* FunctionDeclaration */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 205 /* InterfaceDeclaration */: + case 203 /* FunctionDeclaration */: indent++; } current = current.parent; @@ -32329,21 +32764,21 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: ts.forEach(node.declarationList.declarations, visit); break; - case 151 /* ObjectBindingPattern */: - case 152 /* ArrayBindingPattern */: + case 153 /* ObjectBindingPattern */: + case 154 /* ArrayBindingPattern */: ts.forEach(node.elements, visit); break; - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -32355,7 +32790,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 212 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 214 /* NamespaceImport */) { childNodes.push(importClause.namedBindings); } else { @@ -32364,21 +32799,21 @@ var ts; } } break; - case 153 /* BindingElement */: - case 199 /* VariableDeclaration */: + case 155 /* BindingElement */: + case 201 /* VariableDeclaration */: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } // Fall through - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: - case 203 /* InterfaceDeclaration */: - case 206 /* ModuleDeclaration */: - case 201 /* FunctionDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 214 /* ImportSpecifier */: - case 218 /* ExportSpecifier */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 205 /* InterfaceDeclaration */: + case 208 /* ModuleDeclaration */: + case 203 /* FunctionDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 216 /* ImportSpecifier */: + case 220 /* ExportSpecifier */: childNodes.push(node); break; } @@ -32426,17 +32861,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: - case 203 /* InterfaceDeclaration */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 205 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -32447,12 +32882,12 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 201 /* FunctionDeclaration */) { + if (functionDeclaration.kind === 203 /* FunctionDeclaration */) { // A function declaration is 'top level' if it contains any function declarations // within it. - if (functionDeclaration.body && functionDeclaration.body.kind === 180 /* Block */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 182 /* Block */) { // Proper function declarations can only have identifier names - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 201 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 203 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { return true; } // Or if it is not parented by another function. i.e all functions @@ -32512,7 +32947,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 130 /* Parameter */: + case 131 /* Parameter */: if (ts.isBindingPattern(node.name)) { break; } @@ -32520,36 +32955,36 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 137 /* GetAccessor */: + case 138 /* GetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 138 /* SetAccessor */: + case 139 /* SetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 141 /* IndexSignature */: + case 142 /* IndexSignature */: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 227 /* EnumMember */: + case 229 /* EnumMember */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 139 /* CallSignature */: + case 140 /* CallSignature */: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 140 /* ConstructSignature */: + case 141 /* ConstructSignature */: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: var variableDeclarationNode; - var name_28; - if (node.kind === 153 /* BindingElement */) { - name_28 = node.name; + var name_25; + if (node.kind === 155 /* BindingElement */) { + name_25 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration - while (variableDeclarationNode && variableDeclarationNode.kind !== 199 /* VariableDeclaration */) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 201 /* VariableDeclaration */) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -32557,24 +32992,24 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_28 = node.name; + name_25 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_28), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_28), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_28), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.variableElement); } - case 136 /* Constructor */: + case 137 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 218 /* ExportSpecifier */: - case 214 /* ImportSpecifier */: - case 209 /* ImportEqualsDeclaration */: - case 211 /* ImportClause */: - case 212 /* NamespaceImport */: + case 220 /* ExportSpecifier */: + case 216 /* ImportSpecifier */: + case 211 /* ImportEqualsDeclaration */: + case 213 /* ImportClause */: + case 214 /* NamespaceImport */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -32604,17 +33039,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 228 /* SourceFile */: + case 230 /* SourceFile */: return createSourceFileItem(node); - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: return createClassItem(node); - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: return createEnumItem(node); - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return createIterfaceItem(node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return createModuleItem(node); - case 201 /* FunctionDeclaration */: + case 203 /* FunctionDeclaration */: return createFunctionItem(node); } return undefined; @@ -32626,7 +33061,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 206 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 208 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -32638,7 +33073,7 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.body && node.body.kind === 180 /* Block */) { + if (node.body && node.body.kind === 182 /* Block */) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -32659,7 +33094,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 136 /* Constructor */ && member; + return member.kind === 137 /* Constructor */ && member; }); // Add the constructor parameters in as children of the class (for property parameters). // Note that *all non-binding pattern named* parameters will be added to the nodes array, but parameters that @@ -32683,7 +33118,7 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 128 /* ComputedPropertyName */; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 129 /* ComputedPropertyName */; }); } /** * Like removeComputedProperties, but retains the properties with well known symbol names @@ -32692,13 +33127,13 @@ var ts; return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 206 /* ModuleDeclaration */) { + while (node.body.kind === 208 /* ModuleDeclaration */) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 228 /* SourceFile */ + return node.kind === 230 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -33213,7 +33648,7 @@ var ts; var hasTransitionFromUpperToLower = transitionFromUpperToLower(identifier, word, i, wordStart); if (charIsPunctuation(identifier.charCodeAt(i - 1)) || charIsPunctuation(identifier.charCodeAt(i)) || - lastIsDigit != currentIsDigit || + lastIsDigit !== currentIsDigit || hasTransitionFromLowerToUpper || hasTransitionFromUpperToLower) { if (!isAllPunctuation(identifier, wordStart, i)) { @@ -33274,7 +33709,7 @@ var ts; // 3) HTMLDocument -> HTML, Document // // etc. - if (index != wordStart && + if (index !== wordStart && index + 1 < identifier.length) { var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index)); var nextIsLower = isLowerCaseLetter(identifier.charCodeAt(index + 1)); @@ -33493,7 +33928,7 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 158 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 160 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. @@ -33501,7 +33936,7 @@ var ts; var expression = callExpression.expression; var name = expression.kind === 65 /* Identifier */ ? expression - : expression.kind === 156 /* PropertyAccessExpression */ + : expression.kind === 158 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -33534,7 +33969,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 158 /* CallExpression */ || node.parent.kind === 159 /* NewExpression */) { + if (node.parent.kind === 160 /* CallExpression */ || node.parent.kind === 161 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -33587,25 +34022,25 @@ var ts; }; } } - else if (node.kind === 10 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 160 /* TaggedTemplateExpression */) { + else if (node.kind === 10 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 162 /* TaggedTemplateExpression */) { // Check if we're actually inside the template; // otherwise we'll fall out and return undefined. if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0); } } - else if (node.kind === 11 /* TemplateHead */ && node.parent.parent.kind === 160 /* TaggedTemplateExpression */) { + else if (node.kind === 11 /* TemplateHead */ && node.parent.parent.kind === 162 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 172 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 174 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 178 /* TemplateSpan */ && node.parent.parent.parent.kind === 160 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 180 /* TemplateSpan */ && node.parent.parent.parent.kind === 162 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 172 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 174 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. if (node.kind === 13 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; @@ -33723,7 +34158,7 @@ var ts; // // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 172 /* TemplateExpression */) { + if (template.kind === 174 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -33732,7 +34167,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 228 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 230 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -33933,40 +34368,40 @@ var ts; return false; } switch (n.kind) { - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 155 /* ObjectLiteralExpression */: - case 151 /* ObjectBindingPattern */: - case 146 /* TypeLiteral */: - case 180 /* Block */: - case 207 /* ModuleBlock */: - case 208 /* CaseBlock */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 157 /* ObjectLiteralExpression */: + case 153 /* ObjectBindingPattern */: + case 148 /* TypeLiteral */: + case 182 /* Block */: + case 209 /* ModuleBlock */: + case 210 /* CaseBlock */: return nodeEndsWith(n, 15 /* CloseBraceToken */, sourceFile); - case 224 /* CatchClause */: + case 226 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 159 /* NewExpression */: + case 161 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 158 /* CallExpression */: - case 162 /* ParenthesizedExpression */: - case 150 /* ParenthesizedType */: + case 160 /* CallExpression */: + case 164 /* ParenthesizedExpression */: + case 152 /* ParenthesizedType */: return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); - case 143 /* FunctionType */: - case 144 /* ConstructorType */: + case 145 /* FunctionType */: + case 146 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 140 /* ConstructSignature */: - case 139 /* CallSignature */: - case 164 /* ArrowFunction */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 141 /* ConstructSignature */: + case 140 /* CallSignature */: + case 166 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -33976,63 +34411,63 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 17 /* CloseParenToken */, sourceFile); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 184 /* IfStatement */: + case 186 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 183 /* ExpressionStatement */: + case 185 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile); - case 154 /* ArrayLiteralExpression */: - case 152 /* ArrayBindingPattern */: - case 157 /* ElementAccessExpression */: - case 128 /* ComputedPropertyName */: - case 148 /* TupleType */: + case 156 /* ArrayLiteralExpression */: + case 154 /* ArrayBindingPattern */: + case 159 /* ElementAccessExpression */: + case 129 /* ComputedPropertyName */: + case 150 /* TupleType */: return nodeEndsWith(n, 19 /* CloseBracketToken */, sourceFile); - case 141 /* IndexSignature */: + case 142 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); - case 221 /* CaseClause */: - case 222 /* DefaultClause */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed return false; - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 186 /* WhileStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 188 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 185 /* DoStatement */: + case 187 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; var hasWhileKeyword = findChildOfKind(n, 100 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 145 /* TypeQuery */: + case 147 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 166 /* TypeOfExpression */: - case 165 /* DeleteExpression */: - case 167 /* VoidExpression */: - case 173 /* YieldExpression */: - case 174 /* SpreadElementExpression */: + case 168 /* TypeOfExpression */: + case 167 /* DeleteExpression */: + case 169 /* VoidExpression */: + case 175 /* YieldExpression */: + case 176 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 160 /* TaggedTemplateExpression */: + case 162 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 172 /* TemplateExpression */: + case 174 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 178 /* TemplateSpan */: + case 180 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 168 /* PrefixUnaryExpression */: + case 170 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 170 /* BinaryExpression */: + case 172 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 171 /* ConditionalExpression */: + case 173 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -34088,7 +34523,7 @@ var ts; // for the position of the relevant node (or comma). var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { // find syntax list that covers the span of the node - if (c.kind === 251 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 253 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -34222,7 +34657,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 228 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 230 /* SourceFile */); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -34266,17 +34701,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 142 /* TypeReference */ || node.kind === 158 /* CallExpression */) { + if (node.kind === 144 /* TypeReference */ || node.kind === 160 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 202 /* ClassDeclaration */ || node.kind === 203 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 204 /* ClassDeclaration */ || node.kind === 205 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 126 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 127 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { @@ -34331,7 +34766,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 130 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 131 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -34744,7 +35179,7 @@ var ts; if (this.tokensAreOnSameLine === undefined) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(this.currentTokenSpan.pos).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(this.nextTokenSpan.pos).line; - this.tokensAreOnSameLine = (startLine == endLine); + this.tokensAreOnSameLine = (startLine === endLine); } return this.tokensAreOnSameLine; }; @@ -34763,7 +35198,7 @@ var ts; FormattingContext.prototype.NodeIsOnOneLine = function (node) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile)).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; - return startLine == endLine; + return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { var openBrace = ts.findChildOfKind(node, 14 /* OpenBraceToken */, this.sourceFile); @@ -34923,7 +35358,7 @@ var ts; this.customContextChecks = funcs; } RuleOperationContext.prototype.IsAny = function () { - return this == RuleOperationContext.Any; + return this === RuleOperationContext.Any; }; RuleOperationContext.prototype.InContext = function (context) { if (this.IsAny()) { @@ -35029,7 +35464,7 @@ var ts; this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([96 /* TryKeyword */, 81 /* FinallyKeyword */]), 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116 /* GetKeyword */, 121 /* SetKeyword */]), 65 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116 /* GetKeyword */, 122 /* SetKeyword */]), 65 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); @@ -35037,9 +35472,9 @@ var ts; // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(114 /* ConstructorKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Use of module as a function call. e.g.: import m2 = module("m2"); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([117 /* ModuleKeyword */, 119 /* RequireKeyword */]), 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([118 /* ModuleKeyword */, 120 /* RequireKeyword */]), 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69 /* ClassKeyword */, 115 /* DeclareKeyword */, 77 /* EnumKeyword */, 78 /* ExportKeyword */, 79 /* ExtendsKeyword */, 116 /* GetKeyword */, 102 /* ImplementsKeyword */, 85 /* ImportKeyword */, 103 /* InterfaceKeyword */, 117 /* ModuleKeyword */, 118 /* NamespaceKeyword */, 106 /* PrivateKeyword */, 108 /* PublicKeyword */, 121 /* SetKeyword */, 109 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69 /* ClassKeyword */, 115 /* DeclareKeyword */, 77 /* EnumKeyword */, 78 /* ExportKeyword */, 79 /* ExtendsKeyword */, 116 /* GetKeyword */, 102 /* ImplementsKeyword */, 85 /* ImportKeyword */, 103 /* InterfaceKeyword */, 118 /* ModuleKeyword */, 119 /* NamespaceKeyword */, 106 /* PrivateKeyword */, 108 /* PublicKeyword */, 122 /* SetKeyword */, 109 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([79 /* ExtendsKeyword */, 102 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(8 /* StringLiteral */, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); @@ -35059,7 +35494,7 @@ var ts; // decorators this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 78 /* ExportKeyword */, 73 /* DefaultKeyword */, 69 /* ClassKeyword */, 109 /* StaticKeyword */, 108 /* PublicKeyword */, 106 /* PrivateKeyword */, 107 /* ProtectedKeyword */, 116 /* GetKeyword */, 121 /* SetKeyword */, 18 /* OpenBracketToken */, 35 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 78 /* ExportKeyword */, 73 /* DefaultKeyword */, 69 /* ClassKeyword */, 109 /* StaticKeyword */, 108 /* PublicKeyword */, 106 /* PrivateKeyword */, 107 /* ProtectedKeyword */, 116 /* GetKeyword */, 122 /* SetKeyword */, 18 /* OpenBracketToken */, 35 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(83 /* FunctionKeyword */, 35 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(35 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 16 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(110 /* YieldKeyword */, 35 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); @@ -35155,9 +35590,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_29 in o) { - if (o[name_29] === rule) { - return name_29; + for (var name_26 in o) { + if (o[name_26] === rule) { + return name_26; } } throw new Error("Unknown rule"); @@ -35166,36 +35601,37 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 187 /* ForStatement */; + return context.contextNode.kind === 189 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 170 /* BinaryExpression */: - case 171 /* ConditionalExpression */: + case 172 /* BinaryExpression */: + case 173 /* ConditionalExpression */: + case 143 /* TypePredicate */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 153 /* BindingElement */: + case 155 /* BindingElement */: // equals in type X = ... - case 204 /* TypeAliasDeclaration */: + case 206 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 199 /* VariableDeclaration */: + case 201 /* VariableDeclaration */: // equal in p = 0; - case 130 /* Parameter */: - case 227 /* EnumMember */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 131 /* Parameter */: + case 229 /* EnumMember */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return context.currentTokenSpan.kind === 53 /* EqualsToken */ || context.nextTokenSpan.kind === 53 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 188 /* ForInStatement */: + case 190 /* ForInStatement */: return context.currentTokenSpan.kind === 86 /* InKeyword */ || context.nextTokenSpan.kind === 86 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 189 /* ForOfStatement */: - return context.currentTokenSpan.kind === 126 /* OfKeyword */ || context.nextTokenSpan.kind === 126 /* OfKeyword */; + case 191 /* ForOfStatement */: + return context.currentTokenSpan.kind === 127 /* OfKeyword */ || context.nextTokenSpan.kind === 127 /* OfKeyword */; } return false; }; @@ -35203,7 +35639,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 171 /* ConditionalExpression */; + return context.contextNode.kind === 173 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -35247,92 +35683,92 @@ var ts; return true; } switch (node.kind) { - case 180 /* Block */: - case 208 /* CaseBlock */: - case 155 /* ObjectLiteralExpression */: - case 207 /* ModuleBlock */: + case 182 /* Block */: + case 210 /* CaseBlock */: + case 157 /* ObjectLiteralExpression */: + case 209 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: //case SyntaxKind.MemberFunctionDeclaration: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: ///case SyntaxKind.MethodSignature: - case 139 /* CallSignature */: - case 163 /* FunctionExpression */: - case 136 /* Constructor */: - case 164 /* ArrowFunction */: + case 140 /* CallSignature */: + case 165 /* FunctionExpression */: + case 137 /* Constructor */: + case 166 /* ArrowFunction */: //case SyntaxKind.ConstructorDeclaration: //case SyntaxKind.SimpleArrowFunctionExpression: //case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 201 /* FunctionDeclaration */ || context.contextNode.kind === 163 /* FunctionExpression */; + return context.contextNode.kind === 203 /* FunctionDeclaration */ || context.contextNode.kind === 165 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 146 /* TypeLiteral */: - case 206 /* ModuleDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 148 /* TypeLiteral */: + case 208 /* ModuleDeclaration */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 202 /* ClassDeclaration */: - case 206 /* ModuleDeclaration */: - case 205 /* EnumDeclaration */: - case 180 /* Block */: - case 224 /* CatchClause */: - case 207 /* ModuleBlock */: - case 194 /* SwitchStatement */: + case 204 /* ClassDeclaration */: + case 208 /* ModuleDeclaration */: + case 207 /* EnumDeclaration */: + case 182 /* Block */: + case 226 /* CatchClause */: + case 209 /* ModuleBlock */: + case 196 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 184 /* IfStatement */: - case 194 /* SwitchStatement */: - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 186 /* WhileStatement */: - case 197 /* TryStatement */: - case 185 /* DoStatement */: - case 193 /* WithStatement */: + case 186 /* IfStatement */: + case 196 /* SwitchStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 188 /* WhileStatement */: + case 199 /* TryStatement */: + case 187 /* DoStatement */: + case 195 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 224 /* CatchClause */: + case 226 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 155 /* ObjectLiteralExpression */; + return context.contextNode.kind === 157 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 158 /* CallExpression */; + return context.contextNode.kind === 160 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 159 /* NewExpression */; + return context.contextNode.kind === 161 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -35356,38 +35792,38 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 131 /* Decorator */; + return node.kind === 132 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 200 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 202 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { - return context.formattingRequestKind != 2 /* FormatOnEnter */; + return context.formattingRequestKind !== 2 /* FormatOnEnter */; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 206 /* ModuleDeclaration */; + return context.contextNode.kind === 208 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 146 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 148 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameter = function (token, parent) { if (token.kind !== 24 /* LessThanToken */ && token.kind !== 25 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 142 /* TypeReference */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 144 /* TypeReference */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: return true; default: return false; @@ -35398,10 +35834,10 @@ var ts; Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 99 /* VoidKeyword */ && context.currentTokenParent.kind === 167 /* VoidExpression */; + return context.currentTokenSpan.kind === 99 /* VoidKeyword */ && context.currentTokenParent.kind === 169 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 173 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 175 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; })(); @@ -35425,7 +35861,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 126 /* LastToken */ + 1; + this.mapRowLength = 127 /* LastToken */ + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); //new Array(this.mapRowLength * this.mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(this.map.length); //new Array(this.map.length); @@ -35445,13 +35881,13 @@ var ts; }; RulesMap.prototype.FillRule = function (rule, rulesBucketConstructionStateList) { var _this = this; - var specificRule = rule.Descriptor.LeftTokenRange != formatting.Shared.TokenRange.Any && - rule.Descriptor.RightTokenRange != formatting.Shared.TokenRange.Any; + var specificRule = rule.Descriptor.LeftTokenRange !== formatting.Shared.TokenRange.Any && + rule.Descriptor.RightTokenRange !== formatting.Shared.TokenRange.Any; rule.Descriptor.LeftTokenRange.GetTokens().forEach(function (left) { rule.Descriptor.RightTokenRange.GetTokens().forEach(function (right) { var rulesBucketIndex = _this.GetRuleBucketIndex(left, right); var rulesBucket = _this.map[rulesBucketIndex]; - if (rulesBucket == undefined) { + if (rulesBucket === undefined) { rulesBucket = _this.map[rulesBucketIndex] = new RulesBucket(); } rulesBucket.AddRule(rule, specificRule, rulesBucketConstructionStateList, rulesBucketIndex); @@ -35518,7 +35954,7 @@ var ts; RulesBucketConstructionState.prototype.IncreaseInsertionIndex = function (maskPosition) { var value = (this.rulesInsertionIndexBitmap >> maskPosition) & Mask; value++; - ts.Debug.assert((value & Mask) == value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules."); + ts.Debug.assert((value & Mask) === value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules."); var temp = this.rulesInsertionIndexBitmap & ~(Mask << maskPosition); temp |= value << maskPosition; this.rulesInsertionIndexBitmap = temp; @@ -35535,7 +35971,7 @@ var ts; }; RulesBucket.prototype.AddRule = function (rule, specificTokens, constructionState, rulesBucketIndex) { var position; - if (rule.Operation.Action == 1 /* Ignore */) { + if (rule.Operation.Action === 1 /* Ignore */) { position = specificTokens ? RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny; @@ -35610,7 +36046,7 @@ var ts; return [this.token]; }; TokenSingleValueAccess.prototype.Contains = function (tokenValue) { - return tokenValue == this.token; + return tokenValue === this.token; }; return TokenSingleValueAccess; })(); @@ -35620,7 +36056,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 126 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 127 /* LastToken */; token++) { result.push(token); } return result; @@ -35662,9 +36098,9 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(66 /* FirstKeyword */, 126 /* LastKeyword */); + TokenRange.Keywords = TokenRange.FromRange(66 /* FirstKeyword */, 127 /* LastKeyword */); TokenRange.BinaryOperators = TokenRange.FromRange(24 /* FirstBinaryOperator */, 64 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([86 /* InKeyword */, 87 /* InstanceOfKeyword */, 126 /* OfKeyword */]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([86 /* InKeyword */, 87 /* InstanceOfKeyword */, 127 /* OfKeyword */, 117 /* IsKeyword */]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([38 /* PlusPlusToken */, 39 /* MinusMinusToken */, 47 /* TildeToken */, 46 /* ExclamationToken */]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7 /* NumericLiteral */, 65 /* Identifier */, 16 /* OpenParenToken */, 18 /* OpenBracketToken */, 14 /* OpenBraceToken */, 93 /* ThisKeyword */, 88 /* NewKeyword */]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 16 /* OpenParenToken */, 93 /* ThisKeyword */, 88 /* NewKeyword */]); @@ -35672,7 +36108,7 @@ var ts; TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 16 /* OpenParenToken */, 93 /* ThisKeyword */, 88 /* NewKeyword */]); TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 88 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([65 /* Identifier */, 120 /* NumberKeyword */, 122 /* StringKeyword */, 113 /* BooleanKeyword */, 123 /* SymbolKeyword */, 99 /* VoidKeyword */, 112 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([65 /* Identifier */, 121 /* NumberKeyword */, 123 /* StringKeyword */, 113 /* BooleanKeyword */, 124 /* SymbolKeyword */, 99 /* VoidKeyword */, 112 /* AnyKeyword */]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -35711,6 +36147,7 @@ var ts; return this.rulesMap; }; RulesProvider.prototype.ensureUpToDate = function (options) { + // TODO: Should this be '==='? if (this.options == null || !ts.compareDataObjects(this.options, options)) { var activeRules = this.createActiveRules(options); var rulesMap = formatting.RulesMap.create(activeRules); @@ -35875,17 +36312,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 180 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 228 /* SourceFile */: - case 180 /* Block */: - case 207 /* ModuleBlock */: + return body && body.kind === 182 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 230 /* SourceFile */: + case 182 /* Block */: + case 209 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 224 /* CatchClause */: + case 226 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -36058,9 +36495,9 @@ var ts; // - source file // - switch\default clauses if (isSomeBlock(parent.kind) || - parent.kind === 228 /* SourceFile */ || - parent.kind === 221 /* CaseClause */ || - parent.kind === 222 /* DefaultClause */) { + parent.kind === 230 /* SourceFile */ || + parent.kind === 223 /* CaseClause */ || + parent.kind === 224 /* DefaultClause */) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -36096,19 +36533,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 202 /* ClassDeclaration */: return 69 /* ClassKeyword */; - case 203 /* InterfaceDeclaration */: return 103 /* InterfaceKeyword */; - case 201 /* FunctionDeclaration */: return 83 /* FunctionKeyword */; - case 205 /* EnumDeclaration */: return 205 /* EnumDeclaration */; - case 137 /* GetAccessor */: return 116 /* GetKeyword */; - case 138 /* SetAccessor */: return 121 /* SetKeyword */; - case 135 /* MethodDeclaration */: + case 204 /* ClassDeclaration */: return 69 /* ClassKeyword */; + case 205 /* InterfaceDeclaration */: return 103 /* InterfaceKeyword */; + case 203 /* FunctionDeclaration */: return 83 /* FunctionKeyword */; + case 207 /* EnumDeclaration */: return 207 /* EnumDeclaration */; + case 138 /* GetAccessor */: return 116 /* GetKeyword */; + case 139 /* SetAccessor */: return 122 /* SetKeyword */; + case 136 /* MethodDeclaration */: if (node.asteriskToken) { return 35 /* AsteriskToken */; } // fall-through - case 133 /* PropertyDeclaration */: - case 130 /* Parameter */: + case 134 /* PropertyDeclaration */: + case 131 /* Parameter */: return node.name.kind; } } @@ -36241,7 +36678,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 131 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 132 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -36564,20 +37001,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 180 /* Block */: - case 207 /* ModuleBlock */: + case 182 /* Block */: + case 209 /* ModuleBlock */: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 136 /* Constructor */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 164 /* ArrowFunction */: + case 137 /* Constructor */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 166 /* ArrowFunction */: if (node.typeParameters === list) { return 24 /* LessThanToken */; } @@ -36585,8 +37022,8 @@ var ts; return 16 /* OpenParenToken */; } break; - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: if (node.typeArguments === list) { return 24 /* LessThanToken */; } @@ -36594,7 +37031,7 @@ var ts; return 16 /* OpenParenToken */; } break; - case 142 /* TypeReference */: + case 144 /* TypeReference */: if (node.typeArguments === list) { return 24 /* LessThanToken */; } @@ -36693,7 +37130,7 @@ var ts; return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 23 /* CommaToken */ && precedingToken.parent.kind !== 170 /* BinaryExpression */) { + if (precedingToken.kind === 23 /* CommaToken */ && precedingToken.parent.kind !== 172 /* BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { @@ -36804,7 +37241,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 228 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 230 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -36837,7 +37274,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 184 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 186 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 76 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -36849,23 +37286,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 142 /* TypeReference */: + case 144 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 155 /* ObjectLiteralExpression */: + case 157 /* ObjectLiteralExpression */: return node.parent.properties; - case 154 /* ArrayLiteralExpression */: + case 156 /* ArrayLiteralExpression */: return node.parent.elements; - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: { + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -36876,8 +37313,8 @@ var ts; } break; } - case 159 /* NewExpression */: - case 158 /* CallExpression */: { + case 161 /* NewExpression */: + case 160 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -36956,28 +37393,28 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 154 /* ArrayLiteralExpression */: - case 180 /* Block */: - case 207 /* ModuleBlock */: - case 155 /* ObjectLiteralExpression */: - case 146 /* TypeLiteral */: - case 148 /* TupleType */: - case 208 /* CaseBlock */: - case 222 /* DefaultClause */: - case 221 /* CaseClause */: - case 162 /* ParenthesizedExpression */: - case 158 /* CallExpression */: - case 159 /* NewExpression */: - case 181 /* VariableStatement */: - case 199 /* VariableDeclaration */: - case 215 /* ExportAssignment */: - case 192 /* ReturnStatement */: - case 171 /* ConditionalExpression */: - case 152 /* ArrayBindingPattern */: - case 151 /* ObjectBindingPattern */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 156 /* ArrayLiteralExpression */: + case 182 /* Block */: + case 209 /* ModuleBlock */: + case 157 /* ObjectLiteralExpression */: + case 148 /* TypeLiteral */: + case 150 /* TupleType */: + case 210 /* CaseBlock */: + case 224 /* DefaultClause */: + case 223 /* CaseClause */: + case 164 /* ParenthesizedExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: + case 183 /* VariableStatement */: + case 201 /* VariableDeclaration */: + case 217 /* ExportAssignment */: + case 194 /* ReturnStatement */: + case 173 /* ConditionalExpression */: + case 154 /* ArrayBindingPattern */: + case 153 /* ObjectBindingPattern */: return true; } return false; @@ -36987,22 +37424,22 @@ var ts; return true; } switch (parent) { - case 185 /* DoStatement */: - case 186 /* WhileStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 187 /* ForStatement */: - case 184 /* IfStatement */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 139 /* CallSignature */: - case 164 /* ArrowFunction */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - return child !== 180 /* Block */; + case 187 /* DoStatement */: + case 188 /* WhileStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 189 /* ForStatement */: + case 186 /* IfStatement */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 140 /* CallSignature */: + case 166 /* ArrowFunction */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + return child !== 182 /* Block */; default: return false; } @@ -37015,8 +37452,7 @@ var ts; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; /// /// @@ -37085,7 +37521,7 @@ var ts; return this.getEnd() - this.getStart(sourceFile); }; NodeObject.prototype.getFullWidth = function () { - return this.end - this.getFullStart(); + return this.end - this.pos; }; NodeObject.prototype.getLeadingTriviaWidth = function (sourceFile) { return this.getStart(sourceFile) - this.pos; @@ -37107,7 +37543,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(251 /* SyntaxList */, nodes.pos, nodes.end, 1024 /* Synthetic */, this); + var list = createNode(253 /* SyntaxList */, nodes.pos, nodes.end, 1024 /* Synthetic */, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -37126,7 +37562,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 127 /* FirstNode */) { + if (this.kind >= 128 /* FirstNode */) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -37171,7 +37607,7 @@ var ts; var children = this.getChildren(); for (var _i = 0; _i < children.length; _i++) { var child = children[_i]; - if (child.kind < 127 /* FirstNode */) { + if (child.kind < 128 /* FirstNode */) { return child; } return child.getFirstToken(sourceFile); @@ -37181,7 +37617,7 @@ var ts; var children = this.getChildren(sourceFile); for (var i = children.length - 1; i >= 0; i--) { var child = children[i]; - if (child.kind < 127 /* FirstNode */) { + if (child.kind < 128 /* FirstNode */) { return child; } return child.getLastToken(sourceFile); @@ -37234,7 +37670,7 @@ var ts; if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); // If it is parameter - try and get the jsDoc comment with @param tag from function declaration's jsDoc comments - if (canUseParsedParamTagComments && declaration.kind === 130 /* Parameter */) { + if (canUseParsedParamTagComments && declaration.kind === 131 /* Parameter */) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -37243,15 +37679,15 @@ var ts; }); } // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === 206 /* ModuleDeclaration */ && declaration.body.kind === 206 /* ModuleDeclaration */) { + if (declaration.kind === 208 /* ModuleDeclaration */ && declaration.body.kind === 208 /* ModuleDeclaration */) { return; } // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === 206 /* ModuleDeclaration */ && declaration.parent.kind === 206 /* ModuleDeclaration */) { + while (declaration.kind === 208 /* ModuleDeclaration */ && declaration.parent.kind === 208 /* ModuleDeclaration */) { declaration = declaration.parent; } // Get the cleaned js doc comment text from the declaration - ts.forEach(getJsDocCommentTextRange(declaration.kind === 199 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 201 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { jsDocCommentParts.push.apply(jsDocCommentParts, cleanedJsDocComment); @@ -37590,9 +38026,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 128 /* ComputedPropertyName */) { + if (declaration.name.kind === 129 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 156 /* PropertyAccessExpression */) { + if (expr.kind === 158 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -37612,9 +38048,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -37634,60 +38070,60 @@ var ts; ts.forEachChild(node, visit); } break; - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 205 /* EnumDeclaration */: - case 206 /* ModuleDeclaration */: - case 209 /* ImportEqualsDeclaration */: - case 218 /* ExportSpecifier */: - case 214 /* ImportSpecifier */: - case 209 /* ImportEqualsDeclaration */: - case 211 /* ImportClause */: - case 212 /* NamespaceImport */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 146 /* TypeLiteral */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 207 /* EnumDeclaration */: + case 208 /* ModuleDeclaration */: + case 211 /* ImportEqualsDeclaration */: + case 220 /* ExportSpecifier */: + case 216 /* ImportSpecifier */: + case 211 /* ImportEqualsDeclaration */: + case 213 /* ImportClause */: + case 214 /* NamespaceImport */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 148 /* TypeLiteral */: addDeclaration(node); // fall through - case 136 /* Constructor */: - case 181 /* VariableStatement */: - case 200 /* VariableDeclarationList */: - case 151 /* ObjectBindingPattern */: - case 152 /* ArrayBindingPattern */: - case 207 /* ModuleBlock */: + case 137 /* Constructor */: + case 183 /* VariableStatement */: + case 202 /* VariableDeclarationList */: + case 153 /* ObjectBindingPattern */: + case 154 /* ArrayBindingPattern */: + case 209 /* ModuleBlock */: ts.forEachChild(node, visit); break; - case 180 /* Block */: + case 182 /* Block */: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 130 /* Parameter */: + case 131 /* Parameter */: // Only consider properties defined as constructor parameters if (!(node.flags & 112 /* AccessibilityModifier */)) { break; } // fall through - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 227 /* EnumMember */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 229 /* EnumMember */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: addDeclaration(node); break; - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -37699,7 +38135,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 212 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 214 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -37900,16 +38336,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 163 /* FunctionExpression */) { + if (declaration.kind === 165 /* FunctionExpression */) { return true; } - if (declaration.kind !== 199 /* VariableDeclaration */ && declaration.kind !== 201 /* FunctionDeclaration */) { + if (declaration.kind !== 201 /* VariableDeclaration */ && declaration.kind !== 203 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { + for (var parent_9 = declaration.parent; !ts.isFunctionBlock(parent_9); parent_9 = parent_9.parent) { // Reached source file or module block - if (parent_8.kind === 228 /* SourceFile */ || parent_8.kind === 207 /* ModuleBlock */) { + if (parent_9.kind === 230 /* SourceFile */ || parent_9.kind === 209 /* ModuleBlock */) { return false; } } @@ -37953,9 +38389,8 @@ var ts; var HostCache = (function () { function HostCache(host, getCanonicalFileName) { this.host = host; - this.getCanonicalFileName = getCanonicalFileName; // script id => script index - this.fileNameToEntry = {}; + this.fileNameToEntry = ts.createFileMap(getCanonicalFileName); // Initialize the list with the root file names var rootFileNames = host.getScriptFileNames(); for (var _i = 0; _i < rootFileNames.length; _i++) { @@ -37968,9 +38403,6 @@ var ts; HostCache.prototype.compilationSettings = function () { return this._compilationSettings; }; - HostCache.prototype.normalizeFileName = function (fileName) { - return this.getCanonicalFileName(ts.normalizeSlashes(fileName)); - }; HostCache.prototype.createEntry = function (fileName) { var entry; var scriptSnapshot = this.host.getScriptSnapshot(fileName); @@ -37981,13 +38413,14 @@ var ts; scriptSnapshot: scriptSnapshot }; } - return this.fileNameToEntry[this.normalizeFileName(fileName)] = entry; + this.fileNameToEntry.set(fileName, entry); + return entry; }; HostCache.prototype.getEntry = function (fileName) { - return ts.lookUp(this.fileNameToEntry, this.normalizeFileName(fileName)); + return this.fileNameToEntry.get(fileName); }; HostCache.prototype.contains = function (fileName) { - return ts.hasProperty(this.fileNameToEntry, this.normalizeFileName(fileName)); + return this.fileNameToEntry.contains(fileName); }; HostCache.prototype.getOrCreateEntry = function (fileName) { if (this.contains(fileName)) { @@ -37996,12 +38429,10 @@ var ts; return this.createEntry(fileName); }; HostCache.prototype.getRootFileNames = function () { - var _this = this; var fileNames = []; - ts.forEachKey(this.fileNameToEntry, function (key) { - var entry = _this.getEntry(key); - if (entry) { - fileNames.push(entry.hostFileName); + this.fileNameToEntry.forEachValue(function (value) { + if (value) { + fileNames.push(value.hostFileName); } }); return fileNames; @@ -38061,7 +38492,7 @@ var ts; * - noLib = true * - noResolve = true */ - function transpile(input, compilerOptions, fileName, diagnostics) { + function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { var options = compilerOptions ? ts.clone(compilerOptions) : getDefaultCompilerOptions(); options.isolatedModules = true; // Filename can be non-ts file. @@ -38075,9 +38506,8 @@ var ts; // Parse var inputFileName = fileName || "module.ts"; var sourceFile = ts.createSourceFile(inputFileName, input, options.target); - // Store syntactic diagnostics - if (diagnostics && sourceFile.parseDiagnostics) { - diagnostics.push.apply(diagnostics, sourceFile.parseDiagnostics); + if (moduleName) { + sourceFile.moduleName = moduleName; } var newLine = ts.getNewLineCharacter(options); // Output @@ -38096,9 +38526,8 @@ var ts; getNewLine: function () { return newLine; } }; var program = ts.createProgram([inputFileName], options, compilerHost); - if (diagnostics) { - diagnostics.push.apply(diagnostics, program.getCompilerOptionsDiagnostics()); - } + ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile)); + ts.addRange(diagnostics, program.getOptionsDiagnostics()); // Emit program.emit(); ts.Debug.assert(outputText !== undefined, "Output generation failed"); @@ -38158,10 +38587,16 @@ var ts; return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, true); } ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; - function createDocumentRegistry() { + function createGetCanonicalFileName(useCaseSensitivefileNames) { + return useCaseSensitivefileNames + ? (function (fileName) { return fileName; }) + : (function (fileName) { return fileName.toLowerCase(); }); + } + function createDocumentRegistry(useCaseSensitiveFileNames) { // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have // for those settings. var buckets = {}; + var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); function getKeyFromCompilationSettings(settings) { return "_" + settings.target; // + "|" + settings.propagateEnumConstantoString() } @@ -38169,7 +38604,7 @@ var ts; var key = getKeyFromCompilationSettings(settings); var bucket = ts.lookUp(buckets, key); if (!bucket && createIfMissing) { - buckets[key] = bucket = {}; + buckets[key] = bucket = ts.createFileMap(getCanonicalFileName); } return bucket; } @@ -38178,7 +38613,7 @@ var ts; var entries = ts.lookUp(buckets, name); var sourceFiles = []; for (var i in entries) { - var entry = entries[i]; + var entry = entries.get(i); sourceFiles.push({ name: i, refCount: entry.languageServiceRefCount, @@ -38201,16 +38636,17 @@ var ts; } function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { var bucket = getBucketForCompilationSettings(compilationSettings, true); - var entry = ts.lookUp(bucket, fileName); + var entry = bucket.get(fileName); if (!entry) { ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); // Have never seen this file with these settings. Create a new source file for it. var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, false); - bucket[fileName] = entry = { + entry = { sourceFile: sourceFile, languageServiceRefCount: 0, owners: [] }; + bucket.set(fileName, entry); } else { // We have an entry for this file. However, it may be for a different version of @@ -38233,11 +38669,11 @@ var ts; function releaseDocument(fileName, compilationSettings) { var bucket = getBucketForCompilationSettings(compilationSettings, false); ts.Debug.assert(bucket !== undefined); - var entry = ts.lookUp(bucket, fileName); + var entry = bucket.get(fileName); entry.languageServiceRefCount--; ts.Debug.assert(entry.languageServiceRefCount >= 0); if (entry.languageServiceRefCount === 0) { - delete bucket[fileName]; + bucket.remove(fileName); } } return { @@ -38300,7 +38736,7 @@ var ts; else { if (token === 65 /* Identifier */) { token = scanner.scan(); - if (token === 125 /* FromKeyword */) { + if (token === 126 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import d from "mod"; @@ -38310,7 +38746,7 @@ var ts; } else if (token === 53 /* EqualsToken */) { token = scanner.scan(); - if (token === 119 /* RequireKeyword */) { + if (token === 120 /* RequireKeyword */) { token = scanner.scan(); if (token === 16 /* OpenParenToken */) { token = scanner.scan(); @@ -38339,7 +38775,7 @@ var ts; } if (token === 15 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 125 /* FromKeyword */) { + if (token === 126 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import {a as A} from "mod"; @@ -38355,7 +38791,7 @@ var ts; token = scanner.scan(); if (token === 65 /* Identifier */) { token = scanner.scan(); - if (token === 125 /* FromKeyword */) { + if (token === 126 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import * as NS from "mod" @@ -38378,7 +38814,7 @@ var ts; } if (token === 15 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 125 /* FromKeyword */) { + if (token === 126 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // export {a as A} from "mod"; @@ -38390,7 +38826,7 @@ var ts; } else if (token === 35 /* AsteriskToken */) { token = scanner.scan(); - if (token === 125 /* FromKeyword */) { + if (token === 126 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // export * from "mod" @@ -38413,7 +38849,7 @@ var ts; /// Helpers function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 195 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 197 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -38422,12 +38858,12 @@ var ts; } function isJumpStatementTarget(node) { return node.kind === 65 /* Identifier */ && - (node.parent.kind === 191 /* BreakStatement */ || node.parent.kind === 190 /* ContinueStatement */) && + (node.parent.kind === 193 /* BreakStatement */ || node.parent.kind === 192 /* ContinueStatement */) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { return node.kind === 65 /* Identifier */ && - node.parent.kind === 195 /* LabeledStatement */ && + node.parent.kind === 197 /* LabeledStatement */ && node.parent.label === node; } /** @@ -38435,7 +38871,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 195 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 197 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -38446,25 +38882,25 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 127 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 128 /* QualifiedName */ && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 156 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 158 /* PropertyAccessExpression */ && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 158 /* CallExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 160 /* CallExpression */ && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 159 /* NewExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 161 /* NewExpression */ && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 206 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 208 /* ModuleDeclaration */ && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { return node.kind === 65 /* Identifier */ && @@ -38473,22 +38909,22 @@ var ts; /** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */ function isNameOfPropertyAssignment(node) { return (node.kind === 65 /* Identifier */ || node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) && - (node.parent.kind === 225 /* PropertyAssignment */ || node.parent.kind === 226 /* ShorthandPropertyAssignment */) && node.parent.name === node; + (node.parent.kind === 227 /* PropertyAssignment */ || node.parent.kind === 228 /* ShorthandPropertyAssignment */) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) { switch (node.parent.kind) { - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 225 /* PropertyAssignment */: - case 227 /* EnumMember */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 206 /* ModuleDeclaration */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 227 /* PropertyAssignment */: + case 229 /* EnumMember */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 208 /* ModuleDeclaration */: return node.parent.name === node; - case 157 /* ElementAccessExpression */: + case 159 /* ElementAccessExpression */: return node.parent.argumentExpression === node; } } @@ -38547,7 +38983,7 @@ var ts; })(BreakContinueSearchType || (BreakContinueSearchType = {})); // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 66 /* FirstKeyword */; i <= 126 /* LastKeyword */; i++) { + for (var i = 66 /* FirstKeyword */; i <= 127 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -38562,17 +38998,17 @@ var ts; return undefined; } switch (node.kind) { - case 228 /* SourceFile */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 202 /* ClassDeclaration */: - case 203 /* InterfaceDeclaration */: - case 205 /* EnumDeclaration */: - case 206 /* ModuleDeclaration */: + case 230 /* SourceFile */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 204 /* ClassDeclaration */: + case 205 /* InterfaceDeclaration */: + case 207 /* EnumDeclaration */: + case 208 /* ModuleDeclaration */: return node; } } @@ -38580,38 +39016,38 @@ var ts; ts.getContainerNode = getContainerNode; /* @internal */ function getNodeKind(node) { switch (node.kind) { - case 206 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 202 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 203 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 204 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 205 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 199 /* VariableDeclaration */: + case 208 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 204 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 205 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 206 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 207 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 201 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 201 /* FunctionDeclaration */: return ScriptElementKind.functionElement; - case 137 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 138 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 203 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 138 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 139 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: return ScriptElementKind.memberFunctionElement; - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return ScriptElementKind.memberVariableElement; - case 141 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 140 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 139 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 136 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 129 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 227 /* EnumMember */: return ScriptElementKind.variableElement; - case 130 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 209 /* ImportEqualsDeclaration */: - case 214 /* ImportSpecifier */: - case 211 /* ImportClause */: - case 218 /* ExportSpecifier */: - case 212 /* NamespaceImport */: + case 142 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 141 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 140 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 137 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 130 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 229 /* EnumMember */: return ScriptElementKind.variableElement; + case 131 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 211 /* ImportEqualsDeclaration */: + case 216 /* ImportSpecifier */: + case 213 /* ImportClause */: + case 220 /* ExportSpecifier */: + case 214 /* NamespaceImport */: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -38634,9 +39070,7 @@ var ts; host.log(message); } } - function getCanonicalFileName(fileName) { - return useCaseSensitivefileNames ? fileName : fileName.toLowerCase(); - } + var getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames); function getValidSourceFile(fileName) { fileName = ts.normalizeSlashes(fileName); var sourceFile = program.getSourceFile(getCanonicalFileName(fileName)); @@ -38827,44 +39261,44 @@ var ts; return false; } switch (node.kind) { - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 223 /* HeritageClause */: + case 225 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 102 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 204 /* TypeAliasDeclaration */: + case 206 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 163 /* FunctionExpression */: - case 201 /* FunctionDeclaration */: - case 164 /* ArrowFunction */: - case 201 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 165 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: + case 166 /* ArrowFunction */: + case 203 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -38872,20 +39306,20 @@ var ts; return true; } break; - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 199 /* VariableDeclaration */: + case 201 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -38893,7 +39327,7 @@ var ts; return true; } break; - case 130 /* Parameter */: + case 131 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -38909,17 +39343,17 @@ var ts; return true; } break; - case 133 /* PropertyDeclaration */: + case 134 /* PropertyDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 161 /* TypeAssertionExpression */: + case 163 /* TypeAssertionExpression */: var typeAssertionExpression = node; diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return true; - case 131 /* Decorator */: + case 132 /* Decorator */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -38964,7 +39398,7 @@ var ts; } function getCompilerOptionsDiagnostics() { synchronizeHostData(); - return program.getGlobalDiagnostics(); + return program.getOptionsDiagnostics().concat(program.getGlobalDiagnostics()); } /// Completion function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks) { @@ -39053,11 +39487,11 @@ var ts; // visible symbols in the scope, and the node is the current location. var node = currentToken; var isRightOfDot = false; - if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 156 /* PropertyAccessExpression */) { + if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 158 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 127 /* QualifiedName */) { + else if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 128 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -39084,7 +39518,7 @@ var ts; // Right of dot member completion list isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 65 /* Identifier */ || node.kind === 127 /* QualifiedName */ || node.kind === 156 /* PropertyAccessExpression */) { + if (node.kind === 65 /* Identifier */ || node.kind === 128 /* QualifiedName */ || node.kind === 158 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -39142,13 +39576,13 @@ var ts; symbols = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties); } } - else if (ts.getAncestor(contextToken, 211 /* ImportClause */)) { + else if (ts.getAncestor(contextToken, 213 /* ImportClause */)) { // cursor is in import clause // try to show exported member for imported module isMemberCompletion = true; isNewIdentifierLocation = true; if (showCompletionsInImportsClause(contextToken)) { - var importDeclaration = ts.getAncestor(contextToken, 210 /* ImportDeclaration */); + var importDeclaration = ts.getAncestor(contextToken, 212 /* ImportDeclaration */); ts.Debug.assert(importDeclaration !== undefined); var exports; if (importDeclaration.moduleSpecifier) { @@ -39227,7 +39661,7 @@ var ts; // import {| // import {a,| if (node.kind === 14 /* OpenBraceToken */ || node.kind === 23 /* CommaToken */) { - return node.parent.kind === 213 /* NamedImports */; + return node.parent.kind === 215 /* NamedImports */; } } return false; @@ -39237,38 +39671,38 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23 /* CommaToken */: - return containingNodeKind === 158 /* CallExpression */ // func( a, | - || containingNodeKind === 136 /* Constructor */ // constructor( a, | public, protected, private keywords are allowed here, so show completion - || containingNodeKind === 159 /* NewExpression */ // new C(a, | - || containingNodeKind === 154 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 170 /* BinaryExpression */ // let x = (a, | - || containingNodeKind === 143 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 160 /* CallExpression */ // func( a, | + || containingNodeKind === 137 /* Constructor */ // constructor( a, | public, protected, private keywords are allowed here, so show completion + || containingNodeKind === 161 /* NewExpression */ // new C(a, | + || containingNodeKind === 156 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 172 /* BinaryExpression */ // let x = (a, | + || containingNodeKind === 145 /* FunctionType */; // var x: (s: string, list| case 16 /* OpenParenToken */: - return containingNodeKind === 158 /* CallExpression */ // func( | - || containingNodeKind === 136 /* Constructor */ // constructor( | - || containingNodeKind === 159 /* NewExpression */ // new C(a| - || containingNodeKind === 162 /* ParenthesizedExpression */ // let x = (a| - || containingNodeKind === 150 /* ParenthesizedType */; // function F(pred: (a| this can become an arrow function, where 'a' is the argument + return containingNodeKind === 160 /* CallExpression */ // func( | + || containingNodeKind === 137 /* Constructor */ // constructor( | + || containingNodeKind === 161 /* NewExpression */ // new C(a| + || containingNodeKind === 164 /* ParenthesizedExpression */ // let x = (a| + || containingNodeKind === 152 /* ParenthesizedType */; // function F(pred: (a| this can become an arrow function, where 'a' is the argument case 18 /* OpenBracketToken */: - return containingNodeKind === 154 /* ArrayLiteralExpression */; // [ | - case 117 /* ModuleKeyword */: // module | - case 118 /* NamespaceKeyword */: + return containingNodeKind === 156 /* ArrayLiteralExpression */; // [ | + case 118 /* ModuleKeyword */: // module | + case 119 /* NamespaceKeyword */: return true; case 20 /* DotToken */: - return containingNodeKind === 206 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 208 /* ModuleDeclaration */; // module A.| case 14 /* OpenBraceToken */: - return containingNodeKind === 202 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 204 /* ClassDeclaration */; // class A{ | case 53 /* EqualsToken */: - return containingNodeKind === 199 /* VariableDeclaration */ // let x = a| - || containingNodeKind === 170 /* BinaryExpression */; // x = a| + return containingNodeKind === 201 /* VariableDeclaration */ // let x = a| + || containingNodeKind === 172 /* BinaryExpression */; // x = a| case 11 /* TemplateHead */: - return containingNodeKind === 172 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 174 /* TemplateExpression */; // `aa ${| case 12 /* TemplateMiddle */: - return containingNodeKind === 178 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 180 /* TemplateSpan */; // `aa ${10} dd ${| case 108 /* PublicKeyword */: case 106 /* PrivateKeyword */: case 107 /* ProtectedKeyword */: - return containingNodeKind === 133 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 134 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -39303,12 +39737,12 @@ var ts; function getContainingObjectLiteralApplicableForCompletion(previousToken) { // The locations in an object literal expression that are applicable for completion are property name definition locations. if (previousToken) { - var parent_9 = previousToken.parent; + var parent_10 = previousToken.parent; switch (previousToken.kind) { case 14 /* OpenBraceToken */: // let x = { | case 23 /* CommaToken */: - if (parent_9 && parent_9.kind === 155 /* ObjectLiteralExpression */) { - return parent_9; + if (parent_10 && parent_10.kind === 157 /* ObjectLiteralExpression */) { + return parent_10; } break; } @@ -39317,16 +39751,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 139 /* CallSignature */: - case 140 /* ConstructSignature */: - case 141 /* IndexSignature */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 140 /* CallSignature */: + case 141 /* ConstructSignature */: + case 142 /* IndexSignature */: return true; } return false; @@ -39336,63 +39770,63 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23 /* CommaToken */: - return containingNodeKind === 199 /* VariableDeclaration */ || - containingNodeKind === 200 /* VariableDeclarationList */ || - containingNodeKind === 181 /* VariableStatement */ || - containingNodeKind === 205 /* EnumDeclaration */ || + return containingNodeKind === 201 /* VariableDeclaration */ || + containingNodeKind === 202 /* VariableDeclarationList */ || + containingNodeKind === 183 /* VariableStatement */ || + containingNodeKind === 207 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 202 /* ClassDeclaration */ || - containingNodeKind === 201 /* FunctionDeclaration */ || - containingNodeKind === 203 /* InterfaceDeclaration */ || - containingNodeKind === 152 /* ArrayBindingPattern */ || - containingNodeKind === 151 /* ObjectBindingPattern */; // function func({ x, y| + containingNodeKind === 204 /* ClassDeclaration */ || + containingNodeKind === 203 /* FunctionDeclaration */ || + containingNodeKind === 205 /* InterfaceDeclaration */ || + containingNodeKind === 154 /* ArrayBindingPattern */ || + containingNodeKind === 153 /* ObjectBindingPattern */; // function func({ x, y| case 20 /* DotToken */: - return containingNodeKind === 152 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 154 /* ArrayBindingPattern */; // var [.| case 51 /* ColonToken */: - return containingNodeKind === 153 /* BindingElement */; // var {x :html| + return containingNodeKind === 155 /* BindingElement */; // var {x :html| case 18 /* OpenBracketToken */: - return containingNodeKind === 152 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 154 /* ArrayBindingPattern */; // var [x| case 16 /* OpenParenToken */: - return containingNodeKind === 224 /* CatchClause */ || + return containingNodeKind === 226 /* CatchClause */ || isFunction(containingNodeKind); case 14 /* OpenBraceToken */: - return containingNodeKind === 205 /* EnumDeclaration */ || - containingNodeKind === 203 /* InterfaceDeclaration */ || - containingNodeKind === 146 /* TypeLiteral */ || - containingNodeKind === 151 /* ObjectBindingPattern */; // function func({ x| + return containingNodeKind === 207 /* EnumDeclaration */ || + containingNodeKind === 205 /* InterfaceDeclaration */ || + containingNodeKind === 148 /* TypeLiteral */ || + containingNodeKind === 153 /* ObjectBindingPattern */; // function func({ x| case 22 /* SemicolonToken */: - return containingNodeKind === 132 /* PropertySignature */ && + return containingNodeKind === 133 /* PropertySignature */ && previousToken.parent && previousToken.parent.parent && - (previousToken.parent.parent.kind === 203 /* InterfaceDeclaration */ || - previousToken.parent.parent.kind === 146 /* TypeLiteral */); // let x : { a; | + (previousToken.parent.parent.kind === 205 /* InterfaceDeclaration */ || + previousToken.parent.parent.kind === 148 /* TypeLiteral */); // let x : { a; | case 24 /* LessThanToken */: - return containingNodeKind === 202 /* ClassDeclaration */ || - containingNodeKind === 201 /* FunctionDeclaration */ || - containingNodeKind === 203 /* InterfaceDeclaration */ || + return containingNodeKind === 204 /* ClassDeclaration */ || + containingNodeKind === 203 /* FunctionDeclaration */ || + containingNodeKind === 205 /* InterfaceDeclaration */ || isFunction(containingNodeKind); case 109 /* StaticKeyword */: - return containingNodeKind === 133 /* PropertyDeclaration */; + return containingNodeKind === 134 /* PropertyDeclaration */; case 21 /* DotDotDotToken */: - return containingNodeKind === 130 /* Parameter */ || - containingNodeKind === 136 /* Constructor */ || + return containingNodeKind === 131 /* Parameter */ || + containingNodeKind === 137 /* Constructor */ || (previousToken.parent && previousToken.parent.parent && - previousToken.parent.parent.kind === 152 /* ArrayBindingPattern */); // var [...z| + previousToken.parent.parent.kind === 154 /* ArrayBindingPattern */); // var [...z| case 108 /* PublicKeyword */: case 106 /* PrivateKeyword */: case 107 /* ProtectedKeyword */: - return containingNodeKind === 130 /* Parameter */; + return containingNodeKind === 131 /* Parameter */; case 69 /* ClassKeyword */: case 77 /* EnumKeyword */: case 103 /* InterfaceKeyword */: case 83 /* FunctionKeyword */: case 98 /* VarKeyword */: case 116 /* GetKeyword */: - case 121 /* SetKeyword */: + case 122 /* SetKeyword */: case 85 /* ImportKeyword */: case 104 /* LetKeyword */: case 70 /* ConstKeyword */: case 110 /* YieldKeyword */: - case 124 /* TypeKeyword */: + case 125 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. @@ -39424,7 +39858,7 @@ var ts; return exports; } if (importDeclaration.importClause.namedBindings && - importDeclaration.importClause.namedBindings.kind === 213 /* NamedImports */) { + importDeclaration.importClause.namedBindings.kind === 215 /* NamedImports */) { ts.forEach(importDeclaration.importClause.namedBindings.elements, function (el) { var name = el.propertyName || el.name; exisingImports[name.text] = true; @@ -39441,7 +39875,7 @@ var ts; } var existingMemberNames = {}; ts.forEach(existingMembers, function (m) { - if (m.kind !== 225 /* PropertyAssignment */ && m.kind !== 226 /* ShorthandPropertyAssignment */) { + if (m.kind !== 227 /* PropertyAssignment */ && m.kind !== 228 /* ShorthandPropertyAssignment */) { // Ignore omitted expressions for missing members in the object literal return; } @@ -39491,10 +39925,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameTable = getNameTable(sourceFile); - for (var name_30 in nameTable) { - if (!allNames[name_30]) { - allNames[name_30] = name_30; - var displayName = getCompletionEntryDisplayName(name_30, target, true); + for (var name_27 in nameTable) { + if (!allNames[name_27]) { + allNames[name_27] = name_27; + var displayName = getCompletionEntryDisplayName(name_27, target, true); if (displayName) { var entry = { name: displayName, @@ -39693,7 +40127,7 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 156 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 158 /* PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -39702,7 +40136,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression; - if (location.kind === 158 /* CallExpression */ || location.kind === 159 /* NewExpression */) { + if (location.kind === 160 /* CallExpression */ || location.kind === 161 /* NewExpression */) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -39715,7 +40149,7 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 159 /* NewExpression */ || callExpression.expression.kind === 91 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 161 /* NewExpression */ || callExpression.expression.kind === 91 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { // Get the first signature if there @@ -39767,24 +40201,24 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 114 /* ConstructorKeyword */ && location.parent.kind === 136 /* Constructor */)) { + (location.kind === 114 /* ConstructorKeyword */ && location.parent.kind === 137 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 136 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 137 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 136 /* Constructor */) { + if (functionDeclaration.kind === 137 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 139 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 140 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -39807,7 +40241,7 @@ var ts; } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(124 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(125 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); @@ -39827,9 +40261,9 @@ var ts; } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 206 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 208 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 65 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 118 /* NamespaceKeyword */ : 117 /* ModuleKeyword */)); + displayParts.push(ts.keywordPart(isNamespace ? 119 /* NamespaceKeyword */ : 118 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -39850,13 +40284,13 @@ var ts; } else { // Method/function type parameter - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 129 /* TypeParameter */).parent; + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 130 /* TypeParameter */).parent; var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 140 /* ConstructSignature */) { + if (signatureDeclaration.kind === 141 /* ConstructSignature */) { displayParts.push(ts.keywordPart(88 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 139 /* CallSignature */ && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 140 /* CallSignature */ && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); @@ -39865,7 +40299,7 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 227 /* EnumMember */) { + if (declaration.kind === 229 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -39881,13 +40315,13 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 209 /* ImportEqualsDeclaration */) { + if (declaration.kind === 211 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); displayParts.push(ts.operatorPart(53 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(119 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(120 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); @@ -40014,8 +40448,8 @@ var ts; // Try getting just type at this position and show switch (node.kind) { case 65 /* Identifier */: - case 156 /* PropertyAccessExpression */: - case 127 /* QualifiedName */: + case 158 /* PropertyAccessExpression */: + case 128 /* QualifiedName */: case 93 /* ThisKeyword */: case 91 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position @@ -40073,7 +40507,7 @@ var ts; if (isNewExpressionTarget(location) || location.kind === 114 /* ConstructorKeyword */) { if (symbol.flags & 32 /* Class */) { var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 202 /* ClassDeclaration */); + ts.Debug.assert(classDeclaration && classDeclaration.kind === 204 /* ClassDeclaration */); return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); } } @@ -40089,8 +40523,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 136 /* Constructor */) || - (!selectConstructors && (d.kind === 201 /* FunctionDeclaration */ || d.kind === 135 /* MethodDeclaration */ || d.kind === 134 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 137 /* Constructor */) || + (!selectConstructors && (d.kind === 203 /* FunctionDeclaration */ || d.kind === 136 /* MethodDeclaration */ || d.kind === 135 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -40159,7 +40593,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 226 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 228 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -40193,7 +40627,7 @@ var ts; var result = []; ts.forEach(type.types, function (t) { if (t.symbol) { - result.push.apply(result, getDefinitionFromSymbol(t.symbol, node)); + ts.addRange(result, getDefinitionFromSymbol(t.symbol, node)); } }); return result; @@ -40288,74 +40722,74 @@ var ts; switch (node.kind) { case 84 /* IfKeyword */: case 76 /* ElseKeyword */: - if (hasKind(node.parent, 184 /* IfStatement */)) { + if (hasKind(node.parent, 186 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; case 90 /* ReturnKeyword */: - if (hasKind(node.parent, 192 /* ReturnStatement */)) { + if (hasKind(node.parent, 194 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; case 94 /* ThrowKeyword */: - if (hasKind(node.parent, 196 /* ThrowStatement */)) { + if (hasKind(node.parent, 198 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; case 68 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 197 /* TryStatement */)) { + if (hasKind(parent(parent(node)), 199 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 96 /* TryKeyword */: case 81 /* FinallyKeyword */: - if (hasKind(parent(node), 197 /* TryStatement */)) { + if (hasKind(parent(node), 199 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 92 /* SwitchKeyword */: - if (hasKind(node.parent, 194 /* SwitchStatement */)) { + if (hasKind(node.parent, 196 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 67 /* CaseKeyword */: case 73 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 194 /* SwitchStatement */)) { + if (hasKind(parent(parent(parent(node))), 196 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 66 /* BreakKeyword */: case 71 /* ContinueKeyword */: - if (hasKind(node.parent, 191 /* BreakStatement */) || hasKind(node.parent, 190 /* ContinueStatement */)) { + if (hasKind(node.parent, 193 /* BreakStatement */) || hasKind(node.parent, 192 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurences(node.parent); } break; case 82 /* ForKeyword */: - if (hasKind(node.parent, 187 /* ForStatement */) || - hasKind(node.parent, 188 /* ForInStatement */) || - hasKind(node.parent, 189 /* ForOfStatement */)) { + if (hasKind(node.parent, 189 /* ForStatement */) || + hasKind(node.parent, 190 /* ForInStatement */) || + hasKind(node.parent, 191 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 100 /* WhileKeyword */: case 75 /* DoKeyword */: - if (hasKind(node.parent, 186 /* WhileStatement */) || hasKind(node.parent, 185 /* DoStatement */)) { + if (hasKind(node.parent, 188 /* WhileStatement */) || hasKind(node.parent, 187 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 114 /* ConstructorKeyword */: - if (hasKind(node.parent, 136 /* Constructor */)) { + if (hasKind(node.parent, 137 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; case 116 /* GetKeyword */: - case 121 /* SetKeyword */: - if (hasKind(node.parent, 137 /* GetAccessor */) || hasKind(node.parent, 138 /* SetAccessor */)) { + case 122 /* SetKeyword */: + if (hasKind(node.parent, 138 /* GetAccessor */) || hasKind(node.parent, 139 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 181 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 183 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -40371,10 +40805,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 196 /* ThrowStatement */) { + if (node.kind === 198 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 197 /* TryStatement */) { + else if (node.kind === 199 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -40402,19 +40836,19 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_10 = child.parent; - if (ts.isFunctionBlock(parent_10) || parent_10.kind === 228 /* SourceFile */) { - return parent_10; + var parent_11 = child.parent; + if (ts.isFunctionBlock(parent_11) || parent_11.kind === 230 /* SourceFile */) { + return parent_11; } // A throw-statement is only owned by a try-statement if the try-statement has // a catch clause, and if the throw-statement occurs within the try block. - if (parent_10.kind === 197 /* TryStatement */) { - var tryStatement = parent_10; + if (parent_11.kind === 199 /* TryStatement */) { + var tryStatement = parent_11; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_10; + child = parent_11; } return undefined; } @@ -40423,7 +40857,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 191 /* BreakStatement */ || node.kind === 190 /* ContinueStatement */) { + if (node.kind === 193 /* BreakStatement */ || node.kind === 192 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -40437,25 +40871,25 @@ var ts; return actualOwner && actualOwner === owner; } function getBreakOrContinueOwner(statement) { - for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { - switch (node_1.kind) { - case 194 /* SwitchStatement */: - if (statement.kind === 190 /* ContinueStatement */) { + for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { + switch (node_2.kind) { + case 196 /* SwitchStatement */: + if (statement.kind === 192 /* ContinueStatement */) { continue; } // Fall through. - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 186 /* WhileStatement */: - case 185 /* DoStatement */: - if (!statement.label || isLabeledBy(node_1, statement.label.text)) { - return node_1; + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 188 /* WhileStatement */: + case 187 /* DoStatement */: + if (!statement.label || isLabeledBy(node_2, statement.label.text)) { + return node_2; } break; default: // Don't cross function boundaries. - if (ts.isFunctionLike(node_1)) { + if (ts.isFunctionLike(node_2)) { return undefined; } break; @@ -40467,18 +40901,18 @@ var ts; var container = declaration.parent; // Make sure we only highlight the keyword when it makes sense to do so. if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 202 /* ClassDeclaration */ || - (declaration.kind === 130 /* Parameter */ && hasKind(container, 136 /* Constructor */)))) { + if (!(container.kind === 204 /* ClassDeclaration */ || + (declaration.kind === 131 /* Parameter */ && hasKind(container, 137 /* Constructor */)))) { return undefined; } } else if (modifier === 109 /* StaticKeyword */) { - if (container.kind !== 202 /* ClassDeclaration */) { + if (container.kind !== 204 /* ClassDeclaration */) { return undefined; } } else if (modifier === 78 /* ExportKeyword */ || modifier === 115 /* DeclareKeyword */) { - if (!(container.kind === 207 /* ModuleBlock */ || container.kind === 228 /* SourceFile */)) { + if (!(container.kind === 209 /* ModuleBlock */ || container.kind === 230 /* SourceFile */)) { return undefined; } } @@ -40490,20 +40924,20 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 207 /* ModuleBlock */: - case 228 /* SourceFile */: + case 209 /* ModuleBlock */: + case 230 /* SourceFile */: nodes = container.statements; break; - case 136 /* Constructor */: + case 137 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. if (modifierFlag & 112 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 136 /* Constructor */ && member; + return member.kind === 137 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -40551,13 +40985,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 137 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 138 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 138 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 139 /* SetAccessor */); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 116 /* GetKeyword */, 121 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 116 /* GetKeyword */, 122 /* SetKeyword */); }); } } } @@ -40575,7 +41009,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 82 /* ForKeyword */, 100 /* WhileKeyword */, 75 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 185 /* DoStatement */) { + if (loopNode.kind === 187 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 100 /* WhileKeyword */)) { @@ -40596,13 +41030,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 187 /* ForStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: - case 185 /* DoStatement */: - case 186 /* WhileStatement */: + case 189 /* ForStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: + case 187 /* DoStatement */: + case 188 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 194 /* SwitchStatement */: + case 196 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -40656,7 +41090,7 @@ var ts; function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); // If we didn't find a containing function with a block body, bail out. - if (!(func && hasKind(func.body, 180 /* Block */))) { + if (!(func && hasKind(func.body, 182 /* Block */))) { return undefined; } var keywords = []; @@ -40672,7 +41106,7 @@ var ts; function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 184 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 186 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. @@ -40685,7 +41119,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 184 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 186 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -40864,17 +41298,17 @@ var ts; } function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 214 /* ImportSpecifier */ || location.parent.kind === 218 /* ExportSpecifier */) && + (location.parent.kind === 216 /* ImportSpecifier */ || location.parent.kind === 220 /* ExportSpecifier */) && location.parent.propertyName === location; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 214 /* ImportSpecifier */ || declaration.kind === 218 /* ExportSpecifier */; + return declaration.kind === 216 /* ImportSpecifier */ || declaration.kind === 220 /* ExportSpecifier */; }); } function getDeclaredName(symbol, location) { // Special case for function expressions, whose names are solely local to their bodies. - var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 163 /* FunctionExpression */ ? d : undefined; }); + var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 165 /* FunctionExpression */ ? d : undefined; }); // When a name gets interned into a SourceFile's 'identifiers' Map, // its name is escaped and stored in the same way its symbol name/identifier // name should be stored. Function expressions, however, are a special case, @@ -40901,7 +41335,7 @@ var ts; return location.getText(); } // Special case for function expressions, whose names are solely local to their bodies. - var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 163 /* FunctionExpression */ ? d : undefined; }); + var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 165 /* FunctionExpression */ ? d : undefined; }); // When a name gets interned into a SourceFile's 'identifiers' Map, // its name is escaped and stored in the same way its symbol name/identifier // name should be stored. Function expressions, however, are a special case, @@ -40925,7 +41359,7 @@ var ts; if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 202 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 204 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -40951,7 +41385,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 228 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 230 /* SourceFile */ && !ts.isExternalModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -41139,13 +41573,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -41177,27 +41611,27 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 228 /* SourceFile */: + case 230 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. @@ -41206,7 +41640,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 228 /* SourceFile */) { + if (searchSpaceNode.kind === 230 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -41237,27 +41671,27 @@ var ts; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 163 /* FunctionExpression */: - case 201 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 228 /* SourceFile */: - if (container.kind === 228 /* SourceFile */ && !ts.isExternalModule(container)) { + case 230 /* SourceFile */: + if (container.kind === 230 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -41311,11 +41745,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 202 /* ClassDeclaration */) { + if (declaration.kind === 204 /* ClassDeclaration */) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 203 /* InterfaceDeclaration */) { + else if (declaration.kind === 205 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -41376,19 +41810,19 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_31 = node.text; + var name_28 = node.text; if (contextualType) { if (contextualType.flags & 16384 /* Union */) { // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) // if not, search the constituent types for the property - var unionProperty = contextualType.getProperty(name_31); + var unionProperty = contextualType.getProperty(name_28); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_31); + var symbol = t.getProperty(name_28); if (symbol) { result_4.push(symbol); } @@ -41397,7 +41831,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_31); + var symbol_1 = contextualType.getProperty(name_28); if (symbol_1) { return [symbol_1]; } @@ -41455,10 +41889,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 169 /* PostfixUnaryExpression */ || parent.kind === 168 /* PrefixUnaryExpression */) { + if (parent.kind === 171 /* PostfixUnaryExpression */ || parent.kind === 170 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 170 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 172 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; return 53 /* FirstAssignment */ <= operator && operator <= 64 /* LastAssignment */; } @@ -41492,33 +41926,33 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 130 /* Parameter */: - case 199 /* VariableDeclaration */: - case 153 /* BindingElement */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: - case 225 /* PropertyAssignment */: - case 226 /* ShorthandPropertyAssignment */: - case 227 /* EnumMember */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 136 /* Constructor */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 201 /* FunctionDeclaration */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: - case 224 /* CatchClause */: + case 131 /* Parameter */: + case 201 /* VariableDeclaration */: + case 155 /* BindingElement */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: + case 227 /* PropertyAssignment */: + case 228 /* ShorthandPropertyAssignment */: + case 229 /* EnumMember */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 137 /* Constructor */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 203 /* FunctionDeclaration */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: + case 226 /* CatchClause */: return 1 /* Value */; - case 129 /* TypeParameter */: - case 203 /* InterfaceDeclaration */: - case 204 /* TypeAliasDeclaration */: - case 146 /* TypeLiteral */: + case 130 /* TypeParameter */: + case 205 /* InterfaceDeclaration */: + case 206 /* TypeAliasDeclaration */: + case 148 /* TypeLiteral */: return 2 /* Type */; - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: if (node.name.kind === 8 /* StringLiteral */) { return 4 /* Namespace */ | 1 /* Value */; } @@ -41528,15 +41962,15 @@ var ts; else { return 4 /* Namespace */; } - case 213 /* NamedImports */: - case 214 /* ImportSpecifier */: - case 209 /* ImportEqualsDeclaration */: - case 210 /* ImportDeclaration */: - case 215 /* ExportAssignment */: - case 216 /* ExportDeclaration */: + case 215 /* NamedImports */: + case 216 /* ImportSpecifier */: + case 211 /* ImportEqualsDeclaration */: + case 212 /* ImportDeclaration */: + case 217 /* ExportAssignment */: + case 218 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 228 /* SourceFile */: + case 230 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; @@ -41546,7 +41980,8 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 142 /* TypeReference */ || node.parent.kind === 177 /* ExpressionWithTypeArguments */; + return node.parent.kind === 144 /* TypeReference */ || + (node.parent.kind === 179 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -41554,32 +41989,32 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 156 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 156 /* PropertyAccessExpression */) { + if (root.parent.kind === 158 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 158 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 177 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 223 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 179 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 225 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 202 /* ClassDeclaration */ && root.parent.parent.token === 102 /* ImplementsKeyword */) || - (decl.kind === 203 /* InterfaceDeclaration */ && root.parent.parent.token === 79 /* ExtendsKeyword */); + return (decl.kind === 204 /* ClassDeclaration */ && root.parent.parent.token === 102 /* ImplementsKeyword */) || + (decl.kind === 205 /* InterfaceDeclaration */ && root.parent.parent.token === 79 /* ExtendsKeyword */); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 127 /* QualifiedName */) { - while (root.parent && root.parent.kind === 127 /* QualifiedName */) { + if (root.parent.kind === 128 /* QualifiedName */) { + while (root.parent && root.parent.kind === 128 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 142 /* TypeReference */ && !isLastClause; + return root.parent.kind === 144 /* TypeReference */ && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 127 /* QualifiedName */) { + while (node.parent.kind === 128 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -41589,15 +42024,15 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 127 /* QualifiedName */ && + if (node.parent.kind === 128 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 209 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 211 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function getMeaningFromLocation(node) { - if (node.parent.kind === 215 /* ExportAssignment */) { + if (node.parent.kind === 217 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -41637,8 +42072,8 @@ var ts; return; } switch (node.kind) { - case 156 /* PropertyAccessExpression */: - case 127 /* QualifiedName */: + case 158 /* PropertyAccessExpression */: + case 128 /* QualifiedName */: case 8 /* StringLiteral */: case 80 /* FalseKeyword */: case 95 /* TrueKeyword */: @@ -41661,7 +42096,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 206 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 208 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -41695,6 +42130,7 @@ var ts; var sourceFile = getValidSourceFile(fileName); var typeChecker = program.getTypeChecker(); var result = []; + var classifiableNames = program.getClassifiableNames(); processNode(sourceFile); return { spans: result, endOfLineState: 0 /* None */ }; function pushClassification(start, length, type) { @@ -41704,6 +42140,9 @@ var ts; } function classifySymbol(symbol, meaningAtPosition) { var flags = symbol.getFlags(); + if ((flags & 788448 /* Classifiable */) === 0 /* None */) { + return; + } if (flags & 32 /* Class */) { return 11 /* className */; } @@ -41736,19 +42175,26 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 206 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) == 1 /* Instantiated */; + return declaration.kind === 208 /* ModuleDeclaration */ && + ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } } function processNode(node) { // Only walk into nodes that intersect the requested span. - if (node && ts.textSpanIntersectsWith(span, node.getStart(), node.getWidth())) { - if (node.kind === 65 /* Identifier */ && node.getWidth() > 0) { - var symbol = typeChecker.getSymbolAtLocation(node); - if (symbol) { - var type = classifySymbol(symbol, getMeaningFromLocation(node)); - if (type) { - pushClassification(node.getStart(), node.getWidth(), type); + if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { + if (node.kind === 65 /* Identifier */ && !ts.nodeIsMissing(node)) { + var identifier = node; + // Only bother calling into the typechecker if this is an identifier that + // could possibly resolve to a type name. This makes classification run + // in a third of the time it would normally take. + if (classifiableNames[identifier.text]) { + var symbol = typeChecker.getSymbolAtLocation(node); + if (symbol) { + var type = classifySymbol(symbol, getMeaningFromLocation(node)); + if (type) { + pushClassification(node.getStart(), node.getWidth(), type); + } } } } @@ -41795,6 +42241,8 @@ var ts; function getEncodedSyntacticClassifications(fileName, span) { // doesn't use compiler - no need to synchronize with host var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var spanStart = span.start; + var spanLength = span.length; // Make a scanner we can get trivia from. var triviaScanner = ts.createScanner(2 /* Latest */, false, sourceFile.text); var mergeConflictScanner = ts.createScanner(2 /* Latest */, false, sourceFile.text); @@ -41806,42 +42254,47 @@ var ts; result.push(length); result.push(type); } - function classifyLeadingTrivia(token) { - var tokenStart = ts.skipTrivia(sourceFile.text, token.pos, false); - if (tokenStart === token.pos) { - return; - } - // token has trivia. Classify them appropriately. + function classifyLeadingTriviaAndGetTokenStart(token) { triviaScanner.setTextPos(token.pos); while (true) { var start = triviaScanner.getTextPos(); + // only bother scanning if we have something that could be trivia. + if (!ts.couldStartTrivia(sourceFile.text, start)) { + return start; + } var kind = triviaScanner.scan(); var end = triviaScanner.getTextPos(); var width = end - start; // The moment we get something that isn't trivia, then stop processing. if (!ts.isTrivia(kind)) { - return; + return start; + } + // Don't bother with newlines/whitespace. + if (kind === 4 /* NewLineTrivia */ || kind === 5 /* WhitespaceTrivia */) { + continue; } // Only bother with the trivia if it at least intersects the span of interest. - if (ts.textSpanIntersectsWith(span, start, width)) { - if (ts.isComment(kind)) { - classifyComment(token, kind, start, width); + if (ts.isComment(kind)) { + classifyComment(token, kind, start, width); + // Classifying a comment might cause us to reuse the trivia scanner + // (because of jsdoc comments). So after we classify the comment make + // sure we set the scanner position back to where it needs to be. + triviaScanner.setTextPos(end); + continue; + } + if (kind === 6 /* ConflictMarkerTrivia */) { + var text = sourceFile.text; + var ch = text.charCodeAt(start); + // for the <<<<<<< and >>>>>>> markers, we just add them in as comments + // in the classification stream. + if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { + pushClassification(start, width, 1 /* comment */); continue; } - if (kind === 6 /* ConflictMarkerTrivia */) { - var text = sourceFile.text; - var ch = text.charCodeAt(start); - // for the <<<<<<< and >>>>>>> markers, we just add them in as comments - // in the classification stream. - if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { - pushClassification(start, width, 1 /* comment */); - continue; - } - // for the ======== add a comment for the first line, and then lex all - // subsequent lines up until the end of the conflict marker. - ts.Debug.assert(ch === 61 /* equals */); - classifyDisabledMergeCode(text, start, end); - } + // for the ======== add a comment for the first line, and then lex all + // subsequent lines up until the end of the conflict marker. + ts.Debug.assert(ch === 61 /* equals */); + classifyDisabledMergeCode(text, start, end); } } } @@ -41875,16 +42328,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 247 /* JSDocParameterTag */: + case 249 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 250 /* JSDocTemplateTag */: + case 252 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 249 /* JSDocTypeTag */: + case 251 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 248 /* JSDocReturnTag */: + case 250 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -41942,11 +42395,13 @@ var ts; } } function classifyToken(token) { - classifyLeadingTrivia(token); - if (token.getWidth() > 0) { + var tokenStart = classifyLeadingTriviaAndGetTokenStart(token); + var tokenWidth = token.end - tokenStart; + ts.Debug.assert(tokenWidth >= 0); + if (tokenWidth > 0) { var type = classifyTokenType(token.kind, token); if (type) { - pushClassification(token.getStart(), token.getWidth(), type); + pushClassification(tokenStart, tokenWidth, type); } } } @@ -41970,16 +42425,16 @@ var ts; if (token) { if (tokenKind === 53 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 199 /* VariableDeclaration */ || - token.parent.kind === 133 /* PropertyDeclaration */ || - token.parent.kind === 130 /* Parameter */) { + if (token.parent.kind === 201 /* VariableDeclaration */ || + token.parent.kind === 134 /* PropertyDeclaration */ || + token.parent.kind === 131 /* Parameter */) { return 5 /* operator */; } } - if (token.parent.kind === 170 /* BinaryExpression */ || - token.parent.kind === 168 /* PrefixUnaryExpression */ || - token.parent.kind === 169 /* PostfixUnaryExpression */ || - token.parent.kind === 171 /* ConditionalExpression */) { + if (token.parent.kind === 172 /* BinaryExpression */ || + token.parent.kind === 170 /* PrefixUnaryExpression */ || + token.parent.kind === 171 /* PostfixUnaryExpression */ || + token.parent.kind === 173 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -42002,32 +42457,32 @@ var ts; else if (tokenKind === 65 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 129 /* TypeParameter */: + case 130 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 203 /* InterfaceDeclaration */: + case 205 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 130 /* Parameter */: + case 131 /* Parameter */: if (token.parent.name === token) { return 17 /* parameterName */; } @@ -42042,10 +42497,10 @@ var ts; return; } // Ignore nodes that don't intersect the original span to classify. - if (ts.textSpanIntersectsWith(span, element.getFullStart(), element.getFullWidth())) { + if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { var children = element.getChildren(sourceFile); - for (var _i = 0; _i < children.length; _i++) { - var child = children[_i]; + for (var i = 0, n = children.length; i < n; i++) { + var child = children[i]; if (ts.isToken(child)) { classifyToken(child); } @@ -42372,7 +42827,7 @@ var ts; // then we want 'something' to be in the name table. Similarly, if we have // "a['propname']" then we want to store "propname" in the name table. if (ts.isDeclarationName(node) || - node.parent.kind === 220 /* ExternalModuleReference */ || + node.parent.kind === 222 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -42385,7 +42840,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 157 /* ElementAccessExpression */ && + node.parent.kind === 159 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /// Classifier @@ -42433,7 +42888,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 116 /* GetKeyword */ || - keyword2 === 121 /* SetKeyword */ || + keyword2 === 122 /* SetKeyword */ || keyword2 === 114 /* ConstructorKeyword */ || keyword2 === 109 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". @@ -42592,10 +43047,10 @@ var ts; angleBracketStack--; } else if (token === 112 /* AnyKeyword */ || - token === 122 /* StringKeyword */ || - token === 120 /* NumberKeyword */ || + token === 123 /* StringKeyword */ || + token === 121 /* NumberKeyword */ || token === 113 /* BooleanKeyword */ || - token === 123 /* SymbolKeyword */) { + token === 124 /* SymbolKeyword */) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, @@ -42766,7 +43221,7 @@ var ts; } } function isKeyword(token) { - return token >= 66 /* FirstKeyword */ && token <= 126 /* LastKeyword */; + return token >= 66 /* FirstKeyword */ && token <= 127 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -42824,7 +43279,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 228 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); + var proto = kind === 230 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = 0; proto.end = 0; @@ -42894,125 +43349,125 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 185 /* DoStatement */) { + if (node.parent.kind === 187 /* DoStatement */) { // Set span as if on while keyword return spanInPreviousNode(node); } - if (node.parent.kind === 187 /* ForStatement */) { + if (node.parent.kind === 189 /* ForStatement */) { // For now lets set the span on this expression, fix it later return textSpan(node); } - if (node.parent.kind === 170 /* BinaryExpression */ && node.parent.operatorToken.kind === 23 /* CommaToken */) { + if (node.parent.kind === 172 /* BinaryExpression */ && node.parent.operatorToken.kind === 23 /* CommaToken */) { // if this is comma expression, the breakpoint is possible in this expression return textSpan(node); } - if (node.parent.kind == 164 /* ArrowFunction */ && node.parent.body == node) { + if (node.parent.kind === 166 /* ArrowFunction */ && node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); } } switch (node.kind) { - case 181 /* VariableStatement */: + case 183 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 199 /* VariableDeclaration */: - case 133 /* PropertyDeclaration */: - case 132 /* PropertySignature */: + case 201 /* VariableDeclaration */: + case 134 /* PropertyDeclaration */: + case 133 /* PropertySignature */: return spanInVariableDeclaration(node); - case 130 /* Parameter */: + case 131 /* Parameter */: return spanInParameterDeclaration(node); - case 201 /* FunctionDeclaration */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 136 /* Constructor */: - case 163 /* FunctionExpression */: - case 164 /* ArrowFunction */: + case 203 /* FunctionDeclaration */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 137 /* Constructor */: + case 165 /* FunctionExpression */: + case 166 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 180 /* Block */: + case 182 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 207 /* ModuleBlock */: + case 209 /* ModuleBlock */: return spanInBlock(node); - case 224 /* CatchClause */: + case 226 /* CatchClause */: return spanInBlock(node.block); - case 183 /* ExpressionStatement */: + case 185 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 192 /* ReturnStatement */: + case 194 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 186 /* WhileStatement */: + case 188 /* WhileStatement */: // Span on while(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 185 /* DoStatement */: + case 187 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 198 /* DebuggerStatement */: + case 200 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 184 /* IfStatement */: + case 186 /* IfStatement */: // set on if(..) span return textSpan(node, ts.findNextToken(node.expression, node)); - case 195 /* LabeledStatement */: + case 197 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 191 /* BreakStatement */: - case 190 /* ContinueStatement */: + case 193 /* BreakStatement */: + case 192 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 187 /* ForStatement */: + case 189 /* ForStatement */: return spanInForStatement(node); - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: // span on for (a in ...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 194 /* SwitchStatement */: + case 196 /* SwitchStatement */: // span on switch(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 221 /* CaseClause */: - case 222 /* DefaultClause */: + case 223 /* CaseClause */: + case 224 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 197 /* TryStatement */: + case 199 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 196 /* ThrowStatement */: + case 198 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 215 /* ExportAssignment */: + case 217 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 209 /* ImportEqualsDeclaration */: + case 211 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 210 /* ImportDeclaration */: + case 212 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 216 /* ExportDeclaration */: + case 218 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 202 /* ClassDeclaration */: - case 205 /* EnumDeclaration */: - case 227 /* EnumMember */: - case 158 /* CallExpression */: - case 159 /* NewExpression */: + case 204 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 229 /* EnumMember */: + case 160 /* CallExpression */: + case 161 /* NewExpression */: // span on complete node return textSpan(node); - case 193 /* WithStatement */: + case 195 /* WithStatement */: // span in statement return spanInNode(node.statement); // No breakpoint in interface, type alias - case 203 /* InterfaceDeclaration */: - case 204 /* TypeAliasDeclaration */: + case 205 /* InterfaceDeclaration */: + case 206 /* TypeAliasDeclaration */: return undefined; // Tokens: case 22 /* SemicolonToken */: @@ -43042,11 +43497,11 @@ var ts; return spanInNextNode(node); default: // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 225 /* PropertyAssignment */ && node.parent.name === node) { + if (node.parent.kind === 227 /* PropertyAssignment */ && node.parent.name === node) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 161 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 163 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNode(node.parent.expression); } // return type of function go to previous token @@ -43059,12 +43514,12 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 188 /* ForInStatement */ || - variableDeclaration.parent.parent.kind === 189 /* ForOfStatement */) { + if (variableDeclaration.parent.parent.kind === 190 /* ForInStatement */ || + variableDeclaration.parent.parent.kind === 191 /* ForOfStatement */) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 181 /* VariableStatement */; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 187 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 183 /* VariableStatement */; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 189 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -43118,7 +43573,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1 /* Export */) || - (functionDeclaration.parent.kind === 202 /* ClassDeclaration */ && functionDeclaration.kind !== 136 /* Constructor */); + (functionDeclaration.parent.kind === 204 /* ClassDeclaration */ && functionDeclaration.kind !== 137 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -43141,18 +43596,18 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 206 /* ModuleDeclaration */: + case 208 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 186 /* WhileStatement */: - case 184 /* IfStatement */: - case 188 /* ForInStatement */: - case 189 /* ForOfStatement */: + case 188 /* WhileStatement */: + case 186 /* IfStatement */: + case 190 /* ForInStatement */: + case 191 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 187 /* ForStatement */: + case 189 /* ForStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement @@ -43160,7 +43615,7 @@ var ts; } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 200 /* VariableDeclarationList */) { + if (forStatement.initializer.kind === 202 /* VariableDeclarationList */) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -43180,13 +43635,13 @@ var ts; // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 205 /* EnumDeclaration */: + case 207 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 202 /* ClassDeclaration */: + case 204 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 208 /* CaseBlock */: + case 210 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -43194,25 +43649,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 207 /* ModuleBlock */: + case 209 /* ModuleBlock */: // If this is not instantiated module block no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 205 /* EnumDeclaration */: - case 202 /* ClassDeclaration */: + case 207 /* EnumDeclaration */: + case 204 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 180 /* Block */: + case 182 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through. - case 224 /* CatchClause */: + case 226 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 208 /* CaseBlock */: + case 210 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -43226,7 +43681,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 185 /* DoStatement */) { + if (node.parent.kind === 187 /* DoStatement */) { // Go to while keyword and do action instead return spanInPreviousNode(node); } @@ -43236,17 +43691,17 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 163 /* FunctionExpression */: - case 201 /* FunctionDeclaration */: - case 164 /* ArrowFunction */: - case 135 /* MethodDeclaration */: - case 134 /* MethodSignature */: - case 137 /* GetAccessor */: - case 138 /* SetAccessor */: - case 136 /* Constructor */: - case 186 /* WhileStatement */: - case 185 /* DoStatement */: - case 187 /* ForStatement */: + case 165 /* FunctionExpression */: + case 203 /* FunctionDeclaration */: + case 166 /* ArrowFunction */: + case 136 /* MethodDeclaration */: + case 135 /* MethodSignature */: + case 138 /* GetAccessor */: + case 139 /* SetAccessor */: + case 137 /* Constructor */: + case 188 /* WhileStatement */: + case 187 /* DoStatement */: + case 189 /* ForStatement */: return spanInPreviousNode(node); // Default to parent node default: @@ -43257,19 +43712,19 @@ var ts; } function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration - if (ts.isFunctionLike(node.parent) || node.parent.kind === 225 /* PropertyAssignment */) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 227 /* PropertyAssignment */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 161 /* TypeAssertionExpression */) { + if (node.parent.kind === 163 /* TypeAssertionExpression */) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 185 /* DoStatement */) { + if (node.parent.kind === 187 /* DoStatement */) { // Set span on while expression return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } @@ -43320,6 +43775,7 @@ var ts; ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { var oldSnapshotShim = oldSnapshot; var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + // TODO: should this be '==='? if (encoded == null) { return null; } @@ -43331,12 +43787,18 @@ var ts; var LanguageServiceShimHostAdapter = (function () { function LanguageServiceShimHostAdapter(shimHost) { this.shimHost = shimHost; + this.loggingEnabled = false; + this.tracingEnabled = false; } LanguageServiceShimHostAdapter.prototype.log = function (s) { - this.shimHost.log(s); + if (this.loggingEnabled) { + this.shimHost.log(s); + } }; LanguageServiceShimHostAdapter.prototype.trace = function (s) { - this.shimHost.trace(s); + if (this.tracingEnabled) { + this.shimHost.trace(s); + } }; LanguageServiceShimHostAdapter.prototype.error = function (s) { this.shimHost.error(s); @@ -43348,8 +43810,12 @@ var ts; } return this.shimHost.getProjectVersion(); }; + LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { + return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; + }; LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { var settingsJson = this.shimHost.getCompilationSettings(); + // TODO: should this be '==='? if (settingsJson == null || settingsJson == "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); return null; @@ -43415,13 +43881,13 @@ var ts; return CoreServicesShimHostAdapter; })(); ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; - function simpleForwardCall(logger, actionDescription, action, noPerfLogging) { - if (!noPerfLogging) { + function simpleForwardCall(logger, actionDescription, action, logPerformance) { + if (logPerformance) { logger.log(actionDescription); var start = Date.now(); } var result = action(); - if (!noPerfLogging) { + if (logPerformance) { var end = Date.now(); logger.log(actionDescription + " completed in " + (end - start) + " msec"); if (typeof (result) === "string") { @@ -43434,9 +43900,9 @@ var ts; } return result; } - function forwardJSONCall(logger, actionDescription, action, noPerfLogging) { + function forwardJSONCall(logger, actionDescription, action, logPerformance) { try { - var result = simpleForwardCall(logger, actionDescription, action, noPerfLogging); + var result = simpleForwardCall(logger, actionDescription, action, logPerformance); return JSON.stringify({ result: result }); } catch (err) { @@ -43478,10 +43944,11 @@ var ts; _super.call(this, factory); this.host = host; this.languageService = languageService; + this.logPerformance = false; this.logger = this.host; } LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action, false); + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); }; /// DISPOSE /** @@ -43788,12 +44255,12 @@ var ts; function ClassifierShimObject(factory, logger) { _super.call(this, factory); this.logger = logger; + this.logPerformance = false; this.classifier = ts.createClassifier(); } ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { var _this = this; - return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, - /*noPerfLogging:*/ true); + return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, this.logPerformance); }; /// COLORIZATION ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { @@ -43815,9 +44282,10 @@ var ts; _super.call(this, factory); this.logger = logger; this.host = host; + this.logPerformance = false; } CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action, false); + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { @@ -43874,7 +44342,6 @@ var ts; var TypeScriptServicesFactory = (function () { function TypeScriptServicesFactory() { this._shims = []; - this.documentRegistry = ts.createDocumentRegistry(); } /* * Returns script API version. @@ -43884,6 +44351,9 @@ var ts; }; TypeScriptServicesFactory.prototype.createLanguageServiceShim = function (host) { try { + if (this.documentRegistry === undefined) { + this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + } var hostAdapter = new LanguageServiceShimHostAdapter(host); var languageService = ts.createLanguageService(hostAdapter, this.documentRegistry); return new LanguageServiceShimObject(this, host, languageService);