diff --git a/tsserver/lib.d.ts b/tsserver/lib.d.ts index d25e29bd..40a29796 100644 --- a/tsserver/lib.d.ts +++ b/tsserver/lib.d.ts @@ -3881,7 +3881,7 @@ declare module Intl { currency?: string; currencyDisplay?: string; useGrouping?: boolean; - minimumintegerDigits?: number; + minimumIntegerDigits?: number; minimumFractionDigits?: number; maximumFractionDigits?: number; minimumSignificantDigits?: number; @@ -3894,7 +3894,7 @@ declare module Intl { style: string; currency?: string; currencyDisplay?: string; - minimumintegerDigits: number; + minimumIntegerDigits: number; minimumFractionDigits: number; maximumFractionDigits: number; minimumSignificantDigits?: number; @@ -4243,8 +4243,8 @@ interface AnalyserNode extends AudioNode { smoothingTimeConstant: number; getByteFrequencyData(array: Uint8Array): void; getByteTimeDomainData(array: Uint8Array): void; - getFloatFrequencyData(array: any): void; - getFloatTimeDomainData(array: any): void; + getFloatFrequencyData(array: Float32Array): void; + getFloatTimeDomainData(array: Float32Array): void; } declare var AnalyserNode: { @@ -4331,7 +4331,7 @@ interface AudioBuffer { length: number; numberOfChannels: number; sampleRate: number; - getChannelData(channel: number): any; + getChannelData(channel: number): Float32Array; } declare var AudioBuffer: { @@ -4375,7 +4375,7 @@ interface AudioContext extends EventTarget { createMediaElementSource(mediaElement: HTMLMediaElement): MediaElementAudioSourceNode; createOscillator(): OscillatorNode; createPanner(): PannerNode; - createPeriodicWave(real: any, imag: any): PeriodicWave; + createPeriodicWave(real: Float32Array, imag: Float32Array): PeriodicWave; createScriptProcessor(bufferSize?: number, numberOfInputChannels?: number, numberOfOutputChannels?: number): ScriptProcessorNode; createStereoPanner(): StereoPannerNode; createWaveShaper(): WaveShaperNode; @@ -4433,7 +4433,7 @@ interface AudioParam { linearRampToValueAtTime(value: number, endTime: number): void; setTargetAtTime(target: number, startTime: number, timeConstant: number): void; setValueAtTime(value: number, startTime: number): void; - setValueCurveAtTime(values: any, startTime: number, duration: number): void; + setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): void; } declare var AudioParam: { @@ -4509,7 +4509,7 @@ interface BiquadFilterNode extends AudioNode { frequency: AudioParam; gain: AudioParam; type: string; - getFrequencyResponse(frequencyHz: any, magResponse: any, phaseResponse: any): void; + getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; } declare var BiquadFilterNode: { @@ -5108,7 +5108,7 @@ declare var CanvasPattern: { interface CanvasRenderingContext2D { canvas: HTMLCanvasElement; - fillStyle: any; + fillStyle: string | CanvasGradient | CanvasPattern; font: string; globalAlpha: number; globalCompositeOperation: string; @@ -5123,7 +5123,7 @@ interface CanvasRenderingContext2D { shadowColor: string; shadowOffsetX: number; shadowOffsetY: number; - strokeStyle: any; + strokeStyle: string | CanvasGradient | CanvasPattern; textAlign: string; textBaseline: string; arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; @@ -6491,8 +6491,6 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven importNode(importedNode: Node, deep: boolean): Node; msElementsFromPoint(x: number, y: number): NodeList; msElementsFromRect(left: number, top: number, width: number, height: number): NodeList; - msGetPrintDocumentForNamedFlow(flowName: string): Document; - msSetPrintDocumentUriForNamedFlow(flowName: string, uri: string): void; /** * Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. * @param url Specifies a MIME type for the document. @@ -11314,27 +11312,6 @@ declare var MSHTMLWebViewElement: { new(): MSHTMLWebViewElement; } -interface MSHeaderFooter { - URL: string; - dateLong: string; - dateShort: string; - font: string; - htmlFoot: string; - htmlHead: string; - page: number; - pageTotal: number; - textFoot: string; - textHead: string; - timeLong: string; - timeShort: string; - title: string; -} - -declare var MSHeaderFooter: { - prototype: MSHeaderFooter; - new(): MSHeaderFooter; -} - interface MSInputMethodContext extends EventTarget { compositionEndOffset: number; compositionStartOffset: number; @@ -11493,24 +11470,6 @@ declare var MSPointerEvent: { new(typeArg: string, eventInitDict?: PointerEventInit): MSPointerEvent; } -interface MSPrintManagerTemplatePrinter extends MSTemplatePrinter, EventTarget { - percentScale: number; - showHeaderFooter: boolean; - shrinkToFit: boolean; - drawPreviewPage(element: HTMLElement, pageNumber: number): void; - endPrint(): void; - getPrintTaskOptionValue(key: string): any; - invalidatePreview(): void; - setPageCount(pageCount: number): void; - startPrint(): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var MSPrintManagerTemplatePrinter: { - prototype: MSPrintManagerTemplatePrinter; - new(): MSPrintManagerTemplatePrinter; -} - interface MSRangeCollection { length: number; item(index: number): Range; @@ -11558,63 +11517,6 @@ declare var MSStreamReader: { new(): MSStreamReader; } -interface MSTemplatePrinter { - collate: boolean; - copies: number; - currentPage: boolean; - currentPageAvail: boolean; - duplex: boolean; - footer: string; - frameActive: boolean; - frameActiveEnabled: boolean; - frameAsShown: boolean; - framesetDocument: boolean; - header: string; - headerFooterFont: string; - marginBottom: number; - marginLeft: number; - marginRight: number; - marginTop: number; - orientation: string; - pageFrom: number; - pageHeight: number; - pageTo: number; - pageWidth: number; - selectedPages: boolean; - selection: boolean; - selectionEnabled: boolean; - unprintableBottom: number; - unprintableLeft: number; - unprintableRight: number; - unprintableTop: number; - usePrinterCopyCollate: boolean; - createHeaderFooter(): MSHeaderFooter; - deviceSupports(property: string): any; - ensurePrintDialogDefaults(): boolean; - getPageMarginBottom(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginBottomImportant(pageRule: CSSPageRule): boolean; - getPageMarginLeft(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginLeftImportant(pageRule: CSSPageRule): boolean; - getPageMarginRight(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginRightImportant(pageRule: CSSPageRule): boolean; - getPageMarginTop(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginTopImportant(pageRule: CSSPageRule): boolean; - printBlankPage(): void; - printNonNative(document: any): boolean; - printNonNativeFrames(document: any, activeFrame: boolean): void; - printPage(element: HTMLElement): void; - showPageSetupDialog(): boolean; - showPrintDialog(): boolean; - startDoc(title: string): boolean; - stopDoc(): void; - updatePageStatus(status: number): void; -} - -declare var MSTemplatePrinter: { - prototype: MSTemplatePrinter; - new(): MSTemplatePrinter; -} - interface MSWebViewAsyncOperation extends EventTarget { error: DOMError; oncomplete: (ev: Event) => any; @@ -12032,6 +11934,10 @@ declare var Node: { } interface NodeFilter { + acceptNode(n: Node): number; +} + +declare var NodeFilter: { FILTER_ACCEPT: number; FILTER_REJECT: number; FILTER_SKIP: number; @@ -12049,7 +11955,6 @@ interface NodeFilter { SHOW_PROCESSING_INSTRUCTION: number; SHOW_TEXT: number; } -declare var NodeFilter: NodeFilter; interface NodeIterator { expandEntityReferences: boolean; @@ -12759,7 +12664,6 @@ declare var SVGDescElement: { interface SVGElement extends Element { id: string; - className: any; onclick: (ev: MouseEvent) => any; ondblclick: (ev: MouseEvent) => any; onfocusin: (ev: FocusEvent) => any; @@ -12773,6 +12677,7 @@ interface SVGElement extends Element { ownerSVGElement: SVGSVGElement; viewportElement: SVGElement; xmlbase: string; + className: any; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -14934,7 +14839,7 @@ declare var WEBGL_depth_texture: { } interface WaveShaperNode extends AudioNode { - curve: any; + curve: Float32Array; oversample: string; } @@ -15121,34 +15026,34 @@ interface WebGLRenderingContext { 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; + uniform1fv(location: WebGLUniformLocation, v: Float32Array): void; uniform1i(location: WebGLUniformLocation, x: number): void; uniform1iv(location: WebGLUniformLocation, v: Int32Array): void; uniform2f(location: WebGLUniformLocation, x: number, y: number): void; - uniform2fv(location: WebGLUniformLocation, v: any): void; + uniform2fv(location: WebGLUniformLocation, v: Float32Array): void; uniform2i(location: WebGLUniformLocation, x: number, y: number): void; uniform2iv(location: WebGLUniformLocation, v: Int32Array): void; uniform3f(location: WebGLUniformLocation, x: number, y: number, z: number): void; - uniform3fv(location: WebGLUniformLocation, v: any): void; + uniform3fv(location: WebGLUniformLocation, v: Float32Array): void; uniform3i(location: WebGLUniformLocation, x: number, y: number, z: number): void; uniform3iv(location: WebGLUniformLocation, v: Int32Array): void; uniform4f(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; - uniform4fv(location: WebGLUniformLocation, v: any): void; + uniform4fv(location: WebGLUniformLocation, v: Float32Array): void; uniform4i(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; uniform4iv(location: WebGLUniformLocation, v: Int32Array): void; - uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; - uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; - uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; + uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; useProgram(program: WebGLProgram): void; validateProgram(program: WebGLProgram): void; vertexAttrib1f(indx: number, x: number): void; - vertexAttrib1fv(indx: number, values: any): void; + vertexAttrib1fv(indx: number, values: Float32Array): void; vertexAttrib2f(indx: number, x: number, y: number): void; - vertexAttrib2fv(indx: number, values: any): void; + vertexAttrib2fv(indx: number, values: Float32Array): void; vertexAttrib3f(indx: number, x: number, y: number, z: number): void; - vertexAttrib3fv(indx: number, values: any): void; + vertexAttrib3fv(indx: number, values: Float32Array): void; vertexAttrib4f(indx: number, x: number, y: number, z: number, w: number): void; - vertexAttrib4fv(indx: number, values: any): void; + vertexAttrib4fv(indx: number, values: Float32Array): void; vertexAttribPointer(indx: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void; viewport(x: number, y: number, width: number, height: number): void; ACTIVE_ATTRIBUTES: number; @@ -15912,7 +15817,6 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window locationbar: BarProp; menubar: BarProp; msAnimationStartTime: number; - msTemplatePrinter: MSTemplatePrinter; name: string; navigator: Navigator; offscreenBuffering: string | boolean; @@ -16649,7 +16553,6 @@ interface XMLHttpRequestEventTarget { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } - interface NodeListOf extends NodeList { length: number; item(index: number): TNode; @@ -16670,8 +16573,6 @@ interface EventListenerObject { handleEvent(evt: Event): void; } -declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; - interface MessageEventInit extends EventInit { data?: any; origin?: string; @@ -16687,6 +16588,8 @@ interface ProgressEventInit extends EventInit { total?: number; } +declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; + interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } @@ -16747,7 +16650,6 @@ declare var location: Location; declare var locationbar: BarProp; declare var menubar: BarProp; declare var msAnimationStartTime: number; -declare var msTemplatePrinter: MSTemplatePrinter; declare var name: string; declare var navigator: Navigator; declare var offscreenBuffering: string | boolean; diff --git a/tsserver/lib.es6.d.ts b/tsserver/lib.es6.d.ts index 507f0da5..a7bf8f05 100644 --- a/tsserver/lib.es6.d.ts +++ b/tsserver/lib.es6.d.ts @@ -3965,7 +3965,34 @@ interface ObjectConstructor { * Copy the values of all of the enumerable own properties from one or more source objects to a * target object. Returns the target object. * @param target The target object to copy to. - * @param sources One or more source objects to copy properties from. + * @param source The source object from which to copy properties. + */ + assign(target: T, source: U): T & U; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source1 The first source object from which to copy properties. + * @param source2 The second source object from which to copy properties. + */ + assign(target: T, source1: U, source2: V): T & U & V; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source1 The first source object from which to copy properties. + * @param source2 The second source object from which to copy properties. + * @param source3 The third source object from which to copy properties. + */ + assign(target: T, source1: U, source2: V, source3: W): T & U & V & W; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param sources One or more source objects from which to copy properties */ assign(target: any, ...sources: any[]): any; @@ -5169,7 +5196,7 @@ declare module Intl { currency?: string; currencyDisplay?: string; useGrouping?: boolean; - minimumintegerDigits?: number; + minimumIntegerDigits?: number; minimumFractionDigits?: number; maximumFractionDigits?: number; minimumSignificantDigits?: number; @@ -5182,7 +5209,7 @@ declare module Intl { style: string; currency?: string; currencyDisplay?: string; - minimumintegerDigits: number; + minimumIntegerDigits: number; minimumFractionDigits: number; maximumFractionDigits: number; minimumSignificantDigits?: number; @@ -5531,8 +5558,8 @@ interface AnalyserNode extends AudioNode { smoothingTimeConstant: number; getByteFrequencyData(array: Uint8Array): void; getByteTimeDomainData(array: Uint8Array): void; - getFloatFrequencyData(array: any): void; - getFloatTimeDomainData(array: any): void; + getFloatFrequencyData(array: Float32Array): void; + getFloatTimeDomainData(array: Float32Array): void; } declare var AnalyserNode: { @@ -5619,7 +5646,7 @@ interface AudioBuffer { length: number; numberOfChannels: number; sampleRate: number; - getChannelData(channel: number): any; + getChannelData(channel: number): Float32Array; } declare var AudioBuffer: { @@ -5663,7 +5690,7 @@ interface AudioContext extends EventTarget { createMediaElementSource(mediaElement: HTMLMediaElement): MediaElementAudioSourceNode; createOscillator(): OscillatorNode; createPanner(): PannerNode; - createPeriodicWave(real: any, imag: any): PeriodicWave; + createPeriodicWave(real: Float32Array, imag: Float32Array): PeriodicWave; createScriptProcessor(bufferSize?: number, numberOfInputChannels?: number, numberOfOutputChannels?: number): ScriptProcessorNode; createStereoPanner(): StereoPannerNode; createWaveShaper(): WaveShaperNode; @@ -5721,7 +5748,7 @@ interface AudioParam { linearRampToValueAtTime(value: number, endTime: number): void; setTargetAtTime(target: number, startTime: number, timeConstant: number): void; setValueAtTime(value: number, startTime: number): void; - setValueCurveAtTime(values: any, startTime: number, duration: number): void; + setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): void; } declare var AudioParam: { @@ -5797,7 +5824,7 @@ interface BiquadFilterNode extends AudioNode { frequency: AudioParam; gain: AudioParam; type: string; - getFrequencyResponse(frequencyHz: any, magResponse: any, phaseResponse: any): void; + getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; } declare var BiquadFilterNode: { @@ -6396,7 +6423,7 @@ declare var CanvasPattern: { interface CanvasRenderingContext2D { canvas: HTMLCanvasElement; - fillStyle: any; + fillStyle: string | CanvasGradient | CanvasPattern; font: string; globalAlpha: number; globalCompositeOperation: string; @@ -6411,7 +6438,7 @@ interface CanvasRenderingContext2D { shadowColor: string; shadowOffsetX: number; shadowOffsetY: number; - strokeStyle: any; + strokeStyle: string | CanvasGradient | CanvasPattern; textAlign: string; textBaseline: string; arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; @@ -7779,8 +7806,6 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven importNode(importedNode: Node, deep: boolean): Node; msElementsFromPoint(x: number, y: number): NodeList; msElementsFromRect(left: number, top: number, width: number, height: number): NodeList; - msGetPrintDocumentForNamedFlow(flowName: string): Document; - msSetPrintDocumentUriForNamedFlow(flowName: string, uri: string): void; /** * Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. * @param url Specifies a MIME type for the document. @@ -12602,27 +12627,6 @@ declare var MSHTMLWebViewElement: { new(): MSHTMLWebViewElement; } -interface MSHeaderFooter { - URL: string; - dateLong: string; - dateShort: string; - font: string; - htmlFoot: string; - htmlHead: string; - page: number; - pageTotal: number; - textFoot: string; - textHead: string; - timeLong: string; - timeShort: string; - title: string; -} - -declare var MSHeaderFooter: { - prototype: MSHeaderFooter; - new(): MSHeaderFooter; -} - interface MSInputMethodContext extends EventTarget { compositionEndOffset: number; compositionStartOffset: number; @@ -12781,24 +12785,6 @@ declare var MSPointerEvent: { new(typeArg: string, eventInitDict?: PointerEventInit): MSPointerEvent; } -interface MSPrintManagerTemplatePrinter extends MSTemplatePrinter, EventTarget { - percentScale: number; - showHeaderFooter: boolean; - shrinkToFit: boolean; - drawPreviewPage(element: HTMLElement, pageNumber: number): void; - endPrint(): void; - getPrintTaskOptionValue(key: string): any; - invalidatePreview(): void; - setPageCount(pageCount: number): void; - startPrint(): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var MSPrintManagerTemplatePrinter: { - prototype: MSPrintManagerTemplatePrinter; - new(): MSPrintManagerTemplatePrinter; -} - interface MSRangeCollection { length: number; item(index: number): Range; @@ -12846,63 +12832,6 @@ declare var MSStreamReader: { new(): MSStreamReader; } -interface MSTemplatePrinter { - collate: boolean; - copies: number; - currentPage: boolean; - currentPageAvail: boolean; - duplex: boolean; - footer: string; - frameActive: boolean; - frameActiveEnabled: boolean; - frameAsShown: boolean; - framesetDocument: boolean; - header: string; - headerFooterFont: string; - marginBottom: number; - marginLeft: number; - marginRight: number; - marginTop: number; - orientation: string; - pageFrom: number; - pageHeight: number; - pageTo: number; - pageWidth: number; - selectedPages: boolean; - selection: boolean; - selectionEnabled: boolean; - unprintableBottom: number; - unprintableLeft: number; - unprintableRight: number; - unprintableTop: number; - usePrinterCopyCollate: boolean; - createHeaderFooter(): MSHeaderFooter; - deviceSupports(property: string): any; - ensurePrintDialogDefaults(): boolean; - getPageMarginBottom(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginBottomImportant(pageRule: CSSPageRule): boolean; - getPageMarginLeft(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginLeftImportant(pageRule: CSSPageRule): boolean; - getPageMarginRight(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginRightImportant(pageRule: CSSPageRule): boolean; - getPageMarginTop(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginTopImportant(pageRule: CSSPageRule): boolean; - printBlankPage(): void; - printNonNative(document: any): boolean; - printNonNativeFrames(document: any, activeFrame: boolean): void; - printPage(element: HTMLElement): void; - showPageSetupDialog(): boolean; - showPrintDialog(): boolean; - startDoc(title: string): boolean; - stopDoc(): void; - updatePageStatus(status: number): void; -} - -declare var MSTemplatePrinter: { - prototype: MSTemplatePrinter; - new(): MSTemplatePrinter; -} - interface MSWebViewAsyncOperation extends EventTarget { error: DOMError; oncomplete: (ev: Event) => any; @@ -13320,6 +13249,10 @@ declare var Node: { } interface NodeFilter { + acceptNode(n: Node): number; +} + +declare var NodeFilter: { FILTER_ACCEPT: number; FILTER_REJECT: number; FILTER_SKIP: number; @@ -13337,7 +13270,6 @@ interface NodeFilter { SHOW_PROCESSING_INSTRUCTION: number; SHOW_TEXT: number; } -declare var NodeFilter: NodeFilter; interface NodeIterator { expandEntityReferences: boolean; @@ -14047,7 +13979,6 @@ declare var SVGDescElement: { interface SVGElement extends Element { id: string; - className: any; onclick: (ev: MouseEvent) => any; ondblclick: (ev: MouseEvent) => any; onfocusin: (ev: FocusEvent) => any; @@ -14061,6 +13992,7 @@ interface SVGElement extends Element { ownerSVGElement: SVGSVGElement; viewportElement: SVGElement; xmlbase: string; + className: any; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -16222,7 +16154,7 @@ declare var WEBGL_depth_texture: { } interface WaveShaperNode extends AudioNode { - curve: any; + curve: Float32Array; oversample: string; } @@ -16409,34 +16341,34 @@ interface WebGLRenderingContext { 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; + uniform1fv(location: WebGLUniformLocation, v: Float32Array): void; uniform1i(location: WebGLUniformLocation, x: number): void; uniform1iv(location: WebGLUniformLocation, v: Int32Array): void; uniform2f(location: WebGLUniformLocation, x: number, y: number): void; - uniform2fv(location: WebGLUniformLocation, v: any): void; + uniform2fv(location: WebGLUniformLocation, v: Float32Array): void; uniform2i(location: WebGLUniformLocation, x: number, y: number): void; uniform2iv(location: WebGLUniformLocation, v: Int32Array): void; uniform3f(location: WebGLUniformLocation, x: number, y: number, z: number): void; - uniform3fv(location: WebGLUniformLocation, v: any): void; + uniform3fv(location: WebGLUniformLocation, v: Float32Array): void; uniform3i(location: WebGLUniformLocation, x: number, y: number, z: number): void; uniform3iv(location: WebGLUniformLocation, v: Int32Array): void; uniform4f(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; - uniform4fv(location: WebGLUniformLocation, v: any): void; + uniform4fv(location: WebGLUniformLocation, v: Float32Array): void; uniform4i(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; uniform4iv(location: WebGLUniformLocation, v: Int32Array): void; - uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; - uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; - uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; + uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; useProgram(program: WebGLProgram): void; validateProgram(program: WebGLProgram): void; vertexAttrib1f(indx: number, x: number): void; - vertexAttrib1fv(indx: number, values: any): void; + vertexAttrib1fv(indx: number, values: Float32Array): void; vertexAttrib2f(indx: number, x: number, y: number): void; - vertexAttrib2fv(indx: number, values: any): void; + vertexAttrib2fv(indx: number, values: Float32Array): void; vertexAttrib3f(indx: number, x: number, y: number, z: number): void; - vertexAttrib3fv(indx: number, values: any): void; + vertexAttrib3fv(indx: number, values: Float32Array): void; vertexAttrib4f(indx: number, x: number, y: number, z: number, w: number): void; - vertexAttrib4fv(indx: number, values: any): void; + vertexAttrib4fv(indx: number, values: Float32Array): void; vertexAttribPointer(indx: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void; viewport(x: number, y: number, width: number, height: number): void; ACTIVE_ATTRIBUTES: number; @@ -17200,7 +17132,6 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window locationbar: BarProp; menubar: BarProp; msAnimationStartTime: number; - msTemplatePrinter: MSTemplatePrinter; name: string; navigator: Navigator; offscreenBuffering: string | boolean; @@ -17937,7 +17868,6 @@ interface XMLHttpRequestEventTarget { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } - interface NodeListOf extends NodeList { length: number; item(index: number): TNode; @@ -17958,8 +17888,6 @@ interface EventListenerObject { handleEvent(evt: Event): void; } -declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; - interface MessageEventInit extends EventInit { data?: any; origin?: string; @@ -17975,6 +17903,8 @@ interface ProgressEventInit extends EventInit { total?: number; } +declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; + interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } @@ -18035,7 +17965,6 @@ declare var location: Location; declare var locationbar: BarProp; declare var menubar: BarProp; declare var msAnimationStartTime: number; -declare var msTemplatePrinter: MSTemplatePrinter; declare var name: string; declare var navigator: Navigator; declare var offscreenBuffering: string | boolean; diff --git a/tsserver/tsc.js b/tsserver/tsc.js index 54e41f4b..f4f0974a 100644 --- a/tsserver/tsc.js +++ b/tsserver/tsc.js @@ -47,7 +47,6 @@ var ts; })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); var DiagnosticCategory = ts.DiagnosticCategory; })(ts || (ts = {})); -/// var ts; (function (ts) { function createFileMap(getCanonicalFileName) { @@ -411,8 +410,11 @@ var ts; } ts.chainDiagnosticMessages = chainDiagnosticMessages; function concatenateDiagnosticMessageChains(headChain, tailChain) { - Debug.assert(!headChain.next); - headChain.next = tailChain; + var lastChain = headChain; + while (lastChain.next) { + lastChain = lastChain.next; + } + lastChain.next = tailChain; return headChain; } ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; @@ -569,9 +571,6 @@ var ts; } ts.getNormalizedPathFromPathComponents = getNormalizedPathFromPathComponents; function getNormalizedPathComponentsOfUrl(url) { - // Get root length of http://www.website.com/folder1/foler2/ - // In this example the root is: http://www.website.com/ - // normalized path components should be ["http://www.website.com/", "folder1", "folder2"] var urlLength = url.length; var rootLength = url.indexOf("://") + "://".length; while (rootLength < urlLength) { @@ -631,6 +630,9 @@ var ts; } ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; function getBaseFileName(path) { + if (!path) { + return undefined; + } var i = path.lastIndexOf(ts.directorySeparator); return i < 0 ? path : path.substring(i + 1); } @@ -654,6 +656,20 @@ var ts; } ts.fileExtensionIs = fileExtensionIs; ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; + ts.moduleFileExtensions = ts.supportedExtensions; + function isSupportedSourceFileName(fileName) { + if (!fileName) { + return false; + } + for (var _i = 0; _i < ts.supportedExtensions.length; _i++) { + var extension = ts.supportedExtensions[_i]; + if (fileExtensionIs(fileName, extension)) { + return true; + } + } + return false; + } + ts.isSupportedSourceFileName = isSupportedSourceFileName; var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { @@ -730,8 +746,18 @@ var ts; } Debug.fail = fail; })(Debug = ts.Debug || (ts.Debug = {})); + function copyListRemovingItem(item, list) { + var copiedList = []; + for (var _i = 0; _i < list.length; _i++) { + var e = list[_i]; + if (e !== item) { + copiedList.push(e); + } + } + return copiedList; + } + ts.copyListRemovingItem = copyListRemovingItem; })(ts || (ts = {})); -/// var ts; (function (ts) { ts.sys = (function () { @@ -869,6 +895,76 @@ var ts; var _fs = require("fs"); var _path = require("path"); var _os = require("os"); + function createWatchedFileSet(interval, chunkSize) { + if (interval === void 0) { interval = 2500; } + if (chunkSize === void 0) { chunkSize = 30; } + var watchedFiles = []; + var nextFileToCheck = 0; + var watchTimer; + function getModifiedTime(fileName) { + return _fs.statSync(fileName).mtime; + } + function poll(checkedIndex) { + var watchedFile = watchedFiles[checkedIndex]; + if (!watchedFile) { + return; + } + _fs.stat(watchedFile.fileName, function (err, stats) { + if (err) { + watchedFile.callback(watchedFile.fileName); + } + else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { + watchedFile.mtime = getModifiedTime(watchedFile.fileName); + watchedFile.callback(watchedFile.fileName, watchedFile.mtime.getTime() === 0); + } + }); + } + function startWatchTimer() { + watchTimer = setInterval(function () { + var count = 0; + var nextToCheck = nextFileToCheck; + var firstCheck = -1; + while ((count < chunkSize) && (nextToCheck !== firstCheck)) { + poll(nextToCheck); + if (firstCheck < 0) { + firstCheck = nextToCheck; + } + nextToCheck++; + if (nextToCheck === watchedFiles.length) { + nextToCheck = 0; + } + count++; + } + nextFileToCheck = nextToCheck; + }, interval); + } + function addFile(fileName, callback) { + var file = { + fileName: fileName, + callback: callback, + mtime: getModifiedTime(fileName) + }; + watchedFiles.push(file); + if (watchedFiles.length === 1) { + startWatchTimer(); + } + return file; + } + function removeFile(file) { + watchedFiles = ts.copyListRemovingItem(file, watchedFiles); + } + return { + getModifiedTime: getModifiedTime, + poll: poll, + startWatchTimer: startWatchTimer, + addFile: addFile, + removeFile: removeFile + }; + } + var watchedFileSet = createWatchedFileSet(); + function isNode4OrLater() { + return parseInt(process.version.charAt(1)) >= 4; + } var platform = _os.platform(); var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; function readFile(fileName, encoding) { @@ -949,16 +1045,21 @@ var ts; readFile: readFile, writeFile: writeFile, watchFile: function (fileName, callback) { - _fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged); + if (isNode4OrLater()) { + return _fs.watch(fileName, function (eventName, relativeFileName) { return callback(fileName); }); + } + var watchedFile = watchedFileSet.addFile(fileName, callback); return { - close: function () { _fs.unwatchFile(fileName, fileChanged); } + close: function () { return watchedFileSet.removeFile(watchedFile); } }; - function fileChanged(curr, prev) { - if (+curr.mtime <= +prev.mtime) { - return; + }, + watchDirectory: function (path, callback, recursive) { + return _fs.watch(path, { persistent: true, recursive: !!recursive }, function (eventName, relativeFileName) { + if (eventName === "rename") { + callback(!relativeFileName ? relativeFileName : ts.normalizePath(ts.combinePaths(path, relativeFileName))); } - callback(fileName); - } + ; + }); }, resolvePath: function (path) { return _path.resolve(path); @@ -1003,7 +1104,6 @@ var ts; } })(); })(ts || (ts = {})); -/// var ts; (function (ts) { ts.Diagnostics = { @@ -1056,7 +1156,7 @@ var ts; Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum member must have initializer." }, _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." }, - Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: ts.DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers." }, + In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { code: 1066, category: ts.DiagnosticCategory.Error, key: "In ambient enum declarations member initializer must be constant expression." }, Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." }, @@ -1144,7 +1244,7 @@ var ts; Property_destructuring_pattern_expected: { code: 1180, category: ts.DiagnosticCategory.Error, key: "Property destructuring pattern expected." }, Array_element_destructuring_pattern_expected: { code: 1181, category: ts.DiagnosticCategory.Error, key: "Array element destructuring pattern expected." }, A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: ts.DiagnosticCategory.Error, key: "A destructuring declaration must have an initializer." }, - An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: ts.DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, + An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1183, category: ts.DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, Modifiers_cannot_appear_here: { code: 1184, category: ts.DiagnosticCategory.Error, key: "Modifiers cannot appear here." }, Merge_conflict_marker_encountered: { code: 1185, category: ts.DiagnosticCategory.Error, key: "Merge conflict marker encountered." }, A_rest_element_cannot_have_an_initializer: { code: 1186, category: ts.DiagnosticCategory.Error, key: "A rest element cannot have an initializer." }, @@ -1162,10 +1262,9 @@ var ts; An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: ts.DiagnosticCategory.Error, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, Unterminated_Unicode_escape_sequence: { code: 1199, category: ts.DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." }, Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." }, - Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." }, - Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." }, - Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher." }, - Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: ts.DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." }, + Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead." }, + Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead." }, + Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'es6' when targeting 'ES5' or lower." }, Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." }, Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, @@ -1194,10 +1293,6 @@ var ts; 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." }, - Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning: { code: 1236, category: ts.DiagnosticCategory.Error, key: "Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning." }, - with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, - await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, - Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: ts.DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." }, The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: ts.DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." }, Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." }, @@ -1208,6 +1303,10 @@ var ts; _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with '{1}' modifier." }, Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: ts.DiagnosticCategory.Error, key: "Abstract methods can only appear within an abstract class." }, Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: ts.DiagnosticCategory.Error, key: "Method '{0}' cannot have an implementation because it is marked abstract." }, + with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, + await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, + Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, + can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "'=' can only be used in an object literal property inside a destructuring assignment." }, 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." }, @@ -1248,7 +1347,7 @@ var ts; Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." }, Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: ts.DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword." }, Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." }, - An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." }, + An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." }, Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." }, Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." }, Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." }, @@ -1332,7 +1431,7 @@ var ts; In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, - Ambient_modules_cannot_be_nested_in_other_modules: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules." }, + Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules or namespaces." }, Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient module declaration cannot specify relative module name." }, Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module '{0}' is hidden by a local declaration with the same name" }, Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import name cannot be '{0}'" }, @@ -1413,12 +1512,15 @@ var ts; Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: ts.DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." }, Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, - Only_an_ambient_class_can_be_merged_with_an_interface: { code: 2518, category: ts.DiagnosticCategory.Error, key: "Only an ambient class can be merged with an interface." }, Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." }, await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." }, + Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." }, + A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { code: 2526, category: ts.DiagnosticCategory.Error, key: "A 'this' type is available only in a non-static member of a class or interface." }, + The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { code: 2527, category: ts.DiagnosticCategory.Error, key: "The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary." }, + A_module_cannot_have_multiple_default_exports: { code: 2528, category: ts.DiagnosticCategory.Error, key: "A module cannot have multiple default exports." }, JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -1431,8 +1533,10 @@ var ts; Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, + Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." }, Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." }, Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition: { code: 2655, category: ts.DiagnosticCategory.Error, key: "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition." }, + Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." }, 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}'." }, @@ -1517,7 +1621,7 @@ var ts; Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, - A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, @@ -1529,7 +1633,7 @@ var ts; Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." }, Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." }, Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, - Specify_module_code_generation_Colon_commonjs_amd_system_or_umd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system' or 'umd'" }, + Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es6'" }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print the compiler's version." }, Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile the project in the given directory." }, @@ -1550,7 +1654,7 @@ var ts; Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_amd_system_or_umd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system' or 'umd'." }, + Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es6'." }, Argument_for_target_option_must_be_ES3_ES5_or_ES6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES6'." }, Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, @@ -1571,7 +1675,6 @@ var ts; Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, - Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." }, Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, @@ -1618,79 +1721,83 @@ var ts; Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" } + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" }, + An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17006, category: ts.DiagnosticCategory.Error, key: "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, + A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17007, category: ts.DiagnosticCategory.Error, key: "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." } }; })(ts || (ts = {})); -/// -/// var ts; (function (ts) { + function tokenIsIdentifierOrKeyword(token) { + return token >= 69; + } + ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = { - "abstract": 113, - "any": 115, - "as": 114, - "boolean": 118, - "break": 68, - "case": 69, - "catch": 70, - "class": 71, - "continue": 73, - "const": 72, - "constructor": 119, - "debugger": 74, - "declare": 120, - "default": 75, - "delete": 76, - "do": 77, - "else": 78, - "enum": 79, - "export": 80, - "extends": 81, - "false": 82, - "finally": 83, - "for": 84, - "from": 131, - "function": 85, - "get": 121, - "if": 86, - "implements": 104, - "import": 87, - "in": 88, - "instanceof": 89, - "interface": 105, - "is": 122, - "let": 106, - "module": 123, - "namespace": 124, - "new": 90, - "null": 91, - "number": 126, - "package": 107, - "private": 108, - "protected": 109, - "public": 110, - "require": 125, - "return": 92, - "set": 127, - "static": 111, - "string": 128, - "super": 93, - "switch": 94, - "symbol": 129, - "this": 95, - "throw": 96, - "true": 97, - "try": 98, - "type": 130, - "typeof": 99, - "var": 100, - "void": 101, - "while": 102, - "with": 103, - "yield": 112, - "async": 116, - "await": 117, - "of": 132, + "abstract": 115, + "any": 117, + "as": 116, + "boolean": 120, + "break": 70, + "case": 71, + "catch": 72, + "class": 73, + "continue": 75, + "const": 74, + "constructor": 121, + "debugger": 76, + "declare": 122, + "default": 77, + "delete": 78, + "do": 79, + "else": 80, + "enum": 81, + "export": 82, + "extends": 83, + "false": 84, + "finally": 85, + "for": 86, + "from": 133, + "function": 87, + "get": 123, + "if": 88, + "implements": 106, + "import": 89, + "in": 90, + "instanceof": 91, + "interface": 107, + "is": 124, + "let": 108, + "module": 125, + "namespace": 126, + "new": 92, + "null": 93, + "number": 128, + "package": 109, + "private": 110, + "protected": 111, + "public": 112, + "require": 127, + "return": 94, + "set": 129, + "static": 113, + "string": 130, + "super": 95, + "switch": 96, + "symbol": 131, + "this": 97, + "throw": 98, + "true": 99, + "try": 100, + "type": 132, + "typeof": 101, + "var": 102, + "void": 103, + "while": 104, + "with": 105, + "yield": 114, + "async": 118, + "await": 119, + "of": 134, "{": 15, "}": 16, "(": 17, @@ -1712,37 +1819,39 @@ var ts; "=>": 34, "+": 35, "-": 36, + "**": 38, "*": 37, - "/": 38, - "%": 39, - "++": 40, - "--": 41, - "<<": 42, + "/": 39, + "%": 40, + "++": 41, + "--": 42, + "<<": 43, ">": 43, - ">>>": 44, - "&": 45, - "|": 46, - "^": 47, - "!": 48, - "~": 49, - "&&": 50, - "||": 51, - "?": 52, - ":": 53, - "=": 55, - "+=": 56, - "-=": 57, - "*=": 58, - "/=": 59, - "%=": 60, - "<<=": 61, - ">>=": 62, - ">>>=": 63, - "&=": 64, - "|=": 65, - "^=": 66, - "@": 54 + ">>": 44, + ">>>": 45, + "&": 46, + "|": 47, + "^": 48, + "!": 49, + "~": 50, + "&&": 51, + "||": 52, + "?": 53, + ":": 54, + "=": 56, + "+=": 57, + "-=": 58, + "*=": 59, + "**=": 60, + "/=": 61, + "%=": 62, + "<<=": 63, + ">>=": 64, + ">>>=": 65, + "&=": 66, + "|=": 67, + "^=": 68, + "@": 55 }; var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; @@ -1872,16 +1981,6 @@ var ts; } ts.isWhiteSpace = isWhiteSpace; function isLineBreak(ch) { - // ES5 7.3: - // The ECMAScript line terminator characters are listed in Table 3. - // Table 3: Line Terminator Characters - // Code Unit Value Name Formal Name - // \u000A Line Feed - // \u000D Carriage Return - // \u2028 Line separator - // \u2029 Paragraph separator - // Only the characters in Table 3 are treated as line terminators. Other new line or line - // breaking characters are treated as white space but not as line terminators. return ch === 10 || ch === 13 || ch === 8232 || @@ -2154,8 +2253,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 67 || token > 103; }, - isReservedWord: function () { return token >= 68 && token <= 103; }, + isIdentifier: function () { return token === 69 || token > 105; }, + isReservedWord: function () { return token >= 70 && token <= 105; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -2177,16 +2276,6 @@ var ts; onError(message, length || 0); } } - function isIdentifierStart(ch) { - return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || - ch === 36 || ch === 95 || - ch > 127 && isUnicodeIdentifierStart(ch, languageVersion); - } - function isIdentifierPart(ch) { - return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || - ch >= 48 && ch <= 57 || ch === 36 || ch === 95 || - ch > 127 && isUnicodeIdentifierPart(ch, languageVersion); - } function scanNumber() { var start = pos; while (isDigit(text.charCodeAt(pos))) @@ -2441,12 +2530,12 @@ var ts; var start = pos; while (pos < end) { var ch = text.charCodeAt(pos); - if (isIdentifierPart(ch)) { + if (isIdentifierPart(ch, languageVersion)) { pos++; } else if (ch === 92) { ch = peekUnicodeEscape(); - if (!(ch >= 0 && isIdentifierPart(ch))) { + if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } result += text.substring(start, pos); @@ -2469,7 +2558,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 67; + return token = 69; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -2548,7 +2637,7 @@ var ts; } return pos += 2, token = 31; } - return pos++, token = 48; + return pos++, token = 49; case 34: case 39: tokenValue = scanString(); @@ -2557,42 +2646,48 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 60; + return pos += 2, token = 62; } - return pos++, token = 39; + return pos++, token = 40; case 38: if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 50; + return pos += 2, token = 51; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 64; + return pos += 2, token = 66; } - return pos++, token = 45; + return pos++, token = 46; case 40: return pos++, token = 17; case 41: return pos++, token = 18; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; + return pos += 2, token = 59; + } + if (text.charCodeAt(pos + 1) === 42) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 60; + } + return pos += 2, token = 38; } return pos++, token = 37; case 43: if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 40; + return pos += 2, token = 41; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 56; + return pos += 2, token = 57; } return pos++, token = 35; case 44: return pos++, token = 24; case 45: if (text.charCodeAt(pos + 1) === 45) { - return pos += 2, token = 41; + return pos += 2, token = 42; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; + return pos += 2, token = 58; } return pos++, token = 36; case 46: @@ -2647,9 +2742,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 59; + return pos += 2, token = 61; } - return pos++, token = 38; + return pos++, token = 39; case 48: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { pos += 2; @@ -2697,7 +2792,7 @@ var ts; tokenValue = "" + scanNumber(); return token = 8; case 58: - return pos++, token = 53; + return pos++, token = 54; case 59: return pos++, token = 23; case 60: @@ -2712,14 +2807,16 @@ var ts; } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 61; + return pos += 3, token = 63; } - return pos += 2, token = 42; + return pos += 2, token = 43; } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 28; } - if (text.charCodeAt(pos + 1) === 47 && languageVariant === 1) { + if (languageVariant === 1 && + text.charCodeAt(pos + 1) === 47 && + text.charCodeAt(pos + 2) !== 42) { return pos += 2, token = 26; } return pos++, token = 25; @@ -2742,7 +2839,7 @@ var ts; if (text.charCodeAt(pos + 1) === 62) { return pos += 2, token = 34; } - return pos++, token = 55; + return pos++, token = 56; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2755,35 +2852,35 @@ var ts; } return pos++, token = 27; case 63: - return pos++, token = 52; + return pos++, token = 53; case 91: return pos++, token = 19; case 93: return pos++, token = 20; case 94: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 66; + return pos += 2, token = 68; } - return pos++, token = 47; + return pos++, token = 48; case 123: return pos++, token = 15; case 124: if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 51; + return pos += 2, token = 52; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 65; + return pos += 2, token = 67; } - return pos++, token = 46; + return pos++, token = 47; case 125: return pos++, token = 16; case 126: - return pos++, token = 49; + return pos++, token = 50; case 64: - return pos++, token = 54; + return pos++, token = 55; case 92: var cookedChar = peekUnicodeEscape(); - if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); @@ -2791,9 +2888,9 @@ var ts; error(ts.Diagnostics.Invalid_character); return pos++, token = 0; default: - if (isIdentifierStart(ch)) { + if (isIdentifierStart(ch, languageVersion)) { pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos))) + while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) pos++; tokenValue = text.substring(tokenPos, pos); if (ch === 92) { @@ -2820,14 +2917,14 @@ var ts; if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 63; + return pos += 3, token = 65; } - return pos += 2, token = 44; + return pos += 2, token = 45; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; + return pos += 2, token = 64; } - return pos++, token = 43; + return pos++, token = 44; } if (text.charCodeAt(pos) === 61) { return pos++, token = 29; @@ -2836,7 +2933,7 @@ var ts; return token; } function reScanSlashToken() { - if (token === 38 || token === 59) { + if (token === 39 || token === 61) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -2870,7 +2967,7 @@ var ts; } p++; } - while (p < end && isIdentifierPart(text.charCodeAt(p))) { + while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) { p++; } pos = p; @@ -2913,14 +3010,14 @@ var ts; break; } } - return token = 234; + return token = 236; } function scanJsxIdentifier() { - if (token === 67) { + if (tokenIsIdentifierOrKeyword(token)) { var firstCharPosition = pos; while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 || ((firstCharPosition === pos) ? isIdentifierStart(ch) : isIdentifierPart(ch))) { + if (ch === 45 || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { pos++; } else { @@ -2983,21 +3080,20 @@ var ts; } ts.createScanner = createScanner; })(ts || (ts = {})); -/// var ts; (function (ts) { ts.bindTime = 0; function getModuleInstanceState(node) { - if (node.kind === 213 || node.kind === 214) { + if (node.kind === 215 || node.kind === 216) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 220 || node.kind === 219) && !(node.flags & 1)) { + else if ((node.kind === 222 || node.kind === 221) && !(node.flags & 1)) { return 0; } - else if (node.kind === 217) { + else if (node.kind === 219) { var state = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -3013,7 +3109,7 @@ var ts; }); return state; } - else if (node.kind === 216) { + else if (node.kind === 218) { return getModuleInstanceState(node.body); } else { @@ -3032,6 +3128,7 @@ var ts; var container; var blockScopeContainer; var lastContainer; + var seenThisKeyword; var inStrictMode = !!file.externalModuleIndicator; var symbolCount = 0; var Symbol = ts.objectAllocator.getSymbolConstructor(); @@ -3065,10 +3162,10 @@ var ts; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 216 && node.name.kind === 9) { + if (node.kind === 218 && node.name.kind === 9) { return "\"" + node.name.text + "\""; } - if (node.name.kind === 134) { + if (node.name.kind === 136) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -3076,22 +3173,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 142: + case 144: return "__constructor"; - case 150: - case 145: + case 152: + case 147: return "__call"; - case 151: - case 146: + case 153: + case 148: return "__new"; - case 147: + case 149: return "__index"; - case 226: + case 228: return "__export"; - case 225: + case 227: return node.isExportEquals ? "export=" : "default"; - case 211: - case 212: + case 213: + case 214: return node.flags & 1024 ? "default" : undefined; } } @@ -3100,7 +3197,8 @@ var ts; } function declareSymbol(symbolTable, parent, node, includes, excludes) { ts.Debug.assert(!ts.hasDynamicName(node)); - var name = node.flags & 1024 && parent ? "default" : getDeclarationName(node); + var isDefaultExport = node.flags & 1024; + var name = isDefaultExport && parent ? "default" : getDeclarationName(node); var symbol; if (name !== undefined) { symbol = ts.hasProperty(symbolTable, name) @@ -3116,6 +3214,11 @@ var ts; var message = symbol.flags & 2 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; + ts.forEach(symbol.declarations, function (declaration) { + if (declaration.flags & 1024) { + message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; + } + }); ts.forEach(symbol.declarations, function (declaration) { file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); }); @@ -3133,7 +3236,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 228 || (node.kind === 219 && hasExportModifier)) { + if (node.kind === 230 || (node.kind === 221 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -3172,44 +3275,51 @@ var ts; blockScopeContainer = node; blockScopeContainer.locals = undefined; } - ts.forEachChild(node, bind); + if (node.kind === 215) { + seenThisKeyword = false; + ts.forEachChild(node, bind); + node.flags = seenThisKeyword ? node.flags | 524288 : node.flags & ~524288; + } + else { + ts.forEachChild(node, bind); + } container = saveContainer; parent = saveParent; blockScopeContainer = savedBlockScopeContainer; } function getContainerFlags(node) { switch (node.kind) { - case 184: - case 212: - case 213: + case 186: + case 214: case 215: - case 153: - case 163: + case 217: + case 155: + case 165: return 1; - case 145: - case 146: case 147: - case 141: - case 140: - case 211: - case 142: + case 148: + case 149: case 143: + case 142: + case 213: case 144: - case 150: - case 151: - case 171: - case 172: + case 145: + case 146: + case 152: + case 153: + case 173: + case 174: + case 218: + case 248: case 216: - case 246: - case 214: return 5; - case 242: - case 197: - case 198: + case 244: case 199: - case 218: + case 200: + case 201: + case 220: return 2; - case 190: + case 192: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -3225,33 +3335,33 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 216: + case 218: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 246: + case 248: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 184: - case 212: + case 186: + case 214: return declareClassMember(node, symbolFlags, symbolExcludes); - case 215: + case 217: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 153: - case 163: - case 213: + case 155: + case 165: + case 215: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 150: - case 151: - case 145: - case 146: + case 152: + case 153: case 147: - case 141: - case 140: - case 142: + case 148: + case 149: case 143: + case 142: case 144: - case 211: - case 171: - case 172: - case 214: + case 145: + case 146: + case 213: + case 173: + case 174: + case 216: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -3275,11 +3385,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 246 ? node : node.body; - if (body.kind === 246 || body.kind === 217) { + var body = node.kind === 248 ? node : node.body; + if (body.kind === 248 || body.kind === 219) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 226 || stat.kind === 225) { + if (stat.kind === 228 || stat.kind === 227) { return true; } } @@ -3334,11 +3444,11 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 67) { + if (prop.name.kind !== 69) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 243 || prop.kind === 244 || prop.kind === 141 + var currentKind = prop.kind === 245 || prop.kind === 246 || prop.kind === 143 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -3360,10 +3470,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 216: + case 218: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 246: + case 248: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -3381,8 +3491,8 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 104 && - node.originalKeywordKind <= 112 && + node.originalKeywordKind >= 106 && + node.originalKeywordKind <= 114 && !ts.isIdentifierName(node)) { if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -3409,17 +3519,17 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 67) { + if (inStrictMode && node.expression.kind === 69) { 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 === 67 && + return node.kind === 69 && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 67) { + if (name && name.kind === 69) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span = ts.getErrorSpanForNode(file, name); @@ -3453,7 +3563,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 40 || node.operator === 41) { + if (node.operator === 41 || node.operator === 42) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -3482,17 +3592,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 246: - case 217: + case 248: + case 219: updateStrictModeStatementList(node.statements); return; - case 190: + case 192: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 212: - case 184: + case 214: + case 186: inStrictMode = true; return; } @@ -3515,88 +3625,91 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 67: + case 69: return checkStrictModeIdentifier(node); - case 179: + case 181: return checkStrictModeBinaryExpression(node); - case 242: + case 244: return checkStrictModeCatchClause(node); - case 173: + case 175: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 178: + case 180: return checkStrictModePostfixUnaryExpression(node); - case 177: + case 179: return checkStrictModePrefixUnaryExpression(node); - case 203: + case 205: return checkStrictModeWithStatement(node); - case 135: + case 97: + seenThisKeyword = true; + return; + case 137: return declareSymbolAndAddToSymbolTable(node, 262144, 530912); - case 136: + case 138: return bindParameter(node); - case 209: - case 161: + case 211: + case 163: return bindVariableDeclarationOrBindingElement(node); - case 139: - case 138: + case 141: + case 140: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); - case 243: - case 244: - return bindPropertyOrMethodOrAccessor(node, 4, 107455); case 245: + case 246: + return bindPropertyOrMethodOrAccessor(node, 4, 107455); + case 247: return bindPropertyOrMethodOrAccessor(node, 8, 107455); - case 145: - case 146: case 147: + case 148: + case 149: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 141: - case 140: + case 143: + case 142: return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); - case 211: + case 213: checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16, 106927); - case 142: + case 144: return declareSymbolAndAddToSymbolTable(node, 16384, 0); - case 143: + case 145: return bindPropertyOrMethodOrAccessor(node, 32768, 41919); - case 144: + case 146: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 150: - case 151: - return bindFunctionOrConstructorType(node); + case 152: case 153: + return bindFunctionOrConstructorType(node); + case 155: return bindAnonymousDeclaration(node, 2048, "__type"); - case 163: + case 165: return bindObjectLiteralExpression(node); - case 171: - case 172: + case 173: + case 174: checkStrictModeFunctionName(node); var bindingName = node.name ? node.name.text : "__function"; return bindAnonymousDeclaration(node, 16, bindingName); - case 184: - case 212: + case 186: + case 214: return bindClassLikeDeclaration(node); - case 213: + case 215: return bindBlockScopedDeclaration(node, 64, 792960); - case 214: + case 216: return bindBlockScopedDeclaration(node, 524288, 793056); - case 215: + case 217: return bindEnumDeclaration(node); - case 216: + case 218: return bindModuleDeclaration(node); - case 219: - case 222: + case 221: case 224: - case 228: + case 226: + case 230: return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 221: + case 223: return bindImportClause(node); - case 226: + case 228: return bindExportDeclaration(node); - case 225: + case 227: return bindExportAssignment(node); - case 246: + case 248: return bindSourceFileIfExternalModule(); } } @@ -3610,7 +3723,7 @@ var ts; if (!container.symbol || !container.symbol.exports) { bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } - else if (node.expression.kind === 67) { + else if (node.expression.kind === 69) { declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); } else { @@ -3631,7 +3744,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 212) { + if (node.kind === 214) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -3684,7 +3797,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 1, 107455); } if (node.flags & 112 && - node.parent.kind === 142 && + node.parent.kind === 144 && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); @@ -3697,7 +3810,6 @@ var ts; } } })(ts || (ts = {})); -/// var ts; (function (ts) { function getDeclarationOfKind(symbol, kind) { @@ -3731,7 +3843,8 @@ var ts; increaseIndent: function () { }, decreaseIndent: function () { }, clear: function () { return str = ""; }, - trackSymbol: function () { } + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } }; } return stringWriters.pop(); @@ -3746,15 +3859,15 @@ var ts; return node.end - node.pos; } ts.getFullWidth = getFullWidth; - function arrayIsEqualTo(arr1, arr2, comparer) { - if (!arr1 || !arr2) { - return arr1 === arr2; + function arrayIsEqualTo(array1, array2, equaler) { + if (!array1 || !array2) { + return array1 === array2; } - if (arr1.length !== arr2.length) { + if (array1.length !== array2.length) { return false; } - for (var i = 0; i < arr1.length; ++i) { - var equals = comparer ? comparer(arr1[i], arr2[i]) : arr1[i] === arr2[i]; + for (var i = 0; i < array1.length; ++i) { + var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; if (!equals) { return false; } @@ -3793,7 +3906,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 246) { + while (node && node.kind !== 248) { node = node.parent; } return node; @@ -3884,15 +3997,15 @@ var ts; return current; } switch (current.kind) { - case 246: + case 248: + case 220: + case 244: case 218: - case 242: - case 216: - case 197: - case 198: case 199: + case 200: + case 201: return current; - case 190: + case 192: if (!isFunctionLike(current.parent)) { return current; } @@ -3903,9 +4016,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 209 && + declaration.kind === 211 && declaration.parent && - declaration.parent.kind === 242; + declaration.parent.kind === 244; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3941,22 +4054,22 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 246: + case 248: 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 209: - case 161: - case 212: - case 184: - case 213: - case 216: - case 215: - case 245: case 211: - case 171: + case 163: + case 214: + case 186: + case 215: + case 218: + case 217: + case 247: + case 213: + case 173: errorNode = node.name; break; } @@ -3978,11 +4091,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 215 && isConst(node); + return node.kind === 217 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 161 || isBindingPattern(node))) { + while (node && (node.kind === 163 || isBindingPattern(node))) { node = node.parent; } return node; @@ -3990,14 +4103,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 209) { + if (node.kind === 211) { node = node.parent; } - if (node && node.kind === 210) { + if (node && node.kind === 212) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 191) { + if (node && node.kind === 193) { flags |= node.flags; } return flags; @@ -4012,7 +4125,7 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 193 && node.expression.kind === 9; + return node.kind === 195 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -4020,7 +4133,7 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - var commentRanges = (node.kind === 136 || node.kind === 135) ? + var commentRanges = (node.kind === 138 || node.kind === 137) ? ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : getLeadingCommentRangesOfNode(node, sourceFileOfNode); return ts.filter(commentRanges, isJsDocComment); @@ -4032,69 +4145,71 @@ var ts; } ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (149 <= node.kind && node.kind <= 158) { + if (151 <= node.kind && node.kind <= 160) { return true; } switch (node.kind) { - case 115: - case 126: + case 117: case 128: - case 118: - case 129: + case 130: + case 120: + case 131: return true; - case 101: - return node.parent.kind !== 175; + case 103: + return node.parent.kind !== 177; case 9: - return node.parent.kind === 136; - case 186: + return node.parent.kind === 138; + case 188: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 67: - if (node.parent.kind === 133 && node.parent.right === node) { + case 69: + if (node.parent.kind === 135 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 164 && node.parent.name === node) { + else if (node.parent.kind === 166 && node.parent.name === node) { node = node.parent; } - case 133: - case 164: - ts.Debug.assert(node.kind === 67 || node.kind === 133 || node.kind === 164, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + ts.Debug.assert(node.kind === 69 || node.kind === 135 || node.kind === 166, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 135: + case 166: + case 97: var parent_1 = node.parent; - if (parent_1.kind === 152) { + if (parent_1.kind === 154) { return false; } - if (149 <= parent_1.kind && parent_1.kind <= 158) { + if (151 <= parent_1.kind && parent_1.kind <= 160) { return true; } switch (parent_1.kind) { - case 186: + case 188: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 135: + case 137: return node === parent_1.constraint; - case 139: - case 138: - case 136: - case 209: - return node === parent_1.type; - case 211: - case 171: - case 172: - case 142: case 141: case 140: - case 143: - case 144: + case 138: + case 211: return node === parent_1.type; + case 213: + case 173: + case 174: + case 144: + case 143: + case 142: case 145: case 146: + return node === parent_1.type; case 147: + case 148: + case 149: return node === parent_1.type; - case 169: + case 171: return node === parent_1.type; - case 166: - case 167: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 168: + case 169: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 170: return false; } } @@ -4105,23 +4220,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 202: + case 204: return visitor(node); - case 218: - case 190: - case 194: - case 195: + case 220: + case 192: case 196: case 197: case 198: case 199: - case 203: - case 204: - case 239: - case 240: + case 200: + case 201: case 205: - case 207: + case 206: + case 241: case 242: + case 207: + case 209: + case 244: return ts.forEachChild(node, traverse); } } @@ -4131,23 +4246,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 182: + case 184: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } + case 217: case 215: - case 213: + case 218: case 216: case 214: - case 212: - case 184: + case 186: return; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 134) { + if (name_5 && name_5.kind === 136) { traverse(name_5.expression); return; } @@ -4162,14 +4277,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 161: - case 245: - case 136: - case 243: - case 139: + case 163: + case 247: case 138: - case 244: - case 209: + case 245: + case 141: + case 140: + case 246: + case 211: return true; } } @@ -4177,29 +4292,29 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 143 || node.kind === 144); + return node && (node.kind === 145 || node.kind === 146); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 212 || node.kind === 184); + return node && (node.kind === 214 || node.kind === 186); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 142: - case 171: - case 211: - case 172: - case 141: - case 140: - case 143: case 144: + case 173: + case 213: + case 174: + case 143: + case 142: case 145: case 146: case 147: - case 150: - case 151: + case 148: + case 149: + case 152: + case 153: return true; } } @@ -4208,24 +4323,24 @@ var ts; ts.isFunctionLike = isFunctionLike; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 141: - case 140: - case 142: case 143: + case 142: case 144: - case 211: - case 171: + case 145: + case 146: + case 213: + case 173: return true; } return false; } ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isFunctionBlock(node) { - return node && node.kind === 190 && isFunctionLike(node.parent); + return node && node.kind === 192 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 141 && node.parent.kind === 163; + return node && node.kind === 143 && node.parent.kind === 165; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -4253,36 +4368,39 @@ var ts; return undefined; } switch (node.kind) { - case 134: + case 136: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 137: - if (node.parent.kind === 136 && isClassElement(node.parent.parent)) { + case 139: + if (node.parent.kind === 138 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 172: + case 174: if (!includeArrowFunctions) { continue; } - case 211: - case 171: - case 216: - case 139: - case 138: + case 213: + case 173: + case 218: case 141: case 140: - case 142: case 143: + case 142: case 144: - case 215: - case 246: + case 145: + case 146: + case 147: + case 148: + case 149: + case 217: + case 248: return node; } } @@ -4294,33 +4412,33 @@ var ts; if (!node) return node; switch (node.kind) { - case 134: + case 136: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 137: - if (node.parent.kind === 136 && isClassElement(node.parent.parent)) { + case 139: + if (node.parent.kind === 138 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 211: - case 171: - case 172: + case 213: + case 173: + case 174: if (!includeFunctions) { continue; } - case 139: - case 138: case 141: case 140: - case 142: case 143: + case 142: case 144: + case 145: + case 146: return node; } } @@ -4329,12 +4447,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 149: + case 151: return node.typeName; - case 186: + case 188: return node.expression; - case 67: - case 133: + case 69: + case 135: return node; } } @@ -4342,7 +4460,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 168) { + if (node.kind === 170) { return node.tag; } return node.expression; @@ -4350,40 +4468,40 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 212: + case 214: return true; - case 139: - return node.parent.kind === 212; - case 136: - return node.parent.body && node.parent.parent.kind === 212; - case 143: - case 144: case 141: - return node.body && node.parent.kind === 212; + return node.parent.kind === 214; + case 138: + return node.parent.body && node.parent.parent.kind === 214; + case 145: + case 146: + case 143: + return node.body && node.parent.kind === 214; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 212: + case 214: if (node.decorators) { return true; } return false; - case 139: - case 136: + case 141: + case 138: if (node.decorators) { return true; } return false; - case 143: + case 145: if (node.body && node.decorators) { return true; } return false; - case 141: - case 144: + case 143: + case 146: if (node.body && node.decorators) { return true; } @@ -4394,10 +4512,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 212: + case 214: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 141: - case 144: + case 143: + case 146: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -4407,95 +4525,105 @@ var ts; return nodeIsDecorated(node) || childIsDecorated(node); } ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; + function isPropertyAccessExpression(node) { + return node.kind === 166; + } + ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isElementAccessExpression(node) { + return node.kind === 167; + } + ts.isElementAccessExpression = isElementAccessExpression; function isExpression(node) { switch (node.kind) { case 95: case 93: - case 91: - case 97: - case 82: + case 99: + case 84: case 10: - case 162: - case 163: case 164: case 165: case 166: case 167: case 168: - case 187: case 169: case 170: + case 189: case 171: - case 184: case 172: - case 175: case 173: + case 186: case 174: case 177: - case 178: + case 175: + case 176: case 179: case 180: - case 183: case 181: - case 11: - case 185: - case 231: - case 232: case 182: - return true; - case 133: - while (node.parent.kind === 133) { - node = node.parent; - } - return node.parent.kind === 152; - case 67: - if (node.parent.kind === 152) { - return true; - } + case 185: + case 183: + case 11: + case 187: + case 233: + case 234: + case 184: + case 178: + return true; + case 135: + while (node.parent.kind === 135) { + node = node.parent; + } + return node.parent.kind === 154; + case 69: + if (node.parent.kind === 154) { + return true; + } case 8: case 9: + case 97: var parent_2 = node.parent; switch (parent_2.kind) { - case 209: - case 136: - case 139: + case 211: case 138: + case 141: + case 140: + case 247: case 245: - case 243: - case 161: + case 163: return parent_2.initializer === node; - case 193: - case 194: case 195: case 196: - case 202: - case 203: + case 197: + case 198: case 204: - case 239: + case 205: + case 206: + case 241: + case 208: case 206: - case 204: return parent_2.expression === node; - case 197: + case 199: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 210) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 212) || forStatement.condition === node || forStatement.incrementor === node; - case 198: - case 199: + case 200: + case 201: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 210) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 212) || forInStatement.expression === node; - case 169: - case 187: + case 171: + case 189: return node === parent_2.expression; - case 188: + case 190: return node === parent_2.expression; - case 134: + case 136: return node === parent_2.expression; - case 137: - case 238: + case 139: + case 240: + case 239: return true; - case 186: + case 188: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -4506,6 +4634,10 @@ var ts; return false; } ts.isExpression = isExpression; + function isExternalModuleNameRelative(moduleName) { + return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; + } + ts.isExternalModuleNameRelative = isExternalModuleNameRelative; function isInstantiatedModule(node, preserveConstEnums) { var moduleState = ts.getModuleInstanceState(node); return moduleState === 1 || @@ -4513,7 +4645,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 219 && node.moduleReference.kind === 230; + return node.kind === 221 && node.moduleReference.kind === 232; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -4522,20 +4654,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 219 && node.moduleReference.kind !== 230; + return node.kind === 221 && node.moduleReference.kind !== 232; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 220) { + if (node.kind === 222) { return node.moduleSpecifier; } - if (node.kind === 219) { + if (node.kind === 221) { var reference = node.moduleReference; - if (reference.kind === 230) { + if (reference.kind === 232) { return reference.expression; } } - if (node.kind === 226) { + if (node.kind === 228) { return node.moduleSpecifier; } } @@ -4543,13 +4675,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 136: + case 138: + case 143: + case 142: + case 246: + case 245: case 141: case 140: - case 244: - case 243: - case 139: - case 138: return node.questionToken !== undefined; } } @@ -4557,9 +4689,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 259 && + return node.kind === 261 && node.parameters.length > 0 && - node.parameters[0].type.kind === 261; + node.parameters[0].type.kind === 263; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -4573,24 +4705,24 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 267); + return getJSDocTag(node, 269); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 266); + return getJSDocTag(node, 268); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 268); + return getJSDocTag(node, 270); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 67) { + if (parameter.name && parameter.name.kind === 69) { var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 265) { + if (t.kind === 267) { var parameterTag = t; var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_6.text === parameterName) { @@ -4609,12 +4741,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32) { - if (node.type && node.type.kind === 260) { + if (node.type && node.type.kind === 262) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 260; + return paramTag.typeExpression.type.kind === 262; } } return node.dotDotDotToken !== undefined; @@ -4635,7 +4767,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 160 || node.kind === 159); + return !!node && (node.kind === 162 || node.kind === 161); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -4650,34 +4782,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 172: - case 161: - case 212: - case 184: - case 142: + case 174: + case 163: + case 214: + case 186: + case 144: + case 217: + case 247: + case 230: + case 213: + case 173: + case 145: + case 223: + case 221: + case 226: case 215: - case 245: - case 228: - case 211: - case 171: case 143: - case 221: - case 219: + case 142: + case 218: case 224: - case 213: + case 138: + case 245: case 141: case 140: + case 146: + case 246: case 216: - case 222: - case 136: - case 243: - case 139: - case 138: - case 144: - case 244: - case 214: - case 135: - case 209: + case 137: + case 211: return true; } return false; @@ -4685,25 +4817,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 201: - case 200: - case 208: + case 203: + case 202: + case 210: + case 197: case 195: + case 194: + case 200: + case 201: + case 199: + case 196: + case 207: + case 204: + case 206: + case 98: + case 209: case 193: - case 192: case 198: - case 199: - case 197: - case 194: case 205: - case 202: - case 204: - case 96: - case 207: - case 191: - case 196: - case 203: - case 225: + case 227: return true; default: return false; @@ -4712,13 +4844,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 142: - case 139: + case 144: case 141: case 143: - case 144: - case 140: - case 147: + case 145: + case 146: + case 142: + case 149: return true; default: return false; @@ -4726,11 +4858,11 @@ var ts; } ts.isClassElement = isClassElement; function isDeclarationName(name) { - if (name.kind !== 67 && name.kind !== 9 && name.kind !== 8) { + if (name.kind !== 69 && name.kind !== 9 && name.kind !== 8) { return false; } var parent = name.parent; - if (parent.kind === 224 || parent.kind === 228) { + if (parent.kind === 226 || parent.kind === 230) { if (parent.propertyName) { return true; } @@ -4744,54 +4876,54 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 139: - case 138: case 141: case 140: case 143: - case 144: + case 142: + case 145: + case 146: + case 247: case 245: - case 243: - case 164: + case 166: return parent.name === node; - case 133: + case 135: if (parent.right === node) { - while (parent.kind === 133) { + while (parent.kind === 135) { parent = parent.parent; } - return parent.kind === 152; + return parent.kind === 154; } return false; - case 161: - case 224: + case 163: + case 226: return parent.propertyName === node; - case 228: + case 230: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 219 || - node.kind === 221 && !!node.name || - node.kind === 222 || + return node.kind === 221 || + node.kind === 223 && !!node.name || node.kind === 224 || - node.kind === 228 || - node.kind === 225 && node.expression.kind === 67; + node.kind === 226 || + node.kind === 230 || + node.kind === 227 && node.expression.kind === 69; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 81); + var heritageClause = getHeritageClause(node.heritageClauses, 83); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 104); + var heritageClause = getHeritageClause(node.heritageClauses, 106); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 81); + var heritageClause = getHeritageClause(node.heritageClauses, 83); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -4860,7 +4992,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 68 <= token && token <= 132; + return 70 <= token && token <= 134; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -4873,19 +5005,19 @@ var ts; ts.isAsyncFunctionLike = isAsyncFunctionLike; function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 134 && + declaration.name.kind === 136 && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; function isWellKnownSymbolSyntactically(node) { - return node.kind === 164 && isESSymbolIdentifier(node.expression); + return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 67 || name.kind === 9 || name.kind === 8) { + if (name.kind === 69 || name.kind === 9 || name.kind === 8) { return name.text; } - if (name.kind === 134) { + if (name.kind === 136) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -4900,21 +5032,21 @@ var ts; } ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function isESSymbolIdentifier(node) { - return node.kind === 67 && node.text === "Symbol"; + return node.kind === 69 && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 113: - case 116: - case 72: - case 120: - case 75: - case 80: + case 115: + case 118: + case 74: + case 122: + case 77: + case 82: + case 112: case 110: - case 108: - case 109: case 111: + case 113: return true; } return false; @@ -4922,28 +5054,28 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 136; + return root.kind === 138; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 161) { + while (node.kind === 163) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 216 || n.kind === 246; + return isFunctionLike(n) || n.kind === 218 || n.kind === 248; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function cloneEntityName(node) { - if (node.kind === 67) { - var clone_1 = createSynthesizedNode(67); + if (node.kind === 69) { + var clone_1 = createSynthesizedNode(69); clone_1.text = node.text; return clone_1; } else { - var clone_2 = createSynthesizedNode(133); + var clone_2 = createSynthesizedNode(135); clone_2.left = cloneEntityName(node.left); clone_2.left.parent = clone_2; clone_2.right = cloneEntityName(node.right); @@ -5186,7 +5318,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 142 && nodeIsPresent(member.body)) { + if (member.kind === 144 && nodeIsPresent(member.body)) { return member; } }); @@ -5213,10 +5345,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 143) { + if (accessor.kind === 145) { getAccessor = accessor; } - else if (accessor.kind === 144) { + else if (accessor.kind === 146) { setAccessor = accessor; } else { @@ -5225,7 +5357,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 143 || member.kind === 144) + if ((member.kind === 145 || member.kind === 146) && (member.flags & 128) === (accessor.flags & 128)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -5236,10 +5368,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 143 && !getAccessor) { + if (member.kind === 145 && !getAccessor) { getAccessor = member; } - if (member.kind === 144 && !setAccessor) { + if (member.kind === 146 && !setAccessor) { setAccessor = member; } } @@ -5345,16 +5477,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 111: return 128; - case 110: return 16; - case 109: return 64; - case 108: return 32; - case 113: return 256; - case 80: return 1; - case 120: return 2; - case 72: return 32768; - case 75: return 1024; - case 116: return 512; + case 113: return 128; + case 112: return 16; + case 111: return 64; + case 110: return 32; + case 115: return 256; + case 82: return 1; + case 122: return 2; + case 74: return 32768; + case 77: return 1024; + case 118: return 512; } return 0; } @@ -5362,29 +5494,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 164: - case 165: - case 167: case 166: - case 231: - case 232: + case 167: + case 169: case 168: - case 162: + case 233: + case 234: case 170: - case 163: - case 184: - case 171: - case 67: + case 164: + case 172: + case 165: + case 186: + case 173: + case 69: case 10: case 8: case 9: case 11: - case 181: - case 82: - case 91: - case 95: - case 97: + case 183: + case 84: case 93: + case 97: + case 99: + case 95: return true; } } @@ -5392,12 +5524,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 55 && token <= 66; + return token >= 56 && token <= 68; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 186 && - node.parent.token === 81 && + return node.kind === 188 && + node.parent.token === 83 && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -5406,10 +5538,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 67) { + if (node.kind === 69) { return true; } - else if (node.kind === 164) { + else if (isPropertyAccessExpression(node)) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -5417,16 +5549,16 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 133 && node.parent.right === node) || - (node.parent.kind === 164 && node.parent.name === node); + return (node.parent.kind === 135 && node.parent.right === node) || + (node.parent.kind === 166 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 163) { + if (kind === 165) { return expression.properties.length === 0; } - if (kind === 162) { + if (kind === 164) { return expression.elements.length === 0; } return false; @@ -5635,9 +5767,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 135) { + if (d && d.kind === 137) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 213) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 215) { return current; } } @@ -5645,11 +5777,9 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; })(ts || (ts = {})); -/// -/// var ts; (function (ts) { - var nodeConstructors = new Array(270); + var nodeConstructors = new Array(272); ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -5687,20 +5817,26 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 133: + case 135: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 135: + case 137: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 136: - case 139: + case 246: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.equalsToken) || + visitNode(cbNode, node.objectAssignmentInitializer); case 138: - case 243: - case 244: - case 209: - case 161: + case 141: + case 140: + case 245: + case 211: + case 163: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -5709,24 +5845,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 150: - case 151: - case 145: - case 146: + case 152: + case 153: case 147: + case 148: + case 149: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 141: - case 140: - case 142: case 143: + case 142: case 144: - case 171: - case 211: - case 172: + case 145: + case 146: + case 173: + case 213: + case 174: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -5737,290 +5873,290 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 149: + case 151: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 148: + case 150: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 152: - return visitNode(cbNode, node.exprName); - case 153: - return visitNodes(cbNodes, node.members); case 154: - return visitNode(cbNode, node.elementType); + return visitNode(cbNode, node.exprName); case 155: - return visitNodes(cbNodes, node.elementTypes); + return visitNodes(cbNodes, node.members); case 156: + return visitNode(cbNode, node.elementType); case 157: - return visitNodes(cbNodes, node.types); + return visitNodes(cbNodes, node.elementTypes); case 158: - return visitNode(cbNode, node.type); case 159: + return visitNodes(cbNodes, node.types); case 160: + return visitNode(cbNode, node.type); + case 161: + case 162: return visitNodes(cbNodes, node.elements); - case 162: - return visitNodes(cbNodes, node.elements); - case 163: - return visitNodes(cbNodes, node.properties); case 164: + return visitNodes(cbNodes, node.elements); + case 165: + return visitNodes(cbNodes, node.properties); + case 166: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 165: + case 167: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 166: - case 167: + case 168: + case 169: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 168: + case 170: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 169: + case 171: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 170: - return visitNode(cbNode, node.expression); - case 173: - return visitNode(cbNode, node.expression); - case 174: + case 172: return visitNode(cbNode, node.expression); case 175: return visitNode(cbNode, node.expression); + case 176: + return visitNode(cbNode, node.expression); case 177: + return visitNode(cbNode, node.expression); + case 179: return visitNode(cbNode, node.operand); - case 182: + case 184: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 176: - return visitNode(cbNode, node.expression); case 178: + return visitNode(cbNode, node.expression); + case 180: return visitNode(cbNode, node.operand); - case 179: + case 181: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 187: + case 189: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 180: + case 182: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 183: + case 185: return visitNode(cbNode, node.expression); - case 190: - case 217: + case 192: + case 219: return visitNodes(cbNodes, node.statements); - case 246: + case 248: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 191: + case 193: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 210: + case 212: return visitNodes(cbNodes, node.declarations); - case 193: + case 195: return visitNode(cbNode, node.expression); - case 194: + case 196: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 195: + case 197: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 196: + case 198: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 197: + case 199: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 198: + case 200: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 199: + case 201: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 200: - case 201: - return visitNode(cbNode, node.label); case 202: - return visitNode(cbNode, node.expression); case 203: + return visitNode(cbNode, node.label); + case 204: + return visitNode(cbNode, node.expression); + case 205: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 204: + case 206: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 218: + case 220: return visitNodes(cbNodes, node.clauses); - case 239: + case 241: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 240: + case 242: return visitNodes(cbNodes, node.statements); - case 205: + case 207: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 206: + case 208: return visitNode(cbNode, node.expression); - case 207: + case 209: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 242: + case 244: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 137: + case 139: return visitNode(cbNode, node.expression); - case 212: - case 184: + case 214: + case 186: 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 213: + case 215: 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 214: + case 216: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 215: + case 217: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 245: + case 247: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 216: + case 218: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 219: + case 221: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 220: + case 222: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 221: + case 223: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 222: + case 224: return visitNode(cbNode, node.name); - case 223: - case 227: + case 225: + case 229: return visitNodes(cbNodes, node.elements); - case 226: + case 228: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 224: - case 228: + case 226: + case 230: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 225: + case 227: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 181: + case 183: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 188: + case 190: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 134: + case 136: return visitNode(cbNode, node.expression); - case 241: + case 243: return visitNodes(cbNodes, node.types); - case 186: + case 188: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 230: + case 232: return visitNode(cbNode, node.expression); - case 229: - return visitNodes(cbNodes, node.decorators); case 231: + return visitNodes(cbNodes, node.decorators); + case 233: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 232: - case 233: + case 234: + case 235: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 236: + case 238: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 237: + case 239: return visitNode(cbNode, node.expression); - case 238: + case 240: return visitNode(cbNode, node.expression); - case 235: + case 237: return visitNode(cbNode, node.tagName); - case 247: + case 249: return visitNode(cbNode, node.type); - case 251: + case 253: return visitNodes(cbNodes, node.types); - case 252: + case 254: return visitNodes(cbNodes, node.types); - case 250: + case 252: return visitNode(cbNode, node.elementType); - case 254: - return visitNode(cbNode, node.type); - case 253: + case 256: return visitNode(cbNode, node.type); case 255: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.type); case 257: + return visitNodes(cbNodes, node.members); + case 259: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 258: + case 260: return visitNode(cbNode, node.type); - case 259: + case 261: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 260: + case 262: return visitNode(cbNode, node.type); - case 261: + case 263: return visitNode(cbNode, node.type); - case 262: + case 264: return visitNode(cbNode, node.type); - case 256: + case 258: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 263: - return visitNodes(cbNodes, node.tags); case 265: + return visitNodes(cbNodes, node.tags); + case 267: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 266: + case 268: return visitNode(cbNode, node.typeExpression); - case 267: + case 269: return visitNode(cbNode, node.typeExpression); - case 268: + case 270: return visitNodes(cbNodes, node.typeParameters); } } @@ -6116,9 +6252,9 @@ var ts; return; function visit(node) { switch (node.kind) { - case 191: - case 211: - case 136: + case 193: + case 213: + case 138: addJSDocComment(node); } forEachChild(node, visit); @@ -6137,10 +6273,6 @@ var ts; } } function fixupParentReferences(sourceFile) { - // normally parent references are set during binding. However, for clients that only need - // a syntax tree, and no semantic features, then the binding process is an unnecessary - // overhead. This functions allows us to set all the parents, without all the expense of - // binding. var parent = sourceFile; forEachChild(sourceFile, visitNode); return; @@ -6156,7 +6288,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(246, 0); + var sourceFile = createNode(248, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -6315,16 +6447,16 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token === 67) { + if (token === 69) { return true; } - if (token === 112 && inYieldContext()) { + if (token === 114 && inYieldContext()) { return false; } - if (token === 117 && inAwaitContext()) { + if (token === 119 && inAwaitContext()) { return false; } - return token > 103; + return token > 105; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -6420,24 +6552,24 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(67); - if (token !== 67) { + var node = createNode(69); + if (token !== 69) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(67, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(69, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); } function parseIdentifierName() { - return createIdentifier(isIdentifierOrKeyword()); + return createIdentifier(ts.tokenIsIdentifierOrKeyword(token)); } function isLiteralPropertyName() { - return isIdentifierOrKeyword() || + return ts.tokenIsIdentifierOrKeyword(token) || token === 9 || token === 8; } @@ -6457,10 +6589,10 @@ var ts; return parsePropertyNameWorker(false); } function isSimplePropertyName() { - return token === 9 || token === 8 || isIdentifierOrKeyword(); + return token === 9 || token === 8 || ts.tokenIsIdentifierOrKeyword(token); } function parseComputedPropertyName() { - var node = createNode(134); + var node = createNode(136); parseExpected(19); node.expression = allowInAnd(parseExpression); parseExpected(20); @@ -6470,20 +6602,27 @@ var ts; return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 72) { - return nextToken() === 79; + if (token === 74) { + return nextToken() === 81; } - if (token === 80) { + if (token === 82) { nextToken(); - if (token === 75) { + if (token === 77) { return lookAhead(nextTokenIsClassOrFunction); } return token !== 37 && token !== 15 && canFollowModifier(); } - if (token === 75) { + if (token === 77) { return nextTokenIsClassOrFunction(); } + if (token === 113) { + nextToken(); + return canFollowModifier(); + } nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return false; + } return canFollowModifier(); } function parseAnyContextualModifier() { @@ -6497,7 +6636,7 @@ var ts; } function nextTokenIsClassOrFunction() { nextToken(); - return token === 71 || token === 85; + return token === 73 || token === 87; } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -6510,7 +6649,7 @@ var ts; case 3: return !(token === 23 && inErrorRecovery) && isStartOfStatement(); case 2: - return token === 69 || token === 75; + return token === 71 || token === 77; case 4: return isStartOfTypeMember(); case 5: @@ -6548,9 +6687,9 @@ var ts; case 20: return isHeritageClause(); case 21: - return isIdentifierOrKeyword(); + return ts.tokenIsIdentifierOrKeyword(token); case 13: - return isIdentifierOrKeyword() || token === 15; + return ts.tokenIsIdentifierOrKeyword(token) || token === 15; case 14: return true; case 22: @@ -6566,7 +6705,7 @@ var ts; ts.Debug.assert(token === 15); if (nextToken() === 16) { var next = nextToken(); - return next === 24 || next === 15 || next === 81 || next === 104; + return next === 24 || next === 15 || next === 83 || next === 106; } return true; } @@ -6576,11 +6715,11 @@ var ts; } function nextTokenIsIdentifierOrKeyword() { nextToken(); - return isIdentifierOrKeyword(); + return ts.tokenIsIdentifierOrKeyword(token); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 104 || - token === 81) { + if (token === 106 || + token === 83) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -6604,13 +6743,13 @@ var ts; case 21: return token === 16; case 3: - return token === 16 || token === 69 || token === 75; + return token === 16 || token === 71 || token === 77; case 7: - return token === 15 || token === 81 || token === 104; + return token === 15 || token === 83 || token === 106; case 8: return isVariableDeclaratorListTerminator(); case 17: - return token === 27 || token === 17 || token === 15 || token === 81 || token === 104; + return token === 27 || token === 17 || token === 15 || token === 83 || token === 106; case 11: return token === 18 || token === 23; case 15: @@ -6624,11 +6763,11 @@ var ts; case 20: return token === 15 || token === 16; case 13: - return token === 27 || token === 38; + return token === 27 || token === 39; case 14: return token === 25 && lookAhead(nextTokenIsSlash); case 22: - return token === 18 || token === 53 || token === 16; + return token === 18 || token === 54 || token === 16; case 23: return token === 27 || token === 16; case 25: @@ -6749,17 +6888,17 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 142: - case 147: - case 143: case 144: - case 139: - case 189: - return true; + case 149: + case 145: + case 146: case 141: + case 191: + return true; + case 143: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 67 && - methodDeclaration.name.originalKeywordKind === 119; + var nameIsConstructor = methodDeclaration.name.kind === 69 && + methodDeclaration.name.originalKeywordKind === 121; return !nameIsConstructor; } } @@ -6768,8 +6907,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 239: - case 240: + case 241: + case 242: return true; } } @@ -6778,65 +6917,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 211: - case 191: - case 190: - case 194: + case 213: case 193: + case 192: + case 196: + case 195: + case 208: + case 204: case 206: + case 203: case 202: - case 204: - case 201: case 200: - case 198: + case 201: case 199: - case 197: - case 196: - case 203: - case 192: - case 207: + case 198: case 205: - case 195: - case 208: - case 220: - case 219: - case 226: - case 225: - case 216: - case 212: - case 213: - case 215: + case 194: + case 209: + case 207: + case 197: + case 210: + case 222: + case 221: + case 228: + case 227: + case 218: case 214: + case 215: + case 217: + case 216: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 245; + return node.kind === 247; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 146: + case 148: + case 142: + case 149: case 140: case 147: - case 138: - case 145: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 209) { + if (node.kind !== 211) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 136) { + if (node.kind !== 138) { return false; } var parameter = node; @@ -6936,7 +7075,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(21)) { - var node = createNode(133, entity.pos); + var node = createNode(135, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -6944,16 +7083,16 @@ var ts; return entity; } function parseRightSideOfDot(allowIdentifierNames) { - if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) { + if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(67, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(69, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(181); + var template = createNode(183); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); var templateSpans = []; @@ -6966,7 +7105,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(188); + var span = createNode(190); span.expression = allowInAnd(parseExpression); var literal; if (token === 16) { @@ -7001,14 +7140,14 @@ var ts; } function parseTypeReferenceOrTypePredicate() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 67 && token === 122 && !scanner.hasPrecedingLineBreak()) { + if (typeName.kind === 69 && token === 124 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(148, typeName.pos); + var node_1 = createNode(150, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(149, typeName.pos); + var node = createNode(151, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 25) { node.typeArguments = parseBracketedList(18, parseType, 25, 27); @@ -7016,15 +7155,15 @@ var ts; return finishNode(node); } function parseTypeQuery() { - var node = createNode(152); - parseExpected(99); + var node = createNode(154); + parseExpected(101); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(135); + var node = createNode(137); node.name = parseIdentifier(); - if (parseOptional(81)) { + if (parseOptional(83)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -7040,7 +7179,7 @@ var ts; } } function parseParameterType() { - if (parseOptional(53)) { + if (parseOptional(54)) { return token === 9 ? parseLiteralNode(true) : parseType(); @@ -7048,7 +7187,7 @@ var ts; return undefined; } function isStartOfParameter() { - return token === 22 || isIdentifierOrPattern() || ts.isModifier(token) || token === 54; + return token === 22 || isIdentifierOrPattern() || ts.isModifier(token) || token === 55; } function setModifiers(node, modifiers) { if (modifiers) { @@ -7057,7 +7196,7 @@ var ts; } } function parseParameter() { - var node = createNode(136); + var node = createNode(138); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(22); @@ -7065,7 +7204,7 @@ var ts; if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { nextToken(); } - node.questionToken = parseOptionalToken(52); + node.questionToken = parseOptionalToken(53); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(true); return finishNode(node); @@ -7112,10 +7251,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 146) { - parseExpected(90); + if (kind === 148) { + parseExpected(92); } - fillSignature(53, false, false, false, node); + fillSignature(54, false, false, false, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -7142,17 +7281,17 @@ var ts; else { nextToken(); } - if (token === 53 || token === 24) { + if (token === 54 || token === 24) { return true; } - if (token !== 52) { + if (token !== 53) { return false; } nextToken(); - return token === 53 || token === 24 || token === 20; + return token === 54 || token === 24 || token === 20; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(147, fullStart); + var node = createNode(149, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(16, parseParameter, 19, 20); @@ -7163,17 +7302,17 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(52); + var questionToken = parseOptionalToken(53); if (token === 17 || token === 25) { - var method = createNode(140, fullStart); + var method = createNode(142, fullStart); method.name = name; method.questionToken = questionToken; - fillSignature(53, false, false, false, method); + fillSignature(54, false, false, false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(138, fullStart); + var property = createNode(140, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -7207,22 +7346,22 @@ var ts; nextToken(); return token === 17 || token === 25 || - token === 52 || token === 53 || + token === 54 || canParseSemicolon(); } function parseTypeMember() { switch (token) { case 17: case 25: - return parseSignatureMember(145); + return parseSignatureMember(147); case 19: return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); - case 90: + case 92: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(146); + return parseSignatureMember(148); } case 9: case 8: @@ -7234,7 +7373,7 @@ var ts; return result; } } - if (isIdentifierOrKeyword()) { + if (ts.tokenIsIdentifierOrKeyword(token)) { return parsePropertyOrMethodSignature(); } } @@ -7252,7 +7391,7 @@ var ts; return token === 17 || token === 25; } function parseTypeLiteral() { - var node = createNode(153); + var node = createNode(155); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -7268,12 +7407,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(155); + var node = createNode(157); node.elementTypes = parseBracketedList(19, parseType, 19, 20); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(158); + var node = createNode(160); parseExpected(17); node.type = parseType(); parseExpected(18); @@ -7281,8 +7420,8 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 151) { - parseExpected(90); + if (kind === 153) { + parseExpected(92); } fillSignature(34, false, false, false, node); return finishNode(node); @@ -7293,16 +7432,17 @@ var ts; } function parseNonArrayType() { switch (token) { - case 115: + case 117: + case 130: case 128: - case 126: - case 118: - case 129: + case 120: + case 131: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 101: + case 103: + case 97: return parseTokenNode(); - case 99: + case 101: return parseTypeQuery(); case 15: return parseTypeLiteral(); @@ -7316,17 +7456,18 @@ var ts; } function isStartOfType() { switch (token) { - case 115: + case 117: + case 130: case 128: - case 126: - case 118: - case 129: + case 120: + case 131: + case 103: + case 97: case 101: - case 99: case 15: case 19: case 25: - case 90: + case 92: return true; case 17: return lookAhead(isStartOfParenthesizedOrFunctionType); @@ -7342,7 +7483,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { parseExpected(20); - var node = createNode(154, type.pos); + var node = createNode(156, type.pos); node.elementType = type; type = finishNode(node); } @@ -7364,10 +7505,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(157, parseArrayTypeOrHigher, 45); + return parseUnionOrIntersectionType(159, parseArrayTypeOrHigher, 46); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(156, parseIntersectionTypeOrHigher, 46); + return parseUnionOrIntersectionType(158, parseIntersectionTypeOrHigher, 47); } function isStartOfFunctionType() { if (token === 25) { @@ -7382,8 +7523,8 @@ var ts; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 53 || token === 24 || - token === 52 || token === 55 || + if (token === 54 || token === 24 || + token === 53 || token === 56 || isIdentifier() || ts.isModifier(token)) { return true; } @@ -7401,23 +7542,23 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(150); + return parseFunctionOrConstructorType(152); } - if (token === 90) { - return parseFunctionOrConstructorType(151); + if (token === 92) { + return parseFunctionOrConstructorType(153); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(53) ? parseType() : undefined; + return parseOptional(54) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token) { + case 97: case 95: case 93: - case 91: - case 97: - case 82: + case 99: + case 84: case 8: case 9: case 11: @@ -7425,12 +7566,12 @@ var ts; case 17: case 19: case 15: - case 85: - case 71: - case 90: - case 38: - case 59: - case 67: + case 87: + case 73: + case 92: + case 39: + case 61: + case 69: return true; default: return isIdentifier(); @@ -7443,16 +7584,16 @@ var ts; switch (token) { case 35: case 36: + case 50: case 49: - case 48: - case 76: - case 99: + case 78: case 101: - case 40: + case 103: case 41: + case 42: case 25: - case 117: - case 112: + case 119: + case 114: return true; default: if (isBinaryOperator()) { @@ -7463,18 +7604,15 @@ var ts; } function isStartOfExpressionStatement() { return token !== 15 && - token !== 85 && - token !== 71 && - token !== 54 && + token !== 87 && + token !== 73 && + token !== 55 && isStartOfExpression(); } function allowInAndParseExpression() { return allowInAnd(parseExpression); } function parseExpression() { - // Expression[in]: - // AssignmentExpression[in] - // Expression[in] , AssignmentExpression[in] var saveDecoratorContext = inDecoratorContext(); if (saveDecoratorContext) { setDecoratorContext(false); @@ -7490,24 +7628,15 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 55) { + if (token !== 56) { if (scanner.hasPrecedingLineBreak() || (inParameter && token === 15) || !isStartOfExpression()) { return undefined; } } - parseExpected(55); + parseExpected(56); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { - // AssignmentExpression[in,yield]: - // 1) ConditionalExpression[?in,?yield] - // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield] - // 3) LeftHandSideExpression AssignmentOperator AssignmentExpression[?in,?yield] - // 4) ArrowFunctionExpression[?in,?yield] - // 5) [+Yield] YieldExpression[?In] - // - // Note: for ease of implementation we treat productions '2' and '3' as the same thing. - // (i.e. they're both BinaryExpressions with an assignment operator in it). if (isYieldExpression()) { return parseYieldExpression(); } @@ -7516,7 +7645,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 67 && token === 34) { + if (expr.kind === 69 && token === 34) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -7525,7 +7654,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 112) { + if (token === 114) { if (inYieldContext()) { return true; } @@ -7538,7 +7667,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(182); + var node = createNode(184); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token === 37 || isStartOfExpression())) { @@ -7552,8 +7681,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(172, identifier.pos); - var parameter = createNode(136, identifier.pos); + var node = createNode(174, identifier.pos); + var parameter = createNode(138, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -7583,7 +7712,7 @@ var ts; return finishNode(arrowFunction); } function isParenthesizedArrowFunctionExpression() { - if (token === 17 || token === 25 || token === 116) { + if (token === 17 || token === 25 || token === 118) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } if (token === 34) { @@ -7592,7 +7721,7 @@ var ts; return 0; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 116) { + if (token === 118) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0; @@ -7608,7 +7737,7 @@ var ts; var third = nextToken(); switch (third) { case 34: - case 53: + case 54: case 15: return 1; default: @@ -7624,7 +7753,7 @@ var ts; if (!isIdentifier()) { return 0; } - if (nextToken() === 53) { + if (nextToken() === 54) { return 1; } return 2; @@ -7637,10 +7766,10 @@ var ts; if (sourceFile.languageVariant === 1) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 81) { + if (third === 83) { var fourth = nextToken(); switch (fourth) { - case 55: + case 56: case 27: return false; default: @@ -7664,10 +7793,10 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(172); + var node = createNode(174); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 512); - fillSignature(53, false, isAsync, !allowAmbiguity, node); + fillSignature(54, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; } @@ -7681,8 +7810,8 @@ var ts; return parseFunctionBlock(false, isAsync, false); } if (token !== 23 && - token !== 85 && - token !== 71 && + token !== 87 && + token !== 73 && isStartOfStatement() && !isStartOfExpressionStatement()) { return parseFunctionBlock(false, isAsync, true); @@ -7692,15 +7821,15 @@ var ts; : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(52); + var questionToken = parseOptionalToken(53); if (!questionToken) { return leftOperand; } - var node = createNode(180, leftOperand.pos); + var node = createNode(182, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(53, false, ts.Diagnostics._0_expected, ts.tokenToString(53)); + node.colonToken = parseExpectedToken(54, false, ts.Diagnostics._0_expected, ts.tokenToString(54)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -7709,19 +7838,22 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 88 || t === 132; + return t === 90 || t === 134; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { reScanGreaterToken(); var newPrecedence = getBinaryOperatorPrecedence(); - if (newPrecedence <= precedence) { + var consumeCurrentOperator = token === 38 ? + newPrecedence >= precedence : + newPrecedence > precedence; + if (!consumeCurrentOperator) { break; } - if (token === 88 && inDisallowInContext()) { + if (token === 90 && inDisallowInContext()) { break; } - if (token === 114) { + if (token === 116) { if (scanner.hasPrecedingLineBreak()) { break; } @@ -7737,22 +7869,22 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 88) { + if (inDisallowInContext() && token === 90) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 51: + case 52: return 1; - case 50: + case 51: return 2; - case 46: - return 3; case 47: + return 3; + case 48: return 4; - case 45: + case 46: return 5; case 30: case 31: @@ -7763,64 +7895,66 @@ var ts; case 27: case 28: case 29: - case 89: - case 88: - case 114: + case 91: + case 90: + case 116: return 7; - case 42: case 43: case 44: + case 45: return 8; case 35: case 36: return 9; case 37: - case 38: case 39: + case 40: return 10; + case 38: + return 11; } return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(179, left.pos); + var node = createNode(181, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(187, left.pos); + var node = createNode(189, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(177); + var node = createNode(179); node.operator = token; nextToken(); - node.operand = parseUnaryExpressionOrHigher(); + node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(173); + var node = createNode(175); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(174); + var node = createNode(176); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(175); + var node = createNode(177); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token === 117) { + if (token === 119) { if (inAwaitContext()) { return true; } @@ -7829,45 +7963,87 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(176); + var node = createNode(178); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseUnaryExpressionOrHigher() { if (isAwaitExpression()) { return parseAwaitExpression(); } + if (isIncrementExpression()) { + var incrementExpression = parseIncrementExpression(); + return token === 38 ? + parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : + incrementExpression; + } + var unaryOperator = token; + var simpleUnaryExpression = parseSimpleUnaryExpression(); + if (token === 38) { + var diagnostic; + var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); + if (simpleUnaryExpression.kind === 171) { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); + } + else { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses, ts.tokenToString(unaryOperator)); + } + } + return simpleUnaryExpression; + } + function parseSimpleUnaryExpression() { switch (token) { case 35: case 36: + case 50: case 49: - case 48: - case 40: - case 41: return parsePrefixUnaryExpression(); - case 76: + case 78: return parseDeleteExpression(); - case 99: - return parseTypeOfExpression(); case 101: + return parseTypeOfExpression(); + case 103: return parseVoidExpression(); + case 25: + return parseTypeAssertion(); + default: + return parseIncrementExpression(); + } + } + function isIncrementExpression() { + switch (token) { + case 35: + case 36: + case 50: + case 49: + case 78: + case 101: + case 103: + return false; case 25: if (sourceFile.languageVariant !== 1) { - return parseTypeAssertion(); - } - if (lookAhead(nextTokenIsIdentifierOrKeyword)) { - return parseJsxElementOrSelfClosingElement(true); + return false; } default: - return parsePostfixExpressionOrHigher(); + return true; } } - function parsePostfixExpressionOrHigher() { + function parseIncrementExpression() { + if (token === 41 || token === 42) { + var node = createNode(179); + node.operator = token; + nextToken(); + node.operand = parseLeftHandSideExpressionOrHigher(); + return finishNode(node); + } + else if (sourceFile.languageVariant === 1 && token === 25 && lookAhead(nextTokenIsIdentifierOrKeyword)) { + return parseJsxElementOrSelfClosingElement(true); + } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 40 || token === 41) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(178, expression.pos); + if ((token === 41 || token === 42) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(180, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -7876,7 +8052,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token === 93 + var expression = token === 95 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -7890,7 +8066,7 @@ var ts; if (token === 17 || token === 21 || token === 19) { return expression; } - var node = createNode(164, expression.pos); + var node = createNode(166, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); @@ -7898,26 +8074,26 @@ var ts; } function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); - if (opening.kind === 233) { - var node = createNode(231, opening.pos); + if (opening.kind === 235) { + var node = createNode(233, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); return finishNode(node); } else { - ts.Debug.assert(opening.kind === 232); + ts.Debug.assert(opening.kind === 234); return opening; } } function parseJsxText() { - var node = createNode(234, scanner.getStartPos()); + var node = createNode(236, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 234: + case 236: return parseJsxText(); case 15: return parseJsxExpression(false); @@ -7953,11 +8129,11 @@ var ts; var attributes = parseList(13, parseJsxAttribute); var node; if (token === 27) { - node = createNode(233, fullStart); + node = createNode(235, fullStart); scanJsxText(); } else { - parseExpected(38); + parseExpected(39); if (inExpressionContext) { parseExpected(27); } @@ -7965,7 +8141,7 @@ var ts; parseExpected(27, undefined, false); scanJsxText(); } - node = createNode(232, fullStart); + node = createNode(234, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -7976,7 +8152,7 @@ var ts; var elementName = parseIdentifierName(); while (parseOptional(21)) { scanJsxIdentifier(); - var node = createNode(133, elementName.pos); + var node = createNode(135, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); @@ -7984,7 +8160,7 @@ var ts; return elementName; } function parseJsxExpression(inExpressionContext) { - var node = createNode(238); + var node = createNode(240); parseExpected(15); if (token !== 16) { node.expression = parseExpression(); @@ -8003,9 +8179,9 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(236); + var node = createNode(238); node.name = parseIdentifierName(); - if (parseOptional(55)) { + if (parseOptional(56)) { switch (token) { case 9: node.initializer = parseLiteralNode(); @@ -8018,7 +8194,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(237); + var node = createNode(239); parseExpected(15); parseExpected(22); node.expression = parseExpression(); @@ -8026,7 +8202,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(235); + var node = createNode(237); parseExpected(26); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -8039,18 +8215,18 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(169); + var node = createNode(171); parseExpected(25); node.type = parseType(); parseExpected(27); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { var dotToken = parseOptionalToken(21); if (dotToken) { - var propertyAccess = createNode(164, expression.pos); + var propertyAccess = createNode(166, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); @@ -8058,7 +8234,7 @@ var ts; continue; } if (!inDecoratorContext() && parseOptional(19)) { - var indexedAccess = createNode(165, expression.pos); + var indexedAccess = createNode(167, expression.pos); indexedAccess.expression = expression; if (token !== 20) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -8072,7 +8248,7 @@ var ts; continue; } if (token === 11 || token === 12) { - var tagExpression = createNode(168, expression.pos); + var tagExpression = createNode(170, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 11 ? parseLiteralNode() @@ -8091,7 +8267,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(166, expression.pos); + var callExpr = createNode(168, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -8099,7 +8275,7 @@ var ts; continue; } else if (token === 17) { - var callExpr = createNode(166, expression.pos); + var callExpr = createNode(168, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -8132,18 +8308,18 @@ var ts; case 21: case 18: case 20: - case 53: + case 54: case 23: - case 52: + case 53: case 30: case 32: case 31: case 33: - case 50: case 51: - case 47: - case 45: + case 52: + case 48: case 46: + case 47: case 16: case 1: return true; @@ -8159,11 +8335,11 @@ var ts; case 9: case 11: return parseLiteralNode(); + case 97: case 95: case 93: - case 91: - case 97: - case 82: + case 99: + case 84: return parseTokenNode(); case 17: return parseParenthesizedExpression(); @@ -8171,19 +8347,19 @@ var ts; return parseArrayLiteralExpression(); case 15: return parseObjectLiteralExpression(); - case 116: + case 118: if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } return parseFunctionExpression(); - case 71: + case 73: return parseClassExpression(); - case 85: + case 87: return parseFunctionExpression(); - case 90: + case 92: return parseNewExpression(); - case 38: - case 59: + case 39: + case 61: if (reScanSlashToken() === 10) { return parseLiteralNode(); } @@ -8194,28 +8370,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(170); + var node = createNode(172); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); return finishNode(node); } function parseSpreadElement() { - var node = createNode(183); + var node = createNode(185); parseExpected(22); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 22 ? parseSpreadElement() : - token === 24 ? createNode(185) : + token === 24 ? createNode(187) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(162); + var node = createNode(164); parseExpected(19); if (scanner.hasPrecedingLineBreak()) node.flags |= 2048; @@ -8224,11 +8400,11 @@ var ts; return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(121)) { - return parseAccessorDeclaration(143, fullStart, decorators, modifiers); + if (parseContextualModifier(123)) { + return parseAccessorDeclaration(145, fullStart, decorators, modifiers); } - else if (parseContextualModifier(127)) { - return parseAccessorDeclaration(144, fullStart, decorators, modifiers); + else if (parseContextualModifier(129)) { + return parseAccessorDeclaration(146, fullStart, decorators, modifiers); } return undefined; } @@ -8244,27 +8420,33 @@ var ts; var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); - var questionToken = parseOptionalToken(52); + var questionToken = parseOptionalToken(53); if (asteriskToken || token === 17 || token === 25) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } - if ((token === 24 || token === 16) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(244, fullStart); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 || token === 16 || token === 56); + if (isShorthandPropertyAssignment) { + var shorthandDeclaration = createNode(246, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; + var equalsToken = parseOptionalToken(56); + if (equalsToken) { + shorthandDeclaration.equalsToken = equalsToken; + shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); + } return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(243, fullStart); + var propertyAssignment = createNode(245, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(53); + parseExpected(54); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(163); + var node = createNode(165); parseExpected(15); if (scanner.hasPrecedingLineBreak()) { node.flags |= 2048; @@ -8278,9 +8460,9 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(171); + var node = createNode(173); setModifiers(node, parseModifiers()); - parseExpected(85); + parseExpected(87); node.asteriskToken = parseOptionalToken(37); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512); @@ -8289,7 +8471,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(53, isGenerator, isAsync, false, node); + fillSignature(54, isGenerator, isAsync, false, node); node.body = parseFunctionBlock(isGenerator, isAsync, false); if (saveDecoratorContext) { setDecoratorContext(true); @@ -8300,8 +8482,8 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(167); - parseExpected(90); + var node = createNode(169); + parseExpected(92); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token === 17) { @@ -8310,7 +8492,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(190); + var node = createNode(192); if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1, parseStatement); parseExpected(16); @@ -8338,25 +8520,25 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(192); + var node = createNode(194); parseExpected(23); return finishNode(node); } function parseIfStatement() { - var node = createNode(194); - parseExpected(86); + var node = createNode(196); + parseExpected(88); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(78) ? parseStatement() : undefined; + node.elseStatement = parseOptional(80) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(195); - parseExpected(77); + var node = createNode(197); + parseExpected(79); node.statement = parseStatement(); - parseExpected(102); + parseExpected(104); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); @@ -8364,8 +8546,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(196); - parseExpected(102); + var node = createNode(198); + parseExpected(104); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); @@ -8374,11 +8556,11 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(84); + parseExpected(86); parseExpected(17); var initializer = undefined; if (token !== 23) { - if (token === 100 || token === 106 || token === 72) { + if (token === 102 || token === 108 || token === 74) { initializer = parseVariableDeclarationList(true); } else { @@ -8386,22 +8568,22 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(88)) { - var forInStatement = createNode(198, pos); + if (parseOptional(90)) { + var forInStatement = createNode(200, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(18); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(132)) { - var forOfStatement = createNode(199, pos); + else if (parseOptional(134)) { + var forOfStatement = createNode(201, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(18); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(197, pos); + var forStatement = createNode(199, pos); forStatement.initializer = initializer; parseExpected(23); if (token !== 23 && token !== 18) { @@ -8419,7 +8601,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 201 ? 68 : 73); + parseExpected(kind === 203 ? 70 : 75); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -8427,8 +8609,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(202); - parseExpected(92); + var node = createNode(204); + parseExpected(94); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -8436,8 +8618,8 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(203); - parseExpected(103); + var node = createNode(205); + parseExpected(105); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); @@ -8445,30 +8627,30 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(239); - parseExpected(69); + var node = createNode(241); + parseExpected(71); node.expression = allowInAnd(parseExpression); - parseExpected(53); + parseExpected(54); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(240); - parseExpected(75); - parseExpected(53); + var node = createNode(242); + parseExpected(77); + parseExpected(54); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 69 ? parseCaseClause() : parseDefaultClause(); + return token === 71 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(204); - parseExpected(94); + var node = createNode(206); + parseExpected(96); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); - var caseBlock = createNode(218, scanner.getStartPos()); + var caseBlock = createNode(220, scanner.getStartPos()); parseExpected(15); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(16); @@ -8476,28 +8658,26 @@ var ts; return finishNode(node); } function parseThrowStatement() { - // ThrowStatement[Yield] : - // throw [no LineTerminator here]Expression[In, ?Yield]; - var node = createNode(206); - parseExpected(96); + var node = createNode(208); + parseExpected(98); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(207); - parseExpected(98); + var node = createNode(209); + parseExpected(100); node.tryBlock = parseBlock(false); - node.catchClause = token === 70 ? parseCatchClause() : undefined; - if (!node.catchClause || token === 83) { - parseExpected(83); + node.catchClause = token === 72 ? parseCatchClause() : undefined; + if (!node.catchClause || token === 85) { + parseExpected(85); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(242); - parseExpected(70); + var result = createNode(244); + parseExpected(72); if (parseExpected(17)) { result.variableDeclaration = parseVariableDeclaration(); } @@ -8506,80 +8686,77 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(208); - parseExpected(74); + var node = createNode(210); + parseExpected(76); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 67 && parseOptional(53)) { - var labeledStatement = createNode(205, fullStart); + if (expression.kind === 69 && parseOptional(54)) { + var labeledStatement = createNode(207, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(193, fullStart); + var expressionStatement = createNode(195, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); } } - function isIdentifierOrKeyword() { - return token >= 67; - } function nextTokenIsIdentifierOrKeywordOnSameLine() { nextToken(); - return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); + return ts.tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token === 85 && !scanner.hasPrecedingLineBreak(); + return token === 87 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); - return (isIdentifierOrKeyword() || token === 8) && !scanner.hasPrecedingLineBreak(); + return (ts.tokenIsIdentifierOrKeyword(token) || token === 8) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token) { - case 100: - case 106: - case 72: - case 85: - case 71: - case 79: + case 102: + case 108: + case 74: + case 87: + case 73: + case 81: return true; - case 105: - case 130: + case 107: + case 132: return nextTokenIsIdentifierOnSameLine(); - case 123: - case 124: + case 125: + case 126: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 116: - case 120: + case 115: + case 118: + case 122: + case 110: + case 111: + case 112: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 87: + case 89: nextToken(); return token === 9 || token === 37 || - token === 15 || isIdentifierOrKeyword(); - case 80: + token === 15 || ts.tokenIsIdentifierOrKeyword(token); + case 82: nextToken(); - if (token === 55 || token === 37 || - token === 15 || token === 75) { + if (token === 56 || token === 37 || + token === 15 || token === 77) { return true; } continue; - case 110: - case 108: - case 109: - case 111: case 113: nextToken(); continue; @@ -8593,44 +8770,44 @@ var ts; } function isStartOfStatement() { switch (token) { - case 54: + case 55: case 23: case 15: - case 100: - case 106: - case 85: - case 71: - case 79: - case 86: - case 77: case 102: - case 84: + case 108: + case 87: case 73: - case 68: - case 92: - case 103: + case 81: + case 88: + case 79: + case 104: + case 86: + case 75: + case 70: case 94: + case 105: case 96: case 98: - case 74: - case 70: - case 83: - return true; + case 100: + case 76: case 72: - case 80: - case 87: + case 85: + return true; + case 74: + case 82: + case 89: return isStartOfDeclaration(); - case 116: - case 120: - case 105: - case 123: - case 124: - case 130: + case 118: + case 122: + case 107: + case 125: + case 126: + case 132: return true; + case 112: case 110: - case 108: - case 109: case 111: + case 113: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -8649,60 +8826,60 @@ var ts; return parseEmptyStatement(); case 15: return parseBlock(false); - case 100: + case 102: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 106: + case 108: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } break; - case 85: + case 87: return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 71: + case 73: return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); - case 86: + case 88: return parseIfStatement(); - case 77: + case 79: return parseDoStatement(); - case 102: + case 104: return parseWhileStatement(); - case 84: + case 86: return parseForOrForInOrForOfStatement(); - case 73: - return parseBreakOrContinueStatement(200); - case 68: - return parseBreakOrContinueStatement(201); - case 92: + case 75: + return parseBreakOrContinueStatement(202); + case 70: + return parseBreakOrContinueStatement(203); + case 94: return parseReturnStatement(); - case 103: + case 105: return parseWithStatement(); - case 94: - return parseSwitchStatement(); case 96: - return parseThrowStatement(); + return parseSwitchStatement(); case 98: - case 70: - case 83: + return parseThrowStatement(); + case 100: + case 72: + case 85: return parseTryStatement(); - case 74: + case 76: return parseDebuggerStatement(); - case 54: + case 55: return parseDeclaration(); - case 116: - case 105: - case 130: - case 123: - case 124: - case 120: - case 72: - case 79: - case 80: - case 87: - case 108: - case 109: + case 118: + case 107: + case 132: + case 125: + case 126: + case 122: + case 74: + case 81: + case 82: + case 89: case 110: - case 113: case 111: + case 112: + case 115: + case 113: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -8715,33 +8892,33 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 100: - case 106: - case 72: + case 102: + case 108: + case 74: return parseVariableStatement(fullStart, decorators, modifiers); - case 85: + case 87: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 71: + case 73: return parseClassDeclaration(fullStart, decorators, modifiers); - case 105: + case 107: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 130: + case 132: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 79: + case 81: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 123: - case 124: + case 125: + case 126: return parseModuleDeclaration(fullStart, decorators, modifiers); - case 87: + case 89: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 80: + case 82: nextToken(); - return token === 75 || token === 55 ? + return token === 77 || token === 56 ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { - var node = createMissingNode(229, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(231, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -8762,23 +8939,23 @@ var ts; } function parseArrayBindingElement() { if (token === 24) { - return createNode(185); + return createNode(187); } - var node = createNode(161); + var node = createNode(163); node.dotDotDotToken = parseOptionalToken(22); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(161); + var node = createNode(163); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 53) { + if (tokenIsIdentifier && token !== 54) { node.name = propertyName; } else { - parseExpected(53); + parseExpected(54); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -8786,14 +8963,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(159); + var node = createNode(161); parseExpected(15); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(16); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(160); + var node = createNode(162); parseExpected(19); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(20); @@ -8812,7 +8989,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(209); + var node = createNode(211); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -8821,21 +8998,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(210); + var node = createNode(212); switch (token) { - case 100: + case 102: break; - case 106: + case 108: node.flags |= 16384; break; - case 72: + case 74: node.flags |= 32768; break; default: ts.Debug.fail(); } nextToken(); - if (token === 132 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 134 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -8850,7 +9027,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 18; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(191, fullStart); + var node = createNode(193, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -8858,29 +9035,29 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(211, fullStart); + var node = createNode(213, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(85); + parseExpected(87); node.asteriskToken = parseOptionalToken(37); node.name = node.flags & 1024 ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512); - fillSignature(53, isGenerator, isAsync, false, node); + fillSignature(54, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(142, pos); + var node = createNode(144, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(119); - fillSignature(53, false, false, false, node); + parseExpected(121); + fillSignature(54, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(141, fullStart); + var method = createNode(143, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -8888,12 +9065,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = !!(method.flags & 512); - fillSignature(53, isGenerator, isAsync, false, method); + fillSignature(54, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(139, fullStart); + var property = createNode(141, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -8908,7 +9085,7 @@ var ts; function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { var asteriskToken = parseOptionalToken(37); var name = parsePropertyName(); - var questionToken = parseOptionalToken(52); + var questionToken = parseOptionalToken(53); if (asteriskToken || token === 17 || token === 25) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } @@ -8924,16 +9101,16 @@ var ts; node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(53, false, false, false, node); + fillSignature(54, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { + case 112: case 110: - case 108: - case 109: case 111: + case 113: return true; default: return false; @@ -8941,7 +9118,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 54) { + if (token === 55) { return true; } while (ts.isModifier(token)) { @@ -8962,15 +9139,15 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 127 || idToken === 121) { + if (!ts.isKeyword(idToken) || idToken === 129 || idToken === 123) { return true; } switch (token) { case 17: case 25: + case 54: + case 56: case 53: - case 55: - case 52: return true; default: return canParseSemicolon(); @@ -8982,14 +9159,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(54)) { + if (!parseOptional(55)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(137, decoratorStart); + var decorator = createNode(139, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -9023,7 +9200,7 @@ var ts; function parseModifiersForArrowFunction() { var flags = 0; var modifiers; - if (token === 116) { + if (token === 118) { var modifierStart = scanner.getStartPos(); var modifierKind = token; nextToken(); @@ -9038,7 +9215,7 @@ var ts; } function parseClassElement() { if (token === 23) { - var result = createNode(189); + var result = createNode(191); nextToken(); return finishNode(result); } @@ -9049,13 +9226,13 @@ var ts; if (accessor) { return accessor; } - if (token === 119) { + if (token === 121) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { return parseIndexSignatureDeclaration(fullStart, decorators, modifiers); } - if (isIdentifierOrKeyword() || + if (ts.tokenIsIdentifierOrKeyword(token) || token === 9 || token === 8 || token === 37 || @@ -9063,23 +9240,23 @@ var ts; return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_7 = createMissingNode(67, true, ts.Diagnostics.Declaration_expected); + var name_7 = createMissingNode(69, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 184); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 186); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 212); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 214); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(71); - node.name = parseOptionalIdentifier(); + parseExpected(73); + node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(true); if (parseExpected(15)) { @@ -9091,9 +9268,15 @@ var ts; } return finishNode(node); } + function parseNameOfClassDeclarationOrExpression() { + return isIdentifier() && !isImplementsClause() + ? parseIdentifier() + : undefined; + } + function isImplementsClause() { + return token === 106 && lookAhead(nextTokenIsIdentifierOrKeyword); + } function parseHeritageClauses(isClassHeritageClause) { - // ClassTail[Yield,Await] : (Modified) See 14.5 - // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { return parseList(20, parseHeritageClause); } @@ -9103,8 +9286,8 @@ var ts; return parseList(20, parseHeritageClause); } function parseHeritageClause() { - if (token === 81 || token === 104) { - var node = createNode(241); + if (token === 83 || token === 106) { + var node = createNode(243); node.token = token; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -9113,7 +9296,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(186); + var node = createNode(188); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 25) { node.typeArguments = parseBracketedList(18, parseType, 25, 27); @@ -9121,16 +9304,16 @@ var ts; return finishNode(node); } function isHeritageClause() { - return token === 81 || token === 104; + return token === 83 || token === 106; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213, fullStart); + var node = createNode(215, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(105); + parseExpected(107); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(false); @@ -9138,28 +9321,28 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(214, fullStart); + var node = createNode(216, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(130); + parseExpected(132); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(55); + parseExpected(56); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNode(245, scanner.getStartPos()); + var node = createNode(247, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215, fullStart); + var node = createNode(217, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(79); + parseExpected(81); node.name = parseIdentifier(); if (parseExpected(15)) { node.members = parseDelimitedList(6, parseEnumMember); @@ -9171,7 +9354,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(217, scanner.getStartPos()); + var node = createNode(219, scanner.getStartPos()); if (parseExpected(15)) { node.statements = parseList(1, parseStatement); parseExpected(16); @@ -9182,18 +9365,19 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(216, fullStart); + var node = createNode(218, fullStart); + var namespaceFlag = flags & 131072; node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(21) - ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1) + ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 | namespaceFlag) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216, fullStart); + var node = createNode(218, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -9202,11 +9386,11 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(124)) { + if (parseOptional(126)) { flags |= 131072; } else { - parseExpected(123); + parseExpected(125); if (token === 9) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -9214,64 +9398,58 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 125 && + return token === 127 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 17; } function nextTokenIsSlash() { - return nextToken() === 38; + return nextToken() === 39; } function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 24 || - token === 131; + token === 133; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(87); + parseExpected(89); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 24 && token !== 131) { - var importEqualsDeclaration = createNode(219, fullStart); + if (token !== 24 && token !== 133) { + var importEqualsDeclaration = createNode(221, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(55); + parseExpected(56); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(220, fullStart); + var importDeclaration = createNode(222, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || token === 37 || token === 15) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(131); + parseExpected(133); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - // ImportClause: - // ImportedDefaultBinding - // NameSpaceImport - // NamedImports - // ImportedDefaultBinding, NameSpaceImport - // ImportedDefaultBinding, NamedImports - var importClause = createNode(221, fullStart); + var importClause = createNode(223, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(24)) { - importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(223); + importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(225); } return finishNode(importClause); } @@ -9281,8 +9459,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(230); - parseExpected(125); + var node = createNode(232); + parseExpected(127); parseExpected(17); node.expression = parseModuleSpecifier(); parseExpected(18); @@ -9296,22 +9474,22 @@ var ts; return result; } function parseNamespaceImport() { - var namespaceImport = createNode(222); + var namespaceImport = createNode(224); parseExpected(37); - parseExpected(114); + parseExpected(116); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 223 ? parseImportSpecifier : parseExportSpecifier, 15, 16); + node.elements = parseBracketedList(21, kind === 225 ? parseImportSpecifier : parseExportSpecifier, 15, 16); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(228); + return parseImportOrExportSpecifier(230); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(224); + return parseImportOrExportSpecifier(226); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -9319,9 +9497,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 114) { + if (token === 116) { node.propertyName = identifierName; - parseExpected(114); + parseExpected(116); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -9330,23 +9508,23 @@ var ts; else { node.name = identifierName; } - if (kind === 224 && checkIdentifierIsKeyword) { + if (kind === 226 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(226, fullStart); + var node = createNode(228, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(37)) { - parseExpected(131); + parseExpected(133); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(227); - if (token === 131 || (token === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(131); + node.exportClause = parseNamedImportsOrExports(229); + if (token === 133 || (token === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(133); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -9354,14 +9532,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(227, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(55)) { + if (parseOptional(56)) { node.isExportEquals = true; } else { - parseExpected(75); + parseExpected(77); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -9424,10 +9602,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 - || node.kind === 219 && node.moduleReference.kind === 230 - || node.kind === 220 - || node.kind === 225 - || node.kind === 226 + || node.kind === 221 && node.moduleReference.kind === 232 + || node.kind === 222 + || node.kind === 227 + || node.kind === 228 ? node : undefined; }); @@ -9437,18 +9615,18 @@ var ts; function isJSDocType() { switch (token) { case 37: - case 52: + case 53: case 17: case 19: - case 48: + case 49: case 15: - case 85: + case 87: case 22: - case 90: - case 95: + case 92: + case 97: return true; } - return isIdentifierOrKeyword(); + return ts.tokenIsIdentifierOrKeyword(token); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { @@ -9462,7 +9640,7 @@ var ts; function parseJSDocTypeExpression(start, length) { scanner.setText(sourceText, start, length); token = nextToken(); - var result = createNode(247); + var result = createNode(249); parseExpected(15); result.type = parseJSDocTopLevelType(); parseExpected(16); @@ -9472,13 +9650,13 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 46) { - var unionType = createNode(251, type.pos); + if (token === 47) { + var unionType = createNode(253, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 55) { - var optionalType = createNode(258, type.pos); + if (token === 56) { + var optionalType = createNode(260, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -9489,20 +9667,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 19) { - var arrayType = createNode(250, type.pos); + var arrayType = createNode(252, type.pos); arrayType.elementType = type; nextToken(); parseExpected(20); type = finishNode(arrayType); } - else if (token === 52) { - var nullableType = createNode(253, type.pos); + else if (token === 53) { + var nullableType = createNode(255, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 48) { - var nonNullableType = createNode(254, type.pos); + else if (token === 49) { + var nonNullableType = createNode(256, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -9517,80 +9695,80 @@ var ts; switch (token) { case 37: return parseJSDocAllType(); - case 52: + case 53: return parseJSDocUnknownOrNullableType(); case 17: return parseJSDocUnionType(); case 19: return parseJSDocTupleType(); - case 48: + case 49: return parseJSDocNonNullableType(); case 15: return parseJSDocRecordType(); - case 85: + case 87: return parseJSDocFunctionType(); case 22: return parseJSDocVariadicType(); - case 90: + case 92: return parseJSDocConstructorType(); - case 95: + case 97: return parseJSDocThisType(); - case 115: + case 117: + case 130: case 128: - case 126: - case 118: - case 129: - case 101: + case 120: + case 131: + case 103: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(262); + var result = createNode(264); nextToken(); - parseExpected(53); + parseExpected(54); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(261); + var result = createNode(263); nextToken(); - parseExpected(53); + parseExpected(54); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(260); + var result = createNode(262); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(259); + var result = createNode(261); nextToken(); parseExpected(17); result.parameters = parseDelimitedList(22, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(18); - if (token === 53) { + if (token === 54) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(136); + var parameter = createNode(138); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(258, type.pos); + var result = createNode(260, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(257); + var result = createNode(259); result.name = parseSimplePropertyName(); while (parseOptional(21)) { if (token === 25) { @@ -9619,13 +9797,13 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(133, left.pos); + var result = createNode(135, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(255); + var result = createNode(257); nextToken(); result.members = parseDelimitedList(24, parseJSDocRecordMember); checkForTrailingComma(result.members); @@ -9633,22 +9811,22 @@ var ts; return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(256); + var result = createNode(258); result.name = parseSimplePropertyName(); - if (token === 53) { + if (token === 54) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(254); + var result = createNode(256); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(252); + var result = createNode(254); nextToken(); result.types = parseDelimitedList(25, parseJSDocType); checkForTrailingComma(result.types); @@ -9662,7 +9840,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(251); + var result = createNode(253); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(18); @@ -9673,14 +9851,14 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(46)) { + while (parseOptional(47)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(248); + var result = createNode(250); nextToken(); return finishNode(result); } @@ -9691,13 +9869,13 @@ var ts; token === 16 || token === 18 || token === 27 || - token === 55 || - token === 46) { - var result = createNode(249, pos); + token === 56 || + token === 47) { + var result = createNode(251, pos); return finishNode(result); } else { - var result = createNode(253, pos); + var result = createNode(255, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -9768,7 +9946,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(263, start); + var result = createNode(265, start); result.tags = tags; return finishNode(result, end); } @@ -9779,7 +9957,7 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64); - var atToken = createNode(54, pos - 1); + var atToken = createNode(55, pos - 1); atToken.end = pos; var tagName = scanIdentifier(); if (!tagName) { @@ -9805,7 +9983,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(264, atToken.pos); + var result = createNode(266, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -9856,7 +10034,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(265, atToken.pos); + var result = createNode(267, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -9866,27 +10044,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 266; })) { + if (ts.forEach(tags, function (t) { return t.kind === 268; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(266, atToken.pos); + var result = createNode(268, 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 === 267; })) { + if (ts.forEach(tags, function (t) { return t.kind === 269; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(267, atToken.pos); + var result = createNode(269, 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 === 268; })) { + if (ts.forEach(tags, function (t) { return t.kind === 270; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -9899,7 +10077,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(135, name_8.pos); + var typeParameter = createNode(137, name_8.pos); typeParameter.name = name_8; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -9910,7 +10088,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(268, atToken.pos); + var result = createNode(270, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -9931,7 +10109,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(67, startPos); + var result = createNode(69, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -10007,7 +10185,7 @@ var ts; switch (node.kind) { case 9: case 8: - case 67: + case 69: return true; } return false; @@ -10221,7 +10399,6 @@ var ts; } })(IncrementalParser || (IncrementalParser = {})); })(ts || (ts = {})); -/// var ts; (function (ts) { var nextSymbolId = 1; @@ -10247,17 +10424,19 @@ var ts; var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); var typeCount = 0; + var symbolCount = 0; var emptyArray = []; var emptySymbols = {}; var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 ? 5 : 0; var emitResolver = createResolver(); var undefinedSymbol = createSymbol(4 | 67108864, "undefined"); var argumentsSymbol = createSymbol(4 | 67108864, "arguments"); var checker = { getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, - getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount"); }, + getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, getTypeCount: function () { return typeCount; }, isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, @@ -10403,6 +10582,7 @@ var ts; diagnostics.add(diagnostic); } function createSymbol(flags, name) { + symbolCount++; return new Symbol(flags, name); } function getExcludedSymbolFlags(flags) { @@ -10531,10 +10711,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 246); + return ts.getAncestor(node, 248); } function isGlobalSourceFile(node) { - return node.kind === 246 && !ts.isExternalModule(node); + return node.kind === 248 && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -10551,17 +10731,54 @@ var ts; } } } - function isDefinedBefore(node1, node2) { - var file1 = ts.getSourceFileOfNode(node1); - var file2 = ts.getSourceFileOfNode(node2); - if (file1 === file2) { - return node1.pos <= node2.pos; + function isBlockScopedNameDeclaredBeforeUse(declaration, usage) { + var declarationFile = ts.getSourceFileOfNode(declaration); + var useFile = ts.getSourceFileOfNode(usage); + if (declarationFile !== useFile) { + if (modulekind || (!compilerOptions.outFile && !compilerOptions.out)) { + return true; + } + var sourceFiles = host.getSourceFiles(); + return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } - if (!compilerOptions.outFile && !compilerOptions.out) { - return true; + if (declaration.pos <= usage.pos) { + return declaration.kind !== 211 || + !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + return isUsedInFunctionOrNonStaticProperty(declaration, usage); + function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + if (declaration.parent.parent.kind === 193 || + declaration.parent.parent.kind === 199) { + return isSameScopeDescendentOf(usage, declaration, container); + } + else if (declaration.parent.parent.kind === 201 || + declaration.parent.parent.kind === 200) { + var expression = declaration.parent.parent.expression; + return isSameScopeDescendentOf(usage, expression, container); + } + } + function isUsedInFunctionOrNonStaticProperty(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + var current = usage; + while (current) { + if (current === container) { + return false; + } + if (ts.isFunctionLike(current)) { + return true; + } + var initializerOfNonStaticProperty = current.parent && + current.parent.kind === 141 && + (current.parent.flags & 128) === 0 && + current.parent.initializer === current; + if (initializerOfNonStaticProperty) { + return true; + } + current = current.parent; + } + return false; } - var sourceFiles = host.getSourceFiles(); - return sourceFiles.indexOf(file1) <= sourceFiles.indexOf(file2); } function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { var result; @@ -10582,16 +10799,16 @@ var ts; } } switch (location.kind) { - case 246: + case 248: if (!ts.isExternalModule(location)) break; - case 216: + case 218: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 246 || - (location.kind === 216 && location.name.kind === 9)) { + if (location.kind === 248 || + (location.kind === 218 && location.name.kind === 9)) { if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 228)) { + ts.getDeclarationOfKind(moduleExports[name], 230)) { break; } result = moduleExports["default"]; @@ -10605,13 +10822,13 @@ var ts; break loop; } break; - case 215: + case 217: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; - case 139: - case 138: + case 141: + case 140: if (ts.isClassLike(location.parent) && !(location.flags & 128)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -10621,9 +10838,9 @@ var ts; } } break; - case 212: - case 184: - case 213: + case 214: + case 186: + case 215: 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); @@ -10631,7 +10848,7 @@ var ts; } break loop; } - if (location.kind === 184 && meaning & 32) { + if (location.kind === 186 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -10639,28 +10856,28 @@ var ts; } } break; - case 134: + case 136: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 213) { + if (ts.isClassLike(grandparent) || grandparent.kind === 215) { 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 141: - case 140: - case 142: case 143: + case 142: case 144: - case 211: - case 172: + case 145: + case 146: + case 213: + case 174: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 171: + case 173: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -10673,8 +10890,8 @@ var ts; } } break; - case 137: - if (location.parent && location.parent.kind === 136) { + case 139: + if (location.parent && location.parent.kind === 138) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -10700,8 +10917,11 @@ var ts; error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); return undefined; } - if (meaning & 2 && result.flags & 2) { - checkResolvedBlockScopedVariable(result, errorLocation); + if (meaning & 2) { + var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); + if (exportOrLocalSymbol.flags & 2) { + checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); + } } } return result; @@ -10710,21 +10930,7 @@ var ts; ts.Debug.assert((result.flags & 2) !== 0); var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); - if (!isUsedBeforeDeclaration) { - var variableDeclaration = ts.getAncestor(declaration, 209); - var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 191 || - variableDeclaration.parent.parent.kind === 197) { - isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); - } - else if (variableDeclaration.parent.parent.kind === 199 || - variableDeclaration.parent.parent.kind === 198) { - var expression = variableDeclaration.parent.parent.expression; - isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); - } - } - if (isUsedBeforeDeclaration) { + if (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 211), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -10741,10 +10947,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 219) { + if (node.kind === 221) { return node; } - while (node && node.kind !== 220) { + while (node && node.kind !== 222) { node = node.parent; } return node; @@ -10754,7 +10960,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 230) { + if (node.moduleReference.kind === 232) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -10843,17 +11049,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 219: - return getTargetOfImportEqualsDeclaration(node); case 221: + return getTargetOfImportEqualsDeclaration(node); + case 223: return getTargetOfImportClause(node); - case 222: - return getTargetOfNamespaceImport(node); case 224: + return getTargetOfNamespaceImport(node); + case 226: return getTargetOfImportSpecifier(node); - case 228: + case 230: return getTargetOfExportSpecifier(node); - case 225: + case 227: return getTargetOfExportAssignment(node); } } @@ -10895,10 +11101,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 225) { + if (node.kind === 227) { checkExpressionCached(node.expression); } - else if (node.kind === 228) { + else if (node.kind === 230) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -10908,17 +11114,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 219); + importDeclaration = ts.getAncestor(entityName, 221); ts.Debug.assert(importDeclaration !== undefined); } - if (entityName.kind === 67 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 69 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 67 || entityName.parent.kind === 133) { + if (entityName.kind === 69 || entityName.parent.kind === 135) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 219); + ts.Debug.assert(entityName.parent.kind === 221); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -10930,16 +11136,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 67) { + if (name.kind === 69) { var message = meaning === 1536 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 133 || name.kind === 164) { - var left = name.kind === 133 ? name.left : name.expression; - var right = name.kind === 133 ? name.right : name.name; + else if (name.kind === 135 || name.kind === 166) { + var left = name.kind === 135 ? name.left : name.expression; + var right = name.kind === 135 ? name.right : name.name; var namespace = resolveEntityName(left, 1536, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -10958,9 +11164,6 @@ var ts; ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); return symbol.flags & meaning ? symbol : resolveAlias(symbol); } - function isExternalModuleNameRelative(moduleName) { - return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; - } function resolveExternalModuleName(location, moduleReferenceExpression) { if (moduleReferenceExpression.kind !== 9) { return; @@ -10968,10 +11171,10 @@ var ts; var moduleReferenceLiteral = moduleReferenceExpression; var searchPath = ts.getDirectoryPath(getSourceFile(location).fileName); var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); - if (!moduleName) { + if (moduleName === undefined) { return; } - var isRelative = isExternalModuleNameRelative(moduleName); + var isRelative = ts.isExternalModuleNameRelative(moduleName); if (!isRelative) { var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512); if (symbol) { @@ -11075,7 +11278,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 142 && ts.nodeIsPresent(member.body)) { + if (member.kind === 144 && ts.nodeIsPresent(member.body)) { return member; } } @@ -11140,17 +11343,17 @@ var ts; } } switch (location_1.kind) { - case 246: + case 248: if (!ts.isExternalModule(location_1)) { break; } - case 216: + case 218: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 212: - case 213: + case 214: + case 215: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -11183,7 +11386,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -11212,7 +11415,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -11267,8 +11470,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 216 && declaration.name.kind === 9) || - (declaration.kind === 246 && ts.isExternalModule(declaration)); + return (declaration.kind === 218 && declaration.name.kind === 9) || + (declaration.kind === 248 && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -11300,11 +11503,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 152) { + if (entityName.parent.kind === 154) { meaning = 107455 | 1048576; } - else if (entityName.kind === 133 || entityName.kind === 164 || - entityName.parent.kind === 219) { + else if (entityName.kind === 135 || entityName.kind === 166 || + entityName.parent.kind === 221) { meaning = 1536; } else { @@ -11355,10 +11558,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 158) { + while (node.kind === 160) { node = node.parent; } - if (node.kind === 214) { + if (node.kind === 216) { return getSymbolOfNode(node); } } @@ -11372,10 +11575,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 184: + case 186: return "(Anonymous class)"; - case 171: - case 172: + case 173: + case 174: return "(Anonymous function)"; } } @@ -11436,6 +11639,7 @@ var ts; } function buildTypeDisplay(type, writer, enclosingDeclaration, globalFlags, symbolStack) { var globalFlagsToPass = globalFlags & 16; + var inObjectTypeLiteral = false; return writeType(type, globalFlags); function writeType(type, flags) { if (type.flags & 16777343) { @@ -11443,6 +11647,12 @@ var ts; ? "any" : type.intrinsicName); } + else if (type.flags & 33554432) { + if (inObjectTypeLiteral) { + writer.reportInaccessibleThisError(); + } + writer.writeKeyword("this"); + } else if (type.flags & 4096) { writeTypeReference(type, flags); } @@ -11481,9 +11691,9 @@ var ts; writeType(types[i], delimiter === 24 ? 0 : 64); } } - function writeSymbolTypeReference(symbol, typeArguments, pos, end) { - if (!isReservedMemberName(symbol.name)) { - buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056); + function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { + if (symbol.flags & 32 || !isReservedMemberName(symbol.name)) { + buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056, 0, flags); } if (pos < end) { writePunctuation(writer, 25); @@ -11497,7 +11707,7 @@ var ts; } } function writeTypeReference(type, flags) { - var typeArguments = type.typeArguments; + var typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & 1)) { writeType(typeArguments[0], 64); writePunctuation(writer, 19); @@ -11515,12 +11725,13 @@ var ts; i++; } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_3); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_3, typeArguments, start, i); + writeSymbolTypeReference(parent_3, typeArguments, start, i, flags); writePunctuation(writer, 21); } } } - writeSymbolTypeReference(type.symbol, typeArguments, i, typeArguments.length); + var typeParameterCount = (type.target.typeParameters || emptyArray).length; + writeSymbolTypeReference(type.symbol, typeArguments, i, typeParameterCount, flags); } } function writeTupleType(type) { @@ -11532,7 +11743,7 @@ var ts; if (flags & 64) { writePunctuation(writer, 17); } - writeTypeList(type.types, type.flags & 16384 ? 46 : 45); + writeTypeList(type.types, type.flags & 16384 ? 47 : 46); if (flags & 64) { writePunctuation(writer, 18); } @@ -11552,7 +11763,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056, 0, flags); } else { - writeKeyword(writer, 115); + writeKeyword(writer, 117); } } else { @@ -11573,7 +11784,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 246 || declaration.parent.kind === 217; + return declaration.parent.kind === 248 || declaration.parent.kind === 219; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -11582,7 +11793,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 99); + writeKeyword(writer, 101); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } @@ -11616,7 +11827,7 @@ var ts; if (flags & 64) { writePunctuation(writer, 17); } - writeKeyword(writer, 90); + writeKeyword(writer, 92); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); if (flags & 64) { @@ -11625,6 +11836,8 @@ var ts; return; } } + var saveInObjectTypeLiteral = inObjectTypeLiteral; + inObjectTypeLiteral = true; writePunctuation(writer, 15); writer.writeLine(); writer.increaseIndent(); @@ -11636,7 +11849,7 @@ var ts; } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 90); + writeKeyword(writer, 92); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 23); @@ -11645,11 +11858,11 @@ var ts; if (resolved.stringIndexType) { writePunctuation(writer, 19); writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); - writeKeyword(writer, 128); + writeKeyword(writer, 130); writePunctuation(writer, 20); - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); writeType(resolved.stringIndexType, 0); writePunctuation(writer, 23); @@ -11658,11 +11871,11 @@ var ts; if (resolved.numberIndexType) { writePunctuation(writer, 19); writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); - writeKeyword(writer, 126); + writeKeyword(writer, 128); writePunctuation(writer, 20); - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); writeType(resolved.numberIndexType, 0); writePunctuation(writer, 23); @@ -11677,7 +11890,7 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 52); + writePunctuation(writer, 53); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 23); @@ -11687,9 +11900,9 @@ var ts; else { buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 52); + writePunctuation(writer, 53); } - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); writeType(t, 0); writePunctuation(writer, 23); @@ -11698,6 +11911,7 @@ var ts; } writer.decreaseIndent(); writePunctuation(writer, 16); + inObjectTypeLiteral = saveInObjectTypeLiteral; } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { @@ -11711,7 +11925,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 81); + writeKeyword(writer, 83); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -11723,9 +11937,9 @@ var ts; } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 52); + writePunctuation(writer, 53); } - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } @@ -11772,14 +11986,14 @@ var ts; writePunctuation(writer, 34); } else { - writePunctuation(writer, 53); + writePunctuation(writer, 54); } writeSpace(writer); var returnType; if (signature.typePredicate) { writer.writeParameter(signature.typePredicate.parameterName); writeSpace(writer); - writeKeyword(writer, 122); + writeKeyword(writer, 124); writeSpace(writer); returnType = signature.typePredicate.type; } @@ -11813,12 +12027,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 216) { + if (node.kind === 218) { if (node.name.kind === 9) { return node; } } - else if (node.kind === 246) { + else if (node.kind === 248) { return ts.isExternalModule(node) ? node : undefined; } } @@ -11861,59 +12075,59 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 161: + case 163: return isDeclarationVisible(node.parent.parent); - case 209: + case 211: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 216: - case 212: - case 213: + case 218: case 214: - case 211: case 215: - case 219: + case 216: + case 213: + case 217: + case 221: var parent_4 = getDeclarationContainer(node); if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 219 && parent_4.kind !== 246 && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 221 && parent_4.kind !== 248 && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } return isDeclarationVisible(parent_4); - case 139: - case 138: - case 143: - case 144: case 141: case 140: + case 145: + case 146: + case 143: + case 142: if (node.flags & (32 | 64)) { return false; } - case 142: - case 146: - case 145: + case 144: + case 148: case 147: - case 136: - case 217: - case 150: - case 151: - case 153: case 149: - case 154: + case 138: + case 219: + case 152: + case 153: case 155: + case 151: case 156: case 157: case 158: + case 159: + case 160: return isDeclarationVisible(node.parent); - case 221: - case 222: + case 223: case 224: + case 226: return false; - case 135: - case 246: + case 137: + case 248: return true; - case 225: + case 227: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -11929,10 +12143,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 225) { + if (node.parent && node.parent.kind === 227) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 228) { + else if (node.parent.kind === 230) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -12007,7 +12221,7 @@ var ts; } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); - return node.kind === 209 ? node.parent.parent.parent : node.parent; + return node.kind === 211 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); @@ -12020,9 +12234,13 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1) !== 0; } + function getTypeForBindingElementParent(node) { + var symbol = getSymbolOfNode(node); + return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node); + } function getTypeForBindingElement(declaration) { var pattern = declaration.parent; - var parentType = getTypeForVariableLikeDeclaration(pattern.parent); + var parentType = getTypeForBindingElementParent(pattern.parent); if (parentType === unknownType) { return unknownType; } @@ -12033,7 +12251,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 159) { + if (pattern.kind === 161) { var name_10 = declaration.propertyName || declaration.name; type = getTypeOfPropertyOfType(parentType, name_10.text) || isNumericLiteralName(name_10.text) && getIndexTypeOfType(parentType, 1) || @@ -12067,10 +12285,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 198) { + if (declaration.parent.parent.kind === 200) { return anyType; } - if (declaration.parent.parent.kind === 199) { + if (declaration.parent.parent.kind === 201) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -12079,10 +12297,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 136) { + if (declaration.kind === 138) { var func = declaration.parent; - if (func.kind === 144 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 143); + if (func.kind === 146 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 145); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -12095,56 +12313,56 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 244) { + if (declaration.kind === 246) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name); + return getTypeFromBindingPattern(declaration.name, false); } return undefined; } - function getTypeFromBindingElement(element) { + function getTypeFromBindingElement(element, includePatternInType) { if (element.initializer) { return getWidenedType(checkExpressionCached(element.initializer)); } if (ts.isBindingPattern(element.name)) { - return getTypeFromBindingPattern(element.name); + return getTypeFromBindingPattern(element.name, includePatternInType); } return anyType; } - function getTypeFromObjectBindingPattern(pattern) { + function getTypeFromObjectBindingPattern(pattern, includePatternInType) { var members = {}; ts.forEach(pattern.elements, function (e) { var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0); var name = e.propertyName || e.name; var symbol = createSymbol(flags, name.text); - symbol.type = getTypeFromBindingElement(e); + symbol.type = getTypeFromBindingElement(e, includePatternInType); + symbol.bindingElement = e; members[symbol.name] = symbol; }); - return createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + if (includePatternInType) { + result.pattern = pattern; + } + return result; } - function getTypeFromArrayBindingPattern(pattern) { - var hasSpreadElement = false; - var elementTypes = []; - ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 185 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); - if (e.dotDotDotToken) { - hasSpreadElement = true; - } - }); - if (!elementTypes.length) { + function getTypeFromArrayBindingPattern(pattern, includePatternInType) { + var elements = pattern.elements; + if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType; } - else if (hasSpreadElement) { - var unionOfElements = getUnionType(elementTypes); - return languageVersion >= 2 ? createIterableType(unionOfElements) : createArrayType(unionOfElements); + var elementTypes = ts.map(elements, function (e) { return e.kind === 187 ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + if (includePatternInType) { + var result = createNewTupleType(elementTypes); + result.pattern = pattern; + return result; } return createTupleType(elementTypes); } - function getTypeFromBindingPattern(pattern) { - return pattern.kind === 159 - ? getTypeFromObjectBindingPattern(pattern) - : getTypeFromArrayBindingPattern(pattern); + function getTypeFromBindingPattern(pattern, includePatternInType) { + return pattern.kind === 161 + ? getTypeFromObjectBindingPattern(pattern, includePatternInType) + : getTypeFromArrayBindingPattern(pattern, includePatternInType); } function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { var type = getTypeForVariableLikeDeclaration(declaration); @@ -12152,12 +12370,12 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - return declaration.kind !== 243 ? getWidenedType(type) : type; + return declaration.kind !== 245 ? getWidenedType(type) : type; } type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 136 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 138 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -12170,10 +12388,10 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 242) { + if (declaration.parent.kind === 244) { return links.type = anyType; } - if (declaration.kind === 225) { + if (declaration.kind === 227) { return links.type = checkExpression(declaration.expression); } if (!pushTypeResolution(symbol, 0)) { @@ -12198,7 +12416,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 143) { + if (accessor.kind === 145) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -12214,8 +12432,8 @@ var ts; if (!pushTypeResolution(symbol, 0)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 143); - var setter = ts.getDeclarationOfKind(symbol, 144); + var getter = ts.getDeclarationOfKind(symbol, 145); + var setter = ts.getDeclarationOfKind(symbol, 146); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -12241,7 +12459,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 143); + var getter_1 = ts.getDeclarationOfKind(symbol, 145); 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)); } } @@ -12330,9 +12548,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 212 || node.kind === 184 || - node.kind === 211 || node.kind === 171 || - node.kind === 141 || node.kind === 172) { + if (node.kind === 214 || node.kind === 186 || + node.kind === 213 || node.kind === 173 || + node.kind === 143 || node.kind === 174) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -12341,15 +12559,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 213); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 215); return appendOuterTypeParameters(undefined, declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 213 || node.kind === 212 || - node.kind === 184 || node.kind === 214) { + if (node.kind === 215 || node.kind === 214 || + node.kind === 186 || node.kind === 216) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -12454,7 +12672,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 213 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 215 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -12475,6 +12693,29 @@ var ts; } } } + function isIndependentInterface(symbol) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 215) { + if (declaration.flags & 524288) { + return false; + } + var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); + if (baseTypeNodes) { + for (var _b = 0; _b < baseTypeNodes.length; _b++) { + var node = baseTypeNodes[_b]; + if (ts.isSupportedExpressionWithTypeArguments(node)) { + var baseSymbol = resolveEntityName(node.expression, 793056, true); + if (!baseSymbol || !(baseSymbol.flags & 64) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { + return false; + } + } + } + } + } + } + return true; + } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { @@ -12482,7 +12723,7 @@ var ts; var type = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - if (outerTypeParameters || localTypeParameters) { + if (outerTypeParameters || localTypeParameters || kind === 1024 || !isIndependentInterface(symbol)) { type.flags |= 4096; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; @@ -12491,6 +12732,9 @@ var ts; type.instantiations[getTypeListId(type.typeParameters)] = type; type.target = type; type.typeArguments = type.typeParameters; + type.thisType = createType(512 | 33554432); + type.thisType.symbol = symbol; + type.thisType.constraint = getTypeWithThisArgument(type); } } return links.declaredType; @@ -12501,7 +12745,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 214); + var declaration = ts.getDeclarationOfKind(symbol, 216); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -12532,7 +12776,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 135).constraint) { + if (!ts.getDeclarationOfKind(symbol, 137).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -12565,6 +12809,66 @@ var ts; } return unknownType; } + function isIndependentTypeReference(node) { + if (node.typeArguments) { + for (var _i = 0, _a = node.typeArguments; _i < _a.length; _i++) { + var typeNode = _a[_i]; + if (!isIndependentType(typeNode)) { + return false; + } + } + } + return true; + } + function isIndependentType(node) { + switch (node.kind) { + case 117: + case 130: + case 128: + case 120: + case 131: + case 103: + case 9: + return true; + case 156: + return isIndependentType(node.elementType); + case 151: + return isIndependentTypeReference(node); + } + return false; + } + function isIndependentVariableLikeDeclaration(node) { + return node.type && isIndependentType(node.type) || !node.type && !node.initializer; + } + function isIndependentFunctionLikeDeclaration(node) { + if (node.kind !== 144 && (!node.type || !isIndependentType(node.type))) { + return false; + } + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + if (!isIndependentVariableLikeDeclaration(parameter)) { + return false; + } + } + return true; + } + function isIndependentMember(symbol) { + if (symbol.declarations && symbol.declarations.length === 1) { + var declaration = symbol.declarations[0]; + if (declaration) { + switch (declaration.kind) { + case 141: + case 140: + return isIndependentVariableLikeDeclaration(declaration); + case 143: + case 142: + case 144: + return isIndependentFunctionLikeDeclaration(declaration); + } + } + } + return false; + } function createSymbolTable(symbols) { var result = {}; for (var _i = 0; _i < symbols.length; _i++) { @@ -12573,11 +12877,11 @@ var ts; } return result; } - function createInstantiatedSymbolTable(symbols, mapper) { + function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { var result = {}; for (var _i = 0; _i < symbols.length; _i++) { var symbol = symbols[_i]; - result[symbol.name] = instantiateSymbol(symbol, mapper); + result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); } return result; } @@ -12608,44 +12912,54 @@ var ts; } return type; } - function resolveClassOrInterfaceMembers(type) { - var target = resolveDeclaredMembers(type); - var members = target.symbol.members; - var callSignatures = target.declaredCallSignatures; - var constructSignatures = target.declaredConstructSignatures; - var stringIndexType = target.declaredStringIndexType; - var numberIndexType = target.declaredNumberIndexType; - var baseTypes = getBaseTypes(target); + function getTypeWithThisArgument(type, thisArgument) { + if (type.flags & 4096) { + return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); + } + return type; + } + function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) { + var mapper = identityMapper; + var members = source.symbol.members; + var callSignatures = source.declaredCallSignatures; + var constructSignatures = source.declaredConstructSignatures; + var stringIndexType = source.declaredStringIndexType; + var numberIndexType = source.declaredNumberIndexType; + if (!ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { + mapper = createTypeMapper(typeParameters, typeArguments); + members = createInstantiatedSymbolTable(source.declaredProperties, mapper, typeParameters.length === 1); + callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); + constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); + stringIndexType = instantiateType(source.declaredStringIndexType, mapper); + numberIndexType = instantiateType(source.declaredNumberIndexType, mapper); + } + var baseTypes = getBaseTypes(source); if (baseTypes.length) { - members = createSymbolTable(target.declaredProperties); + if (members === source.symbol.members) { + members = createSymbolTable(source.declaredProperties); + } + var thisArgument = ts.lastOrUndefined(typeArguments); for (var _i = 0; _i < baseTypes.length; _i++) { var baseType = baseTypes[_i]; - addInheritedMembers(members, getPropertiesOfObjectType(baseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(baseType, 0)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(baseType, 1)); - stringIndexType = stringIndexType || getIndexTypeOfType(baseType, 0); - numberIndexType = numberIndexType || getIndexTypeOfType(baseType, 1); + var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; + addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); + stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0); + numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1); } } setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } + function resolveClassOrInterfaceMembers(type) { + resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); + } function resolveTypeReferenceMembers(type) { - var target = resolveDeclaredMembers(type.target); - var mapper = createTypeMapper(target.typeParameters, type.typeArguments); - var members = createInstantiatedSymbolTable(target.declaredProperties, mapper); - var callSignatures = instantiateList(target.declaredCallSignatures, mapper, instantiateSignature); - var constructSignatures = instantiateList(target.declaredConstructSignatures, mapper, instantiateSignature); - var stringIndexType = target.declaredStringIndexType ? instantiateType(target.declaredStringIndexType, mapper) : undefined; - var numberIndexType = target.declaredNumberIndexType ? instantiateType(target.declaredNumberIndexType, mapper) : undefined; - ts.forEach(getBaseTypes(target), function (baseType) { - var instantiatedBaseType = instantiateType(baseType, mapper); - addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); - stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0); - numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1); - }); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + var source = resolveDeclaredMembers(type.target); + var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); + var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? + type.typeArguments : ts.concatenate(type.typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, typeArguments); } function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); @@ -12694,7 +13008,8 @@ var ts; return members; } function resolveTupleTypeMembers(type) { - var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, true))); + var arrayElementType = getUnionType(type.elementTypes, true); + var arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); @@ -12796,7 +13111,14 @@ var ts; var constructSignatures; var stringIndexType; var numberIndexType; - if (symbol.flags & 2048) { + if (type.target) { + members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false); + callSignatures = instantiateList(getSignaturesOfType(type.target, 0), type.mapper, instantiateSignature); + constructSignatures = instantiateList(getSignaturesOfType(type.target, 1), type.mapper, instantiateSignature); + stringIndexType = instantiateType(getIndexTypeOfType(type.target, 0), type.mapper); + numberIndexType = instantiateType(getIndexTypeOfType(type.target, 1), type.mapper); + } + else if (symbol.flags & 2048) { members = symbol.members; callSignatures = getSignaturesOfSymbol(members["__call"]); constructSignatures = getSignaturesOfSymbol(members["__new"]); @@ -12832,7 +13154,10 @@ var ts; } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & (1024 | 2048)) { + if (type.flags & 4096) { + resolveTypeReferenceMembers(type); + } + else if (type.flags & (1024 | 2048)) { resolveClassOrInterfaceMembers(type); } else if (type.flags & 65536) { @@ -12847,9 +13172,6 @@ var ts; else if (type.flags & 32768) { resolveIntersectionTypeMembers(type); } - else { - resolveTypeReferenceMembers(type); - } } return type; } @@ -13056,7 +13378,9 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 142 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 144 ? + getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) + : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -13087,7 +13411,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 148) { + if (declaration.type.kind === 150) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -13097,8 +13421,8 @@ var ts; } } else { - if (declaration.kind === 143 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 144); + if (declaration.kind === 145 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 146); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -13116,19 +13440,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 150: - case 151: - case 211: - case 141: - case 140: + case 152: + case 153: + case 213: + case 143: case 142: + case 144: + case 147: + case 148: + case 149: case 145: case 146: - case 147: - case 143: - case 144: - case 171: - case 172: + case 173: + case 174: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -13198,7 +13522,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 142 || signature.declaration.kind === 146; + var isConstructor = signature.declaration.kind === 144 || signature.declaration.kind === 148; var type = createObjectType(65536 | 262144); type.members = emptySymbols; type.properties = emptyArray; @@ -13212,7 +13536,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 126 : 128; + var syntaxKind = kind === 1 ? 128 : 130; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -13241,30 +13565,33 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 135).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 137).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 135).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 137).parent); } function getTypeListId(types) { - switch (types.length) { - case 1: - return "" + types[0].id; - case 2: - return types[0].id + "," + types[1].id; - default: - var result = ""; - for (var i = 0; i < types.length; i++) { - if (i > 0) { - result += ","; + if (types) { + switch (types.length) { + case 1: + return "" + types[0].id; + case 2: + return types[0].id + "," + types[1].id; + default: + var result = ""; + for (var i = 0; i < types.length; i++) { + if (i > 0) { + result += ","; + } + result += types[i].id; } - result += types[i].id; - } - return result; + return result; + } } + return ""; } function getPropagatingFlagsOfTypes(types) { var result = 0; @@ -13278,7 +13605,7 @@ var ts; var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var flags = 4096 | getPropagatingFlagsOfTypes(typeArguments); + var flags = 4096 | (typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0); type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; @@ -13294,13 +13621,13 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 135; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 137; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 149 && n.typeName.kind === 67) { + if (n.kind === 151 && n.typeName.kind === 69) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); @@ -13367,7 +13694,7 @@ var ts; function getTypeFromTypeReference(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var typeNameOrExpression = node.kind === 149 ? node.typeName : + var typeNameOrExpression = node.kind === 151 ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; @@ -13393,9 +13720,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 212: - case 213: + case 214: case 215: + case 217: return declaration; } } @@ -13445,17 +13772,17 @@ var ts; ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) : emptyObjectType; } - function createTypeFromGenericGlobalType(genericGlobalType, elementType) { - return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, [elementType]) : emptyObjectType; + function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) { + return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; } function createIterableType(elementType) { - return createTypeFromGenericGlobalType(globalIterableType, elementType); + return createTypeFromGenericGlobalType(globalIterableType, [elementType]); } function createIterableIteratorType(elementType) { - return createTypeFromGenericGlobalType(globalIterableIteratorType, elementType); + return createTypeFromGenericGlobalType(globalIterableIteratorType, [elementType]); } function createArrayType(elementType) { - return createTypeFromGenericGlobalType(globalArrayType, elementType); + return createTypeFromGenericGlobalType(globalArrayType, [elementType]); } function getTypeFromArrayTypeNode(node) { var links = getNodeLinks(node); @@ -13466,11 +13793,11 @@ var ts; } function createTupleType(elementTypes) { var id = getTypeListId(elementTypes); - var type = tupleTypes[id]; - if (!type) { - type = tupleTypes[id] = createObjectType(8192 | getPropagatingFlagsOfTypes(elementTypes)); - type.elementTypes = elementTypes; - } + return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes)); + } + function createNewTupleType(elementTypes) { + var type = createObjectType(8192 | getPropagatingFlagsOfTypes(elementTypes)); + type.elementTypes = elementTypes; return type; } function getTypeFromTupleTypeNode(node) { @@ -13612,46 +13939,66 @@ var ts; } return links.resolvedType; } + function getThisType(node) { + var container = ts.getThisContainer(node, false); + var parent = container && container.parent; + if (parent && (ts.isClassLike(parent) || parent.kind === 215)) { + if (!(container.flags & 128)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; + } + } + error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); + return unknownType; + } + function getTypeFromThisTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getThisType(node); + } + return links.resolvedType; + } function getTypeFromTypeNode(node) { switch (node.kind) { - case 115: + case 117: return anyType; - case 128: + case 130: return stringType; - case 126: + case 128: return numberType; - case 118: + case 120: return booleanType; - case 129: + case 131: return esSymbolType; - case 101: + case 103: return voidType; + case 97: + return getTypeFromThisTypeNode(node); case 9: return getTypeFromStringLiteral(node); - case 149: + case 151: return getTypeFromTypeReference(node); - case 148: + case 150: return booleanType; - case 186: + case 188: return getTypeFromTypeReference(node); - case 152: - return getTypeFromTypeQueryNode(node); case 154: + return getTypeFromTypeQueryNode(node); + case 156: return getTypeFromArrayTypeNode(node); - case 155: + case 157: return getTypeFromTupleTypeNode(node); - case 156: + case 158: return getTypeFromUnionTypeNode(node); - case 157: + case 159: return getTypeFromIntersectionTypeNode(node); - case 158: + case 160: return getTypeFromTypeNode(node.type); - case 150: - case 151: + case 152: case 153: + case 155: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 67: - case 133: + case 69: + case 135: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -13755,7 +14102,7 @@ var ts; 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); + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -13787,21 +14134,13 @@ var ts; mapper.instantiations = []; } var result = createObjectType(65536 | 131072, type.symbol); - result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); - result.members = createSymbolTable(result.properties); - result.callSignatures = instantiateList(getSignaturesOfType(type, 0), mapper, instantiateSignature); - result.constructSignatures = instantiateList(getSignaturesOfType(type, 1), mapper, instantiateSignature); - var stringIndexType = getIndexTypeOfType(type, 0); - var numberIndexType = getIndexTypeOfType(type, 1); - if (stringIndexType) - result.stringIndexType = instantiateType(stringIndexType, mapper); - if (numberIndexType) - result.numberIndexType = instantiateType(numberIndexType, mapper); + result.target = type; + result.mapper = mapper; mapper.instantiations[type.id] = result; return result; } function instantiateType(type, mapper) { - if (mapper !== identityMapper) { + if (type && mapper !== identityMapper) { if (type.flags & 512) { return mapper(type); } @@ -13825,27 +14164,27 @@ var ts; return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 171: - case 172: + case 173: + case 174: return isContextSensitiveFunctionLikeDeclaration(node); - case 163: + case 165: return ts.forEach(node.properties, isContextSensitive); - case 162: + case 164: return ts.forEach(node.elements, isContextSensitive); - case 180: + case 182: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 179: - return node.operatorToken.kind === 51 && + case 181: + return node.operatorToken.kind === 52 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 243: + case 245: return isContextSensitive(node.initializer); - case 141: - case 140: + case 143: + case 142: return isContextSensitiveFunctionLikeDeclaration(node); - case 170: + case 172: return isContextSensitive(node.expression); } return false; @@ -13958,7 +14297,9 @@ var ts; } return 0; } - source = getRegularTypeOfObjectLiteral(source); + if (target.flags & 49152) { + source = getRegularTypeOfObjectLiteral(source); + } } var saveErrorInfo = errorInfo; if (source.flags & 16384) { @@ -13996,7 +14337,7 @@ var ts; } else { if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { return result; } } @@ -14018,7 +14359,7 @@ var ts; var result; if (source.flags & 80896 && target.flags & 80896) { if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, false)) { + if (result = typeArgumentsRelatedTo(source, target, false)) { return result; } } @@ -14128,9 +14469,14 @@ var ts; } return result; } - function typesRelatedTo(sources, targets, reportErrors) { + function typeArgumentsRelatedTo(source, target, reportErrors) { + var sources = source.typeArguments || emptyArray; + var targets = target.typeArguments || emptyArray; + if (sources.length !== targets.length && relation === identityRelation) { + return 0; + } var result = -1; - for (var i = 0, len = sources.length; i < len; i++) { + for (var i = 0; i < targets.length; i++) { var related = isRelatedTo(sources[i], targets[i], reportErrors); if (!related) { return 0; @@ -14357,8 +14703,8 @@ var ts; return result; function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) { if (sourceSig && targetSig) { - var sourceDecl = source.symbol && ts.getDeclarationOfKind(source.symbol, 212); - var targetDecl = target.symbol && ts.getDeclarationOfKind(target.symbol, 212); + var sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol); + var targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol); if (!sourceDecl) { return -1; } @@ -14366,8 +14712,8 @@ var ts; var targetErasedSignature = getErasedSignature(targetSig); var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); - var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 212); - var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 212); + var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); + var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256; var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256; if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { @@ -14690,6 +15036,7 @@ var ts; regularType.constructSignatures = type.constructSignatures; regularType.stringIndexType = type.stringIndexType; regularType.numberIndexType = type.numberIndexType; + type.regularType = regularType; } return regularType; } @@ -14780,22 +15127,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 139: - case 138: + case 141: + case 140: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 136: + case 138: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 211: - case 141: - case 140: + case 213: case 143: - case 144: - case 171: - case 172: + case 142: + case 145: + case 146: + case 173: + case 174: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -14891,9 +15238,10 @@ var ts; } } else if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - var sourceTypes = source.typeArguments; - var targetTypes = target.typeArguments; - for (var i = 0; i < sourceTypes.length; i++) { + var sourceTypes = source.typeArguments || emptyArray; + var targetTypes = target.typeArguments || emptyArray; + var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; + for (var i = 0; i < count; i++) { inferFromTypes(sourceTypes[i], targetTypes[i]); } } @@ -15047,10 +15395,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 152: + case 154: return true; - case 67: - case 133: + case 69: + case 135: node = node.parent; continue; default: @@ -15090,12 +15438,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 55 && node.operatorToken.kind <= 66) { + if (node.operatorToken.kind >= 56 && node.operatorToken.kind <= 68) { var n = node.left; - while (n.kind === 170) { + while (n.kind === 172) { n = n.expression; } - if (n.kind === 67 && getResolvedSymbol(n) === symbol) { + if (n.kind === 69 && getResolvedSymbol(n) === symbol) { return true; } } @@ -15109,55 +15457,55 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 179: + case 181: return isAssignedInBinaryExpression(node); - case 209: - case 161: + case 211: + case 163: return isAssignedInVariableDeclaration(node); - case 159: - case 160: + case 161: case 162: - case 163: case 164: case 165: case 166: case 167: + case 168: case 169: - case 187: - case 170: - case 177: - case 173: - case 176: - case 174: + case 171: + case 189: + case 172: + case 179: case 175: case 178: - case 182: + case 176: + case 177: case 180: - case 183: - case 190: - case 191: + case 184: + case 182: + case 185: + case 192: case 193: - case 194: case 195: case 196: case 197: case 198: case 199: - case 202: - case 203: + case 200: + case 201: case 204: - case 239: - case 240: case 205: case 206: - case 207: + case 241: case 242: - case 231: - case 232: - case 236: - case 237: + case 207: + case 208: + case 209: + case 244: case 233: + case 234: case 238: + case 239: + case 235: + case 240: return ts.forEachChild(node, isAssignedIn); } return false; @@ -15172,34 +15520,34 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 194: + case 196: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 180: + case 182: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 179: + case 181: if (child === node.right) { - if (node.operatorToken.kind === 50) { + if (node.operatorToken.kind === 51) { narrowedType = narrowType(type, node.left, true); } - else if (node.operatorToken.kind === 51) { + else if (node.operatorToken.kind === 52) { narrowedType = narrowType(type, node.left, false); } } break; - case 246: - case 216: - case 211: - case 141: - case 140: + case 248: + case 218: + case 213: case 143: - case 144: case 142: + case 145: + case 146: + case 144: break loop; } if (narrowedType !== type) { @@ -15213,12 +15561,12 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 174 || expr.right.kind !== 9) { + if (expr.left.kind !== 176 || expr.right.kind !== 9) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 67 || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 69 || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; @@ -15264,7 +15612,7 @@ var ts; } } function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 67 || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 69 || getResolvedSymbol(expr.left) !== symbol) { return type; } var rightType = checkExpression(expr.right); @@ -15328,27 +15676,27 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 166: + case 168: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 170: + case 172: return narrowType(type, expr.expression, assumeTrue); - case 179: + case 181: var operator = expr.operatorToken.kind; if (operator === 32 || operator === 33) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 50) { + else if (operator === 51) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 51) { + else if (operator === 52) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 89) { + else if (operator === 91) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 177: - if (expr.operator === 48) { + case 179: + if (expr.operator === 49) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -15360,7 +15708,7 @@ var ts; var symbol = getResolvedSymbol(node); if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 172) { + if (container.kind === 174) { if (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); } @@ -15391,15 +15739,15 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 242) { + symbol.valueDeclaration.parent.kind === 244) { return; } var container = symbol.valueDeclaration; - while (container.kind !== 210) { + while (container.kind !== 212) { container = container.parent; } container = container.parent; - if (container.kind === 191) { + if (container.kind === 193) { container = container.parent; } var inFunction = isInsideFunction(node.parent, container); @@ -15417,7 +15765,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 139 || container.kind === 142) { + if (container.kind === 141 || container.kind === 144) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -15428,29 +15776,29 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 172) { + if (container.kind === 174) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 216: + case 218: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 215: + case 217: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 142: + case 144: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 139: - case 138: + case 141: + case 140: if (container.flags & 128) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 134: + case 136: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -15459,27 +15807,27 @@ var ts; } if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); - return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); + return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; } return anyType; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 136) { + if (n.kind === 138) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 166 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 168 && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 172) { + while (container && container.kind === 174) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -15505,7 +15853,7 @@ var ts; return unknownType; } if (!canUseSuperExpression) { - if (container && container.kind === 134) { + if (container && container.kind === 136) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -15516,7 +15864,7 @@ var ts; } return unknownType; } - if (container.kind === 142 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 144 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -15528,24 +15876,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 142; + return container.kind === 144; } else { if (container && ts.isClassLike(container.parent)) { if (container.flags & 128) { - return container.kind === 141 || - container.kind === 140 || - container.kind === 143 || - container.kind === 144; + return container.kind === 143 || + container.kind === 142 || + container.kind === 145 || + container.kind === 146; } else { - return container.kind === 141 || + return container.kind === 143 || + container.kind === 142 || + container.kind === 145 || + container.kind === 146 || + container.kind === 141 || container.kind === 140 || - container.kind === 143 || - container.kind === 144 || - container.kind === 139 || - container.kind === 138 || - container.kind === 142; + container.kind === 144; } } } @@ -15553,8 +15901,8 @@ var ts; } } function getContextuallyTypedParameterType(parameter) { - if (isFunctionExpressionOrArrowFunction(parameter.parent)) { - var func = parameter.parent; + var func = parameter.parent; + if (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) { if (isContextSensitive(func)) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { @@ -15579,14 +15927,14 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 136) { + if (declaration.kind === 138) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; } } if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name); + return getTypeFromBindingPattern(declaration.name, true); } } return undefined; @@ -15612,7 +15960,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 136 && node.parent.initializer === node) { + if (node.parent.kind === 138 && node.parent.initializer === node) { return true; } node = node.parent; @@ -15621,8 +15969,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 142 || - functionDecl.kind === 143 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 144))) { + functionDecl.kind === 144 || + functionDecl.kind === 145 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 146))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -15641,7 +15989,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 168) { + if (template.parent.kind === 170) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -15649,12 +15997,12 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 55 && operator <= 66) { + if (operator >= 56 && operator <= 68) { if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 51) { + else if (operator === 52) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = checkExpression(binaryExpression.left); @@ -15741,7 +16089,7 @@ var ts; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } function getContextualTypeForJsxExpression(expr) { - if (expr.parent.kind === 236) { + if (expr.parent.kind === 238) { var attrib = expr.parent; var attrsType = getJsxElementAttributesType(attrib.parent); if (!attrsType || isTypeAny(attrsType)) { @@ -15751,7 +16099,7 @@ var ts; return getTypeOfPropertyOfType(attrsType, attrib.name.text); } } - if (expr.kind === 237) { + if (expr.kind === 239) { return getJsxElementAttributesType(expr.parent); } return undefined; @@ -15769,38 +16117,38 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 209: - case 136: - case 139: + case 211: case 138: - case 161: + case 141: + case 140: + case 163: return getContextualTypeForInitializerExpression(node); - case 172: - case 202: + case 174: + case 204: return getContextualTypeForReturnExpression(node); - case 182: + case 184: return getContextualTypeForYieldOperand(parent); - case 166: - case 167: - return getContextualTypeForArgument(parent, node); + case 168: case 169: - case 187: + return getContextualTypeForArgument(parent, node); + case 171: + case 189: return getTypeFromTypeNode(parent.type); - case 179: + case 181: return getContextualTypeForBinaryOperand(node); - case 243: + case 245: return getContextualTypeForObjectLiteralElement(parent); - case 162: + case 164: return getContextualTypeForElementExpression(node); - case 180: + case 182: return getContextualTypeForConditionalOperand(node); - case 188: - ts.Debug.assert(parent.parent.kind === 181); + case 190: + ts.Debug.assert(parent.parent.kind === 183); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 170: + case 172: return getContextualType(parent); - case 238: - case 237: + case 240: + case 239: return getContextualTypeForJsxExpression(parent); } return undefined; @@ -15815,7 +16163,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 171 || node.kind === 172; + return node.kind === 173 || node.kind === 174; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -15823,7 +16171,7 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -15863,13 +16211,13 @@ var ts; } function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 179 && parent.operatorToken.kind === 55 && parent.left === node) { + if (parent.kind === 181 && parent.operatorToken.kind === 56 && parent.left === node) { return true; } - if (parent.kind === 243) { + if (parent.kind === 245) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 162) { + if (parent.kind === 164) { return isAssignmentTarget(parent); } return false; @@ -15878,17 +16226,18 @@ var ts; var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper); return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } + function hasDefaultValue(node) { + return (node.kind === 163 && !!node.initializer) || + (node.kind === 181 && node.operatorToken.kind === 56); + } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; - if (!elements.length) { - return createArrayType(undefinedType); - } var hasSpreadElement = false; var elementTypes = []; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 183) { + if (inDestructuringPattern && e.kind === 185) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -15900,18 +16249,41 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 183; + hasSpreadElement = hasSpreadElement || e.kind === 185; } if (!hasSpreadElement) { + if (inDestructuringPattern && elementTypes.length) { + var type = createNewTupleType(elementTypes); + type.pattern = node; + return type; + } var contextualType = getContextualType(node); - if (contextualType && contextualTypeIsTupleLikeType(contextualType) || inDestructuringPattern) { - return createTupleType(elementTypes); + if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { + var pattern = contextualType.pattern; + if (pattern && (pattern.kind === 162 || pattern.kind === 164)) { + var patternElements = pattern.elements; + for (var i = elementTypes.length; i < patternElements.length; i++) { + var patternElement = patternElements[i]; + if (hasDefaultValue(patternElement)) { + elementTypes.push(contextualType.elementTypes[i]); + } + else { + if (patternElement.kind !== 187) { + error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + } + elementTypes.push(unknownType); + } + } + } + if (elementTypes.length) { + return createTupleType(elementTypes); + } } } - return createArrayType(getUnionType(elementTypes)); + return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); } function isNumericName(name) { - return name.kind === 134 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 136 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); @@ -15936,30 +16308,49 @@ var ts; return links.resolvedType; } function checkObjectLiteral(node, contextualMapper) { - checkGrammarObjectLiteralExpression(node); + var inDestructuringPattern = isAssignmentTarget(node); + checkGrammarObjectLiteralExpression(node, inDestructuringPattern); var propertiesTable = {}; var propertiesArray = []; var contextualType = getContextualType(node); + var contextualTypeHasPattern = contextualType && contextualType.pattern && + (contextualType.pattern.kind === 161 || contextualType.pattern.kind === 165); var typeFlags = 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 243 || - memberDecl.kind === 244 || + if (memberDecl.kind === 245 || + memberDecl.kind === 246 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 243) { + if (memberDecl.kind === 245) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 141) { + else if (memberDecl.kind === 143) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 244); + ts.Debug.assert(memberDecl.kind === 246); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; var prop = createSymbol(4 | 67108864 | member.flags, member.name); + if (inDestructuringPattern) { + var isOptional = (memberDecl.kind === 245 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 246 && memberDecl.objectAssignmentInitializer); + if (isOptional) { + prop.flags |= 536870912; + } + } + else if (contextualTypeHasPattern) { + var impliedProp = getPropertyOfType(contextualType, member.name); + if (impliedProp) { + prop.flags |= impliedProp.flags & 536870912; + } + else if (!compilerOptions.suppressExcessPropertyErrors) { + error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); + } + } prop.declarations = member.declarations; prop.parent = member.parent; if (member.valueDeclaration) { @@ -15970,7 +16361,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 143 || memberDecl.kind === 144); + ts.Debug.assert(memberDecl.kind === 145 || memberDecl.kind === 146); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -15978,11 +16369,26 @@ var ts; } propertiesArray.push(member); } + if (contextualTypeHasPattern) { + for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) { + var prop = _c[_b]; + if (!ts.hasProperty(propertiesTable, prop.name)) { + if (!(prop.flags & 536870912)) { + error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + } + propertiesTable[prop.name] = prop; + propertiesArray.push(prop); + } + } + } var stringIndexType = getIndexType(0); var numberIndexType = getIndexType(1); var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576; result.flags |= 524288 | 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064); + if (inDestructuringPattern) { + result.pattern = node; + } return result; function getIndexType(kind) { if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { @@ -16011,7 +16417,7 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 67) { + if (lhs.kind === 69) { return lhs.text === rhs.text; } return lhs.right.text === rhs.right.text && @@ -16028,17 +16434,17 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 238: + case 240: checkJsxExpression(child); break; - case 231: + case 233: checkJsxElement(child); break; - case 232: + case 234: checkJsxSelfClosingElement(child); break; default: - ts.Debug.assert(child.kind === 234); + ts.Debug.assert(child.kind === 236); } } return jsxElementType || anyType; @@ -16047,7 +16453,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 133) { + if (tagName.kind === 135) { return false; } else { @@ -16148,12 +16554,14 @@ var ts; var valueSymbol = resolveJsxTagName(node); if (valueSymbol && valueSymbol !== unknownSymbol) { links.jsxFlags |= 4; - getSymbolLinks(valueSymbol).referenced = true; + if (valueSymbol.flags & 8388608) { + markAliasSymbolAsReferenced(valueSymbol); + } } return valueSymbol || unknownSymbol; } function resolveJsxTagName(node) { - if (node.tagName.kind === 67) { + if (node.tagName.kind === 69) { var tag = node.tagName; var sym = getResolvedSymbol(tag); return sym.exportSymbol || sym; @@ -16293,11 +16701,11 @@ var ts; var nameTable = {}; var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 236) { + if (node.attributes[i].kind === 238) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 237); + ts.Debug.assert(node.attributes[i].kind === 239); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -16323,7 +16731,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 139; + return s.valueDeclaration ? s.valueDeclaration.kind : 141; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; @@ -16331,11 +16739,11 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 93) { - var errorNode = node.kind === 164 ? + if (left.kind === 95) { + var errorNode = node.kind === 166 ? node.name : node.right; - if (getDeclarationKindFromSymbol(prop) !== 141) { + if (getDeclarationKindFromSymbol(prop) !== 143) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -16356,7 +16764,7 @@ var ts; } return true; } - if (left.kind === 93) { + if (left.kind === 95) { return true; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { @@ -16366,6 +16774,9 @@ var ts; if (flags & 128) { return true; } + if (type.flags & 33554432) { + type = getConstraintOfTypeParameter(type); + } if (!(getTargetType(type).flags & (1024 | 2048) && hasBaseType(type, enclosingClass))) { error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); return false; @@ -16390,18 +16801,18 @@ var ts; var prop = getPropertyOfType(apparentType, right.text); if (!prop) { if (right.text) { - error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type)); + error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type.flags & 33554432 ? apparentType : type)); } return unknownType; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32) { - checkClassPropertyAccess(node, left, type, prop); + checkClassPropertyAccess(node, left, apparentType, prop); } return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 164 + var left = node.kind === 166 ? node.expression : node.left; var type = checkExpression(left); @@ -16416,7 +16827,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 167 && node.parent.expression === node) { + if (node.parent.kind === 169 && 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); @@ -16475,6 +16886,12 @@ var ts; if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { return indexArgumentExpression.text; } + if (indexArgumentExpression.kind === 167 || indexArgumentExpression.kind === 166) { + var value = getConstantValue(indexArgumentExpression); + if (value !== undefined) { + return value.toString(); + } + } if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, false)) { var rightHandSideName = indexArgumentExpression.name.text; return ts.getPropertyNameForKnownSymbolName(rightHandSideName); @@ -16512,10 +16929,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 168) { + if (node.kind === 170) { checkExpression(node.template); } - else if (node.kind !== 137) { + else if (node.kind !== 139) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -16566,7 +16983,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 183) { + if (arg && arg.kind === 185) { return i; } } @@ -16578,11 +16995,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 168) { + if (node.kind === 170) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 181) { + if (tagExpression.template.kind === 183) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -16594,7 +17011,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 137) { + else if (node.kind === 139) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); @@ -16602,7 +17019,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 167); + ts.Debug.assert(callExpression.kind === 169); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -16655,7 +17072,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 185) { + if (arg === undefined || arg.kind !== 187) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -16702,7 +17119,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 185) { + if (arg === undefined || arg.kind !== 187) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -16721,16 +17138,16 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 168) { + if (node.kind === 170) { var template = node.template; args = [undefined]; - if (template.kind === 181) { + if (template.kind === 183) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 137) { + else if (node.kind === 139) { return undefined; } else { @@ -16739,18 +17156,21 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 137) { + if (node.kind === 139) { switch (node.parent.kind) { - case 212: - case 184: + case 214: + case 186: return 1; - case 139: - return 2; case 141: + return 2; case 143: - case 144: + case 145: + case 146: + if (languageVersion === 0) { + return 2; + } return signature.parameters.length >= 3 ? 3 : 2; - case 136: + case 138: return 3; } } @@ -16759,83 +17179,83 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - switch (node.kind) { - case 212: - case 184: + if (node.kind === 214) { + var classSymbol = getSymbolOfNode(node); + return getTypeOfSymbol(classSymbol); + } + if (node.kind === 138) { + node = node.parent; + if (node.kind === 144) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 136: - node = node.parent; - if (node.kind === 142) { - var classSymbol_1 = getSymbolOfNode(node); - return getTypeOfSymbol(classSymbol_1); - } - case 139: - case 141: - case 143: - case 144: - return getParentTypeOfClassElement(node); - default: - ts.Debug.fail("Unsupported decorator target."); - return unknownType; + } + } + if (node.kind === 141 || + node.kind === 143 || + node.kind === 145 || + node.kind === 146) { + return getParentTypeOfClassElement(node); } + ts.Debug.fail("Unsupported decorator target."); + return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - switch (node.kind) { - case 212: - ts.Debug.fail("Class decorators should not have a second synthetic argument."); - return unknownType; - case 136: - node = node.parent; - if (node.kind === 142) { - return anyType; - } - case 139: - case 141: - case 143: - case 144: - var element = node; - switch (element.name.kind) { - case 67: - case 8: - case 9: - return getStringLiteralType(element.name); - case 134: - var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 16777216)) { - return nameType; - } - else { - return stringType; - } - default: - ts.Debug.fail("Unsupported property name."); - return unknownType; - } - default: - ts.Debug.fail("Unsupported decorator target."); - return unknownType; + if (node.kind === 214) { + ts.Debug.fail("Class decorators should not have a second synthetic argument."); + return unknownType; + } + if (node.kind === 138) { + node = node.parent; + if (node.kind === 144) { + return anyType; + } + } + if (node.kind === 141 || + node.kind === 143 || + node.kind === 145 || + node.kind === 146) { + var element = node; + switch (element.name.kind) { + case 69: + case 8: + case 9: + return getStringLiteralType(element.name); + case 136: + var nameType = checkComputedPropertyName(element.name); + if (allConstituentTypesHaveKind(nameType, 16777216)) { + return nameType; + } + else { + return stringType; + } + default: + ts.Debug.fail("Unsupported property name."); + return unknownType; + } } + ts.Debug.fail("Unsupported decorator target."); + return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - switch (node.kind) { - case 212: - ts.Debug.fail("Class decorators should not have a third synthetic argument."); - return unknownType; - case 136: - return numberType; - case 139: - ts.Debug.fail("Property decorators should not have a third synthetic argument."); - return unknownType; - case 141: - case 143: - case 144: - var propertyType = getTypeOfNode(node); - return createTypedPropertyDescriptorType(propertyType); - default: - ts.Debug.fail("Unsupported decorator target."); - return unknownType; + if (node.kind === 214) { + ts.Debug.fail("Class decorators should not have a third synthetic argument."); + return unknownType; + } + if (node.kind === 138) { + return numberType; + } + if (node.kind === 141) { + ts.Debug.fail("Property decorators should not have a third synthetic argument."); + return unknownType; } + if (node.kind === 143 || + node.kind === 145 || + node.kind === 146) { + var propertyType = getTypeOfNode(node); + return createTypedPropertyDescriptorType(propertyType); + } + ts.Debug.fail("Unsupported decorator target."); + return unknownType; } function getEffectiveDecoratorArgumentType(node, argIndex) { if (argIndex === 0) { @@ -16851,26 +17271,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 137) { + if (node.kind === 139) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 168) { + else if (argIndex === 0 && node.kind === 170) { return globalTemplateStringsArrayType; } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 137 || - (argIndex === 0 && node.kind === 168)) { + if (node.kind === 139 || + (argIndex === 0 && node.kind === 170)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 137) { + if (node.kind === 139) { return node.expression; } - else if (argIndex === 0 && node.kind === 168) { + else if (argIndex === 0 && node.kind === 170) { return node.template; } else { @@ -16878,12 +17298,12 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 168; - var isDecorator = node.kind === 137; + var isTaggedTemplate = node.kind === 170; + var isDecorator = node.kind === 139; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; - if (node.expression.kind !== 93) { + if (node.expression.kind !== 95) { ts.forEach(typeArguments, checkSourceElement); } } @@ -17021,7 +17441,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 93) { + if (node.expression.kind === 95) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); @@ -17066,7 +17486,7 @@ var ts; if (expressionType === unknownType) { return resolveErrorCall(node); } - var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 212); + var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); if (valueDecl && valueDecl.flags & 256) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); return resolveErrorCall(node); @@ -17110,16 +17530,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 212: - case 184: + case 214: + case 186: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 136: + case 138: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 139: - return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; case 141: + return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; case 143: - case 144: + case 145: + case 146: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -17147,16 +17567,16 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 166) { + if (node.kind === 168) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 167) { + else if (node.kind === 169) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 168) { + else if (node.kind === 170) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 137) { + else if (node.kind === 139) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -17168,15 +17588,15 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 93) { + if (node.expression.kind === 95) { return voidType; } - if (node.kind === 167) { + if (node.kind === 169) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 142 && - declaration.kind !== 146 && - declaration.kind !== 151) { + declaration.kind !== 144 && + declaration.kind !== 148 && + declaration.kind !== 153) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } @@ -17217,10 +17637,22 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); } } + function assignBindingElementTypes(node) { + if (ts.isBindingPattern(node.name)) { + for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.kind !== 187) { + getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); + assignBindingElementTypes(element); + } + } + } + } function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { var links = getSymbolLinks(parameter); if (!links.type) { links.type = instantiateType(contextualType, mapper); + assignBindingElementTypes(parameter.valueDeclaration); } else if (isInferentialContext(mapper)) { inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); @@ -17241,7 +17673,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 190) { + if (func.body.kind !== 192) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -17345,7 +17777,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 206); + return (body.statements.length === 1) && (body.statements[0].kind === 208); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!produceDiagnostics) { @@ -17354,7 +17786,7 @@ var ts; if (returnType === voidType || isTypeAny(returnType)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 190) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 192) { return; } var bodyBlock = func.body; @@ -17367,9 +17799,9 @@ 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 !== 141 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 171) { + if (!hasGrammarError && node.kind === 173) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -17405,14 +17837,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 141 && node.kind !== 140) { + if (produceDiagnostics && node.kind !== 143 && node.kind !== 142) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; @@ -17429,7 +17861,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 190) { + if (node.body.kind === 192) { checkSourceElement(node.body); } else { @@ -17461,17 +17893,17 @@ var ts; } function isReferenceOrErrorExpression(n) { switch (n.kind) { - case 67: { + case 69: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 164: { + case 166: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; } - case 165: + case 167: return true; - case 170: + case 172: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -17479,12 +17911,12 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 67: - case 164: { + case 69: + case 166: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768) !== 0; } - case 165: { + case 167: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 9) { @@ -17494,7 +17926,7 @@ var ts; } return false; } - case 170: + case 172: return isConstVariableReference(n.expression); default: return false; @@ -17539,15 +17971,15 @@ var ts; switch (node.operator) { case 35: case 36: - case 49: + case 50: if (someConstituentTypeHasKind(operandType, 16777216)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 48: + case 49: return booleanType; - case 40: case 41: + case 42: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); @@ -17602,21 +18034,21 @@ var ts; function isConstEnumSymbol(symbol) { return (symbol.flags & 128) !== 0; } - function checkInstanceOfExpression(node, leftType, rightType) { + function checkInstanceOfExpression(left, right, leftType, rightType) { if (allConstituentTypesHaveKind(leftType, 16777726)) { - error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { - error(node.right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); + error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); } return booleanType; } - function checkInExpression(node, leftType, rightType) { + function checkInExpression(left, right, leftType, rightType) { if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 16777216)) { - error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); + error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 | 512)) { - error(node.right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; } @@ -17624,7 +18056,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 243 || p.kind === 244) { + if (p.kind === 245 || p.kind === 246) { var name_13 = p.name; var type = isTypeAny(sourceType) ? sourceType @@ -17632,7 +18064,12 @@ var ts; isNumericLiteralName(name_13.text) && getIndexTypeOfType(sourceType, 1) || getIndexTypeOfType(sourceType, 0); if (type) { - checkDestructuringAssignment(p.initializer || name_13, type); + if (p.kind === 246) { + checkDestructuringAssignment(p, type); + } + else { + checkDestructuringAssignment(p.initializer || name_13, type); + } } else { error(name_13, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_13)); @@ -17649,8 +18086,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 185) { - if (e.kind !== 183) { + if (e.kind !== 187) { + if (e.kind !== 185) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -17675,7 +18112,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 179 && restExpression.operatorToken.kind === 55) { + if (restExpression.kind === 181 && restExpression.operatorToken.kind === 56) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -17687,15 +18124,26 @@ var ts; } return sourceType; } - function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 179 && target.operatorToken.kind === 55) { + function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { + var target; + if (exprOrAssignment.kind === 246) { + var prop = exprOrAssignment; + if (prop.objectAssignmentInitializer) { + checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); + } + target = exprOrAssignment.name; + } + else { + target = exprOrAssignment; + } + if (target.kind === 181 && target.operatorToken.kind === 56) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 163) { + if (target.kind === 165) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 162) { + if (target.kind === 164) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -17708,33 +18156,38 @@ var ts; return sourceType; } function checkBinaryExpression(node, contextualMapper) { - var operator = node.operatorToken.kind; - if (operator === 55 && (node.left.kind === 163 || node.left.kind === 162)) { - return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); + return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node); + } + function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { + var operator = operatorToken.kind; + if (operator === 56 && (left.kind === 165 || left.kind === 164)) { + return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } - var leftType = checkExpression(node.left, contextualMapper); - var rightType = checkExpression(node.right, contextualMapper); + var leftType = checkExpression(left, contextualMapper); + var rightType = checkExpression(right, contextualMapper); switch (operator) { case 37: - case 58: case 38: case 59: - case 39: case 60: - case 36: - case 57: - case 42: + case 39: case 61: - case 43: + case 40: case 62: - case 44: + case 36: + case 58: + case 43: case 63: - case 46: + case 44: + case 64: + case 45: case 65: case 47: + case 67: + case 48: + case 68: + case 46: case 66: - case 45: - case 64: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -17742,19 +18195,19 @@ var ts; var suggestedOperator; if ((leftType.flags & 8) && (rightType.flags & 8) && - (suggestedOperator = getSuggestedBooleanOperator(node.operatorToken.kind)) !== undefined) { - error(node, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(node.operatorToken.kind), ts.tokenToString(suggestedOperator)); + (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { + error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); } else { - var leftOk = checkArithmeticOperandType(node.left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - var rightOk = checkArithmeticOperandType(node.right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); if (leftOk && rightOk) { checkAssignmentOperator(numberType); } } return numberType; case 35: - case 56: + case 57: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -17778,7 +18231,7 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 56) { + if (operator === 57) { checkAssignmentOperator(resultType); } return resultType; @@ -17797,23 +18250,23 @@ var ts; reportOperatorError(); } return booleanType; - case 89: - return checkInstanceOfExpression(node, leftType, rightType); - case 88: - return checkInExpression(node, leftType, rightType); - case 50: - return rightType; + case 91: + return checkInstanceOfExpression(left, right, leftType, rightType); + case 90: + return checkInExpression(left, right, leftType, rightType); case 51: + return rightType; + case 52: return getUnionType([leftType, rightType]); - case 55: + case 56: checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); case 24: return rightType; } function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216) ? node.left : - someConstituentTypeHasKind(rightType, 16777216) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216) ? left : + someConstituentTypeHasKind(rightType, 16777216) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -17823,29 +18276,29 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 46: - case 65: - return 51; case 47: - case 66: + case 67: + return 52; + case 48: + case 68: return 33; - case 45: - case 64: - return 50; + case 46: + case 66: + return 51; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 55 && operator <= 66) { - var ok = checkReferenceExpression(node.left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); + if (produceDiagnostics && operator >= 56 && operator <= 68) { + var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); if (ok) { - checkTypeAssignableTo(valueType, leftType, node.left, undefined); + checkTypeAssignableTo(valueType, leftType, left, undefined); } } } function reportOperatorError() { - error(node, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(node.operatorToken.kind), typeToString(leftType), typeToString(rightType)); + error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); } } function isYieldExpressionInClass(node) { @@ -17921,14 +18374,14 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 134) { + if (node.name.kind === 136) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 134) { + if (node.name.kind === 136) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -17951,7 +18404,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 133) { + if (node.kind === 135) { type = checkQualifiedName(node); } else { @@ -17959,9 +18412,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 164 && node.parent.expression === node) || - (node.parent.kind === 165 && node.parent.expression === node) || - ((node.kind === 67 || node.kind === 133) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 166 && node.parent.expression === node) || + (node.parent.kind === 167 && node.parent.expression === node) || + ((node.kind === 69 || node.kind === 135) && 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); } @@ -17974,78 +18427,78 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 67: + case 69: return checkIdentifier(node); - case 95: + case 97: return checkThisExpression(node); - case 93: + case 95: return checkSuperExpression(node); - case 91: + case 93: return nullType; - case 97: - case 82: + case 99: + case 84: return booleanType; case 8: return checkNumericLiteral(node); - case 181: + case 183: return checkTemplateExpression(node); case 9: case 11: return stringType; case 10: return globalRegExpType; - case 162: - return checkArrayLiteral(node, contextualMapper); - case 163: - return checkObjectLiteral(node, contextualMapper); case 164: - return checkPropertyAccessExpression(node); + return checkArrayLiteral(node, contextualMapper); case 165: - return checkIndexedAccess(node); + return checkObjectLiteral(node, contextualMapper); case 166: + return checkPropertyAccessExpression(node); case 167: - return checkCallExpression(node); + return checkIndexedAccess(node); case 168: - return checkTaggedTemplateExpression(node); + case 169: + return checkCallExpression(node); case 170: + return checkTaggedTemplateExpression(node); + case 172: return checkExpression(node.expression, contextualMapper); - case 184: + case 186: return checkClassExpression(node); - case 171: - case 172: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 173: case 174: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 176: return checkTypeOfExpression(node); - case 169: - case 187: + case 171: + case 189: return checkAssertion(node); - case 173: - return checkDeleteExpression(node); case 175: + return checkDeleteExpression(node); + case 177: return checkVoidExpression(node); - case 176: + case 178: return checkAwaitExpression(node); - case 177: + case 179: return checkPrefixUnaryExpression(node); - case 178: + case 180: return checkPostfixUnaryExpression(node); - case 179: + case 181: return checkBinaryExpression(node, contextualMapper); - case 180: + case 182: return checkConditionalExpression(node, contextualMapper); - case 183: - return checkSpreadElementExpression(node, contextualMapper); case 185: + return checkSpreadElementExpression(node, contextualMapper); + case 187: return undefinedType; - case 182: + case 184: return checkYieldExpression(node); - case 238: + case 240: return checkJsxExpression(node); - case 231: + case 233: return checkJsxElement(node); - case 232: + case 234: return checkJsxSelfClosingElement(node); - case 233: + case 235: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -18061,16 +18514,12 @@ var ts; } } function checkParameter(node) { - // Grammar checking - // 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). checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (node.flags & 112) { func = ts.getContainingFunction(node); - if (!(func.kind === 142 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 144 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -18085,15 +18534,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 141 || - node.kind === 211 || - node.kind === 171; + return node.kind === 143 || + node.kind === 213 || + node.kind === 173; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 67 && + if (param.name.kind === 69 && param.name.text === parameter.text) { return i; } @@ -18103,30 +18552,30 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { - case 172: - case 145: - case 211: - case 171: - case 150: - case 141: - case 140: + case 174: + case 147: + case 213: + case 173: + case 152: + case 143: + case 142: return node === node.parent.type; } return false; } function checkSignatureDeclaration(node) { - if (node.kind === 147) { + if (node.kind === 149) { checkGrammarIndexSignature(node); } - else if (node.kind === 150 || node.kind === 211 || node.kind === 151 || - node.kind === 145 || node.kind === 142 || - node.kind === 146) { + else if (node.kind === 152 || node.kind === 213 || node.kind === 153 || + node.kind === 147 || node.kind === 144 || + node.kind === 148) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 148) { + if (node.type.kind === 150) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -18145,19 +18594,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 159 || - param.name.kind === 160) { + if (param.name.kind === 161 || + param.name.kind === 162) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 67 && + if (element.name.kind === 69 && 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 === 160 || - element.name.kind === 159) { + else if (element.name.kind === 162 || + element.name.kind === 161) { checkBindingPattern(element.name); } } @@ -18181,10 +18630,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 146: + case 148: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 145: + case 147: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -18206,7 +18655,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 213) { + if (node.kind === 215) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -18221,7 +18670,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 128: + case 130: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -18229,7 +18678,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 126: + case 128: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -18269,7 +18718,7 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 166 && n.expression.kind === 93; + return n.kind === 168 && n.expression.kind === 95; } function containsSuperCallAsComputedPropertyName(n) { return n.name && containsSuperCall(n.name); @@ -18287,15 +18736,15 @@ var ts; return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 95) { + if (n.kind === 97) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 171 && n.kind !== 211) { + else if (n.kind !== 173 && n.kind !== 213) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 139 && + return n.kind === 141 && !(n.flags & 128) && !!n.initializer; } @@ -18315,7 +18764,7 @@ var ts; var superCallStatement; for (var _i = 0; _i < statements.length; _i++) { var statement = statements[_i]; - if (statement.kind === 193 && isSuperCallExpression(statement.expression)) { + if (statement.kind === 195 && isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; } @@ -18339,13 +18788,13 @@ var ts; function checkAccessorDeclaration(node) { if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 143) { + if (node.kind === 145) { 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 === 143 ? 144 : 143; + var otherKind = node.kind === 145 ? 146 : 145; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112) !== (otherAccessor.flags & 112))) { @@ -18430,9 +18879,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 213) { - ts.Debug.assert(signatureDeclarationNode.kind === 145 || signatureDeclarationNode.kind === 146); - var signatureKind = signatureDeclarationNode.kind === 145 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 215) { + ts.Debug.assert(signatureDeclarationNode.kind === 147 || signatureDeclarationNode.kind === 148); + var signatureKind = signatureDeclarationNode.kind === 147 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -18450,7 +18899,10 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 213 && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 215 && + n.parent.kind !== 214 && + n.parent.kind !== 186 && + ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; } @@ -18526,7 +18978,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 === 141 || node.kind === 140); + ts.Debug.assert(node.kind === 143 || node.kind === 142); 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); @@ -18558,11 +19010,11 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 213 || node.parent.kind === 153 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 215 || node.parent.kind === 155 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 211 || node.kind === 141 || node.kind === 140 || node.kind === 142) { + if (node.kind === 213 || node.kind === 143 || node.kind === 142 || node.kind === 144) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -18675,16 +19127,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 213: + case 215: return 2097152; - case 216: + case 218: return d.name.kind === 9 || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 212: - case 215: + case 214: + case 217: return 2097152 | 1048576; - case 219: + case 221: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -18695,7 +19147,8 @@ var ts; } } function checkNonThenableType(type, location, message) { - if (!(type.flags & 1) && isTypeAssignableTo(type, getGlobalThenableType())) { + type = getWidenedType(type); + if (!isTypeAny(type) && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -18707,15 +19160,6 @@ var ts; return type; } function getPromisedType(promise) { - // - // { // promise - // then( // thenFunction - // onfulfilled: ( // onfulfilledParameterType - // value: T // valueParameterType - // ) => any - // ): any; - // } - // if (promise.flags & 1) { return undefined; } @@ -18819,22 +19263,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 212: + case 214: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 136: + case 138: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 139: + case 141: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 141: case 143: - case 144: + case 145: + case 146: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -18843,9 +19287,9 @@ var ts; checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 149) { + if (node && node.kind === 151) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 149 ? 793056 : 1536; + var meaning = root.parent.kind === 151 ? 793056 : 1536; var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); if (rootSymbol && rootSymbol.flags & 8388608) { var aliasTarget = resolveAlias(rootSymbol); @@ -18857,19 +19301,19 @@ var ts; } function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 139: + case 141: checkTypeNodeAsExpression(node.type); break; - case 136: + case 138: checkTypeNodeAsExpression(node.type); break; - case 141: + case 143: checkTypeNodeAsExpression(node.type); break; - case 143: + case 145: checkTypeNodeAsExpression(node.type); break; - case 144: + case 146: checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } @@ -18892,24 +19336,24 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 212: + case 214: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 141: - checkParameterTypeAnnotationsAsExpressions(node); - case 144: case 143: - case 139: - case 136: + checkParameterTypeAnnotationsAsExpressions(node); + case 146: + case 145: + case 141: + case 138: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 136) { + if (node.kind === 138) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -18927,12 +19371,9 @@ var ts; checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { - if (!compilerOptions.experimentalAsyncFunctions) { - error(node, ts.Diagnostics.Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning); - } emitAwaiter = true; } - if (node.name && node.name.kind === 134) { + if (node.name && node.name.kind === 136) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -18967,11 +19408,11 @@ var ts; } } function checkBlock(node) { - if (node.kind === 190) { + if (node.kind === 192) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 217) { + if (ts.isFunctionBlock(node) || node.kind === 219) { checkFunctionAndClassExpressionBodies(node); } } @@ -18989,19 +19430,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 139 || - node.kind === 138 || - node.kind === 141 || + if (node.kind === 141 || node.kind === 140 || node.kind === 143 || - node.kind === 144) { + node.kind === 142 || + node.kind === 145 || + node.kind === 146) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 136 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 138 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -19015,7 +19456,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 67; + var isDeclaration_1 = node.kind !== 69; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -19036,7 +19477,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 67; + var isDeclaration_2 = node.kind !== 69; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -19049,22 +19490,19 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 216 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 218 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 246 && ts.isExternalModule(parent)) { + if (parent.kind === 248 && 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)); } } function checkVarDeclaredNamesNotShadowed(node) { - // - ScriptBody : StatementList - // It is a Syntax Error if any element of the LexicallyDeclaredNames of StatementList - // also occurs in the VarDeclaredNames of StatementList. if ((ts.getCombinedNodeFlags(node) & 49152) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 209 && !node.initializer) { + if (node.kind === 211 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -19074,15 +19512,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 210); - var container = varDeclList.parent.kind === 191 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212); + var container = varDeclList.parent.kind === 193 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 190 && ts.isFunctionLike(container.parent) || - container.kind === 217 || - container.kind === 216 || - container.kind === 246); + (container.kind === 192 && ts.isFunctionLike(container.parent) || + container.kind === 219 || + container.kind === 218 || + container.kind === 248); if (!namesShareScope) { var name_14 = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_14, name_14); @@ -19092,16 +19530,16 @@ var ts; } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 136) { + if (ts.getRootDeclaration(node).kind !== 138) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 67) { + if (n.kind === 69) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 136) { + if (referencedSymbol.valueDeclaration.kind === 138) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -19121,7 +19559,7 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 134) { + if (node.name.kind === 136) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -19130,7 +19568,7 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 136 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 138 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -19158,9 +19596,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 139 && node.kind !== 138) { + if (node.kind !== 141 && node.kind !== 140) { checkExportsOnMergedDeclarations(node); - if (node.kind === 209 || node.kind === 161) { + if (node.kind === 211 || node.kind === 163) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -19181,7 +19619,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 163) { + if (node.modifiers && node.parent.kind === 165) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -19214,12 +19652,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 210) { + if (node.initializer && node.initializer.kind === 212) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 210) { + if (node.initializer.kind === 212) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -19234,13 +19672,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 210) { + if (node.initializer.kind === 212) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 162 || varExpr.kind === 163) { + if (varExpr.kind === 164 || varExpr.kind === 165) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -19255,7 +19693,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 210) { + if (node.initializer.kind === 212) { 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); @@ -19265,7 +19703,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 162 || varExpr.kind === 163) { + if (varExpr.kind === 164 || varExpr.kind === 165) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { @@ -19427,7 +19865,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 143 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 144))); + return !!(node.kind === 145 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 146))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -19445,10 +19883,10 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 144) { + if (func.kind === 146) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 142) { + else if (func.kind === 144) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -19457,7 +19895,9 @@ var ts; if (ts.isAsyncFunctionLike(func)) { var promisedType = getPromisedType(returnType); var awaitedType = checkAwaitedType(exprType, node.expression, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); - checkTypeAssignableTo(awaitedType, promisedType, node.expression); + if (promisedType) { + checkTypeAssignableTo(awaitedType, promisedType, node.expression); + } } else { checkTypeAssignableTo(exprType, returnType, node.expression); @@ -19481,7 +19921,7 @@ var ts; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 240 && !hasDuplicateDefaultClause) { + if (clause.kind === 242 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -19493,7 +19933,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 239) { + if (produceDiagnostics && clause.kind === 241) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { @@ -19510,7 +19950,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 205 && current.label.text === node.label.text) { + if (current.kind === 207 && 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; @@ -19536,7 +19976,7 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 67) { + if (catchClause.variableDeclaration.name.kind !== 69) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -19604,7 +20044,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 134 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 136 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -19657,9 +20097,6 @@ var ts; grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); - if (getSymbolOfNode(node).flags & 64 && !ts.isInAmbientContext(node)) { - error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); - } ts.forEach(node.members, checkSourceElement); } function checkClassLikeDeclaration(node) { @@ -19674,6 +20111,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { @@ -19692,7 +20130,7 @@ var ts; } } } - checkTypeAssignableTo(type, baseType, node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); 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); @@ -19705,7 +20143,8 @@ var ts; } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { - ts.forEach(implementedTypeNodes, function (typeRefNode) { + for (var _b = 0; _b < implementedTypeNodes.length; _b++) { + var typeRefNode = implementedTypeNodes[_b]; if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } @@ -19715,14 +20154,14 @@ var ts; if (t !== unknownType) { var declaredType = (t.flags & 4096) ? t.target : t; if (declaredType.flags & (1024 | 2048)) { - checkTypeAssignableTo(type, t, node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); } else { error(typeRefNode, ts.Diagnostics.A_class_may_only_implement_another_class_or_interface); } } } - }); + } } if (produceDiagnostics) { checkIndexConstraints(type); @@ -19732,20 +20171,10 @@ var ts; function getTargetSymbol(s) { return s.flags & 16777216 ? getSymbolLinks(s).target : s; } + function getClassLikeDeclarationOfSymbol(symbol) { + return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; }); + } function checkKindsOfPropertyMemberOverrides(type, baseType) { - // TypeScript 1.0 spec (April 2014): 8.2.3 - // A derived class inherits all members from its base class it doesn't override. - // Inheritance means that a derived class implicitly contains all non - overridden members of the base class. - // Both public and private property members are inherited, but only public property members can be overridden. - // A property member in a derived class is said to override a property member in a base class - // when the derived class property member has the same name and kind(instance or static) - // as the base class property member. - // The type of an overriding property member must be assignable(section 3.8.4) - // to the type of the overridden property member, or otherwise a compile - time error occurs. - // Base class instance member functions can be overridden by derived class instance member functions, - // but not by other kinds of members. - // Base class instance member variables and accessors can be overridden by - // derived class instance member variables and accessors, but not by other kinds of members. var baseProperties = getPropertiesOfObjectType(baseType); for (var _i = 0; _i < baseProperties.length; _i++) { var baseProperty = baseProperties[_i]; @@ -19758,9 +20187,14 @@ var ts; ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); if (derived) { if (derived === base) { - var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 212); + var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 256 && (!derivedClassDecl || !(derivedClassDecl.flags & 256))) { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + if (derivedClassDecl.kind === 186) { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); + } + else { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + } } } else { @@ -19799,7 +20233,7 @@ var ts; } } function isAccessor(kind) { - return kind === 143 || kind === 144; + return kind === 145 || kind === 146; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -19836,7 +20270,7 @@ var ts; var ok = true; for (var _i = 0; _i < baseTypes.length; _i++) { var base = baseTypes[_i]; - var properties = getPropertiesOfObjectType(base); + var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); for (var _a = 0; _a < properties.length; _a++) { var prop = properties[_a]; if (!ts.hasProperty(seen, prop.name)) { @@ -19865,7 +20299,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 213); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 215); 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); @@ -19873,20 +20307,13 @@ var ts; } if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); if (checkInheritedPropertiesAreIdentical(type, node.name)) { - ts.forEach(getBaseTypes(type), function (baseType) { - checkTypeAssignableTo(type, baseType, node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); - }); - checkIndexConstraints(type); - } - } - if (symbol && symbol.declarations) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 212 && !ts.isInAmbientContext(declaration)) { - error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); - break; + for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) { + var baseType = _a[_i]; + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); } + checkIndexConstraints(type); } } } @@ -19914,10 +20341,15 @@ var ts; var autoValue = 0; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); - ts.forEach(node.members, function (member) { - if (member.name.kind !== 134 && isNumericLiteralName(member.name.text)) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.name.kind === 136) { + error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); + } + else if (isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } + var previousEnumMemberIsNonConstant = autoValue === undefined; var initializer = member.initializer; if (initializer) { autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); @@ -19925,10 +20357,13 @@ var ts; else if (ambient && !enumIsConst) { autoValue = undefined; } + else if (previousEnumMemberIsNonConstant) { + error(member.name, ts.Diagnostics.Enum_member_must_have_initializer); + } if (autoValue !== undefined) { getNodeLinks(member).enumMemberValue = autoValue++; } - }); + } nodeLinks.flags |= 8192; } function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { @@ -19939,7 +20374,10 @@ var ts; if (enumIsConst) { error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); } - else if (!ambient) { + else if (ambient) { + error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); + } + else { checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); } } @@ -19955,7 +20393,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 177: + case 179: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -19963,10 +20401,10 @@ var ts; switch (e.operator) { case 35: return value_1; case 36: return -value_1; - case 49: return ~value_1; + case 50: return ~value_1; } return undefined; - case 179: + case 181: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -19976,37 +20414,37 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 46: return left | right; - case 45: return left & right; - case 43: return left >> right; - case 44: return left >>> right; - case 42: return left << right; - case 47: return left ^ right; + case 47: return left | right; + case 46: return left & right; + case 44: return left >> right; + case 45: return left >>> right; + case 43: return left << right; + case 48: return left ^ right; case 37: return left * right; - case 38: return left / right; + case 39: return left / right; case 35: return left + right; case 36: return left - right; - case 39: return left % right; + case 40: return left % right; } return undefined; case 8: return +e.text; - case 170: + case 172: return evalConstant(e.expression); - case 67: - case 165: - case 164: + case 69: + case 167: + case 166: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; var propertyName; - if (e.kind === 67) { + if (e.kind === 69) { enumType_1 = currentType; propertyName = e.text; } else { var expression; - if (e.kind === 165) { + if (e.kind === 167) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -20020,10 +20458,10 @@ var ts; } var current = expression; while (current) { - if (current.kind === 67) { + if (current.kind === 69) { break; } - else if (current.kind === 164) { + else if (current.kind === 166) { current = current.expression; } else { @@ -20046,7 +20484,7 @@ var ts; if (member === propertyDecl) { return undefined; } - if (!isDefinedBefore(propertyDecl, member)) { + if (!isBlockScopedNameDeclaredBeforeUse(propertyDecl, member)) { reportError = false; error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; @@ -20060,7 +20498,7 @@ var ts; if (!produceDiagnostics) { return; } - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -20082,7 +20520,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 215) { + if (declaration.kind !== 217) { return false; } var enumDeclaration = declaration; @@ -20105,8 +20543,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 212 || - (declaration.kind === 211 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 214 || + (declaration.kind === 213 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -20157,7 +20595,7 @@ 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, 212); + var mergedClass = ts.getDeclarationOfKind(symbol, 214); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -20165,9 +20603,9 @@ var ts; } if (isAmbientExternalModule) { if (!isGlobalSourceFile(node.parent)) { - error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules); + error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); } - if (isExternalModuleNameRelative(node.name.text)) { + if (ts.isExternalModuleNameRelative(node.name.text)) { error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); } } @@ -20176,17 +20614,17 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 133) { + if (node.kind === 135) { node = node.left; } - else if (node.kind === 164) { + else if (node.kind === 166) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 67); + ts.Debug.assert(node.kind === 69); return node; } function checkExternalImportOrExportDeclaration(node) { @@ -20195,14 +20633,14 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 217 && node.parent.parent.name.kind === 9; - if (node.parent.kind !== 246 && !inAmbientExternalModule) { - error(moduleName, node.kind === 226 ? + var inAmbientExternalModule = node.parent.kind === 219 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 248 && !inAmbientExternalModule) { + error(moduleName, node.kind === 228 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; } - if (inAmbientExternalModule && isExternalModuleNameRelative(moduleName.text)) { + if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) { error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); return false; } @@ -20216,7 +20654,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 228 ? + var message = node.kind === 230 ? 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)); @@ -20242,7 +20680,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 222) { + if (importClause.namedBindings.kind === 224) { checkImportBinding(importClause.namedBindings); } else { @@ -20277,8 +20715,8 @@ var ts; } } else { - if (languageVersion >= 2 && !ts.isInAmbientContext(node)) { - grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead); + if (modulekind === 5 && !ts.isInAmbientContext(node)) { + grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } } @@ -20293,8 +20731,8 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 217 && node.parent.parent.name.kind === 9; - if (node.parent.kind !== 246 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 219 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 248 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -20307,7 +20745,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 246 && node.parent.kind !== 217 && node.parent.kind !== 216) { + if (node.parent.kind !== 248 && node.parent.kind !== 219 && node.parent.kind !== 218) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -20321,15 +20759,15 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 246 ? node.parent : node.parent.parent; - if (container.kind === 216 && container.name.kind === 67) { + var container = node.parent.kind === 248 ? node.parent : node.parent.parent; + if (container.kind === 218 && container.name.kind === 69) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 67) { + if (node.expression.kind === 69) { markExportAsReferenced(node); } else { @@ -20337,19 +20775,19 @@ var ts; } checkExternalModuleExports(container); if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (languageVersion >= 2) { - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + if (modulekind === 5) { + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead); } - else if (compilerOptions.module === 4) { + else if (modulekind === 4) { grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); } } } function getModuleStatements(node) { - if (node.kind === 246) { + if (node.kind === 248) { return node.statements; } - if (node.kind === 216 && node.body.kind === 217) { + if (node.kind === 218 && node.body.kind === 219) { return node.body.statements; } return emptyArray; @@ -20386,183 +20824,182 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 216: - case 212: + case 218: + case 214: + case 215: case 213: - case 211: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 135: + case 137: return checkTypeParameter(node); - case 136: - return checkParameter(node); - case 139: case 138: + return checkParameter(node); + case 141: + case 140: return checkPropertyDeclaration(node); - case 150: - case 151: - case 145: - case 146: - return checkSignatureDeclaration(node); + case 152: + case 153: case 147: + case 148: + return checkSignatureDeclaration(node); + case 149: return checkSignatureDeclaration(node); - case 141: - case 140: - return checkMethodDeclaration(node); - case 142: - return checkConstructorDeclaration(node); case 143: + case 142: + return checkMethodDeclaration(node); case 144: + return checkConstructorDeclaration(node); + case 145: + case 146: return checkAccessorDeclaration(node); - case 149: + case 151: return checkTypeReferenceNode(node); - case 148: + case 150: return checkTypePredicate(node); - case 152: - return checkTypeQuery(node); - case 153: - return checkTypeLiteral(node); case 154: - return checkArrayType(node); + return checkTypeQuery(node); case 155: - return checkTupleType(node); + return checkTypeLiteral(node); case 156: + return checkArrayType(node); case 157: - return checkUnionOrIntersectionType(node); + return checkTupleType(node); case 158: + case 159: + return checkUnionOrIntersectionType(node); + case 160: return checkSourceElement(node.type); - case 211: + case 213: return checkFunctionDeclaration(node); - case 190: - case 217: + case 192: + case 219: return checkBlock(node); - case 191: - return checkVariableStatement(node); case 193: - return checkExpressionStatement(node); - case 194: - return checkIfStatement(node); + return checkVariableStatement(node); case 195: - return checkDoStatement(node); + return checkExpressionStatement(node); case 196: - return checkWhileStatement(node); + return checkIfStatement(node); case 197: - return checkForStatement(node); + return checkDoStatement(node); case 198: - return checkForInStatement(node); + return checkWhileStatement(node); case 199: - return checkForOfStatement(node); + return checkForStatement(node); case 200: + return checkForInStatement(node); case 201: - return checkBreakOrContinueStatement(node); + return checkForOfStatement(node); case 202: - return checkReturnStatement(node); case 203: - return checkWithStatement(node); + return checkBreakOrContinueStatement(node); case 204: - return checkSwitchStatement(node); + return checkReturnStatement(node); case 205: - return checkLabeledStatement(node); + return checkWithStatement(node); case 206: - return checkThrowStatement(node); + return checkSwitchStatement(node); case 207: - return checkTryStatement(node); + return checkLabeledStatement(node); + case 208: + return checkThrowStatement(node); case 209: + return checkTryStatement(node); + case 211: return checkVariableDeclaration(node); - case 161: + case 163: return checkBindingElement(node); - case 212: + case 214: return checkClassDeclaration(node); - case 213: + case 215: return checkInterfaceDeclaration(node); - case 214: + case 216: return checkTypeAliasDeclaration(node); - case 215: + case 217: return checkEnumDeclaration(node); - case 216: + case 218: return checkModuleDeclaration(node); - case 220: + case 222: return checkImportDeclaration(node); - case 219: + case 221: return checkImportEqualsDeclaration(node); - case 226: + case 228: return checkExportDeclaration(node); - case 225: + case 227: return checkExportAssignment(node); - case 192: + case 194: checkGrammarStatementInAmbientContext(node); return; - case 208: + case 210: checkGrammarStatementInAmbientContext(node); return; - case 229: + case 231: return checkMissingDeclaration(node); } } function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 171: - case 172: + case 173: + case 174: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 184: + case 186: ts.forEach(node.members, checkSourceElement); + ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; - case 141: - case 140: + case 143: + case 142: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 142: - case 143: case 144: - case 211: + case 145: + case 146: + case 213: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 203: + case 205: checkFunctionAndClassExpressionBodies(node.expression); break; - case 137: - case 136: case 139: case 138: - case 159: - case 160: + case 141: + case 140: case 161: case 162: case 163: - case 243: case 164: case 165: + case 245: case 166: case 167: case 168: - case 181: - case 188: case 169: - case 187: case 170: - case 174: - case 175: + case 183: + case 190: + case 171: + case 189: + case 172: case 176: - case 173: case 177: case 178: + case 175: case 179: case 180: - case 183: + case 181: case 182: - case 190: - case 217: - case 191: + case 185: + case 184: + case 192: + case 219: case 193: - case 194: case 195: case 196: case 197: @@ -20571,29 +21008,31 @@ var ts; case 200: case 201: case 202: + case 203: case 204: - case 218: - case 239: - case 240: - case 205: case 206: - case 207: + case 220: + case 241: case 242: + case 207: + case 208: case 209: - case 210: + case 244: + case 211: case 212: - case 241: - case 186: - case 215: - case 245: - case 225: - case 246: - case 238: - case 231: - case 232: - case 236: - case 237: + case 214: + case 243: + case 188: + case 217: + case 247: + case 227: + case 248: + case 240: case 233: + case 234: + case 238: + case 239: + case 235: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -20671,7 +21110,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 203 && node.parent.statement === node) { + if (node.parent.kind === 205 && node.parent.statement === node) { return true; } node = node.parent; @@ -20693,28 +21132,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 246: + case 248: if (!ts.isExternalModule(location)) { break; } - case 216: + case 218: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 215: + case 217: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 184: + case 186: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 212: - case 213: + case 214: + case 215: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 171: + case 173: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -20747,42 +21186,42 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 67 && + return name.kind === 69 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 135: - case 212: - case 213: + case 137: case 214: case 215: + case 216: + case 217: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 133) { + while (node.parent && node.parent.kind === 135) { node = node.parent; } - return node.parent && node.parent.kind === 149; + return node.parent && node.parent.kind === 151; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 164) { + while (node.parent && node.parent.kind === 166) { node = node.parent; } - return node.parent && node.parent.kind === 186; + return node.parent && node.parent.kind === 188; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 133) { + while (nodeOnRightSide.parent.kind === 135) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 219) { + if (nodeOnRightSide.parent.kind === 221) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 225) { + if (nodeOnRightSide.parent.kind === 227) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -20794,10 +21233,10 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 225) { + if (entityName.parent.kind === 227) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 164) { + if (entityName.kind !== 166) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -20806,31 +21245,40 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 186 ? 793056 : 1536; + var meaning = 0; + if (entityName.parent.kind === 188) { + meaning = 793056; + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + meaning |= 107455; + } + } + else { + meaning = 1536; + } meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 233) || - (entityName.parent.kind === 232) || - (entityName.parent.kind === 235)) { + else if ((entityName.parent.kind === 235) || + (entityName.parent.kind === 234) || + (entityName.parent.kind === 237)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 67) { + if (entityName.kind === 69) { var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 164) { + else if (entityName.kind === 166) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 133) { + else if (entityName.kind === 135) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -20839,14 +21287,14 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 149 ? 793056 : 1536; + var meaning = entityName.parent.kind === 151 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 236) { + else if (entityName.parent.kind === 238) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 148) { + if (entityName.parent.kind === 150) { return resolveEntityName(entityName, 1); } return undefined; @@ -20858,14 +21306,14 @@ var ts; if (ts.isDeclarationName(node)) { return getSymbolOfNode(node.parent); } - if (node.kind === 67) { + if (node.kind === 69) { if (isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 225 + return node.parent.kind === 227 ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } - else if (node.parent.kind === 161 && - node.parent.parent.kind === 159 && + else if (node.parent.kind === 163 && + node.parent.parent.kind === 161 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -20875,29 +21323,29 @@ var ts; } } switch (node.kind) { - case 67: - case 164: - case 133: + case 69: + case 166: + case 135: return getSymbolOfEntityNameOrPropertyAccessExpression(node); + case 97: case 95: - case 93: - var type = checkExpression(node); + var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 119: + case 121: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 142) { + if (constructorDeclaration && constructorDeclaration.kind === 144) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 220 || node.parent.kind === 226) && + ((node.parent.kind === 222 || node.parent.kind === 228) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 165 && node.parent.argumentExpression === node) { + if (node.parent.kind === 167 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -20911,7 +21359,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 244) { + if (location && location.kind === 246) { return resolveEntityName(location.name, 107455); } return undefined; @@ -21011,11 +21459,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 246) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 248) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 216 || n.kind === 215) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 218 || n.kind === 217) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -21028,11 +21476,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 190: - case 218: - case 197: - case 198: + case 192: + case 220: case 199: + case 200: + case 201: return true; } return false; @@ -21058,22 +21506,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 219: case 221: - case 222: + case 223: case 224: - case 228: - return isAliasResolvedToValue(getSymbolOfNode(node)); case 226: + case 230: + return isAliasResolvedToValue(getSymbolOfNode(node)); + case 228: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 225: - return node.expression && node.expression.kind === 67 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 227: + return node.expression && node.expression.kind === 69 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 246 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 248 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -21121,7 +21569,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 245) { + if (node.kind === 247) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -21207,21 +21655,6 @@ var ts; var symbol = getReferencedValueSymbol(reference); return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; } - function getBlockScopedVariableId(n) { - ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 161 || (n.parent.kind === 209 && 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 !== 242; - if (isLetOrConst) { - getSymbolLinks(symbol); - return symbol.id; - } - return undefined; - } function instantiateSingleCallFunctionType(functionType, typeArguments) { if (functionType === unknownType) { return unknownType; @@ -21253,7 +21686,6 @@ var ts; isEntityNameVisible: isEntityNameVisible, getConstantValue: getConstantValue, collectLinkedAliases: collectLinkedAliases, - getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, isOptionalParameter: isOptionalParameter @@ -21334,10 +21766,7 @@ var ts; if (!ts.nodeCanBeDecorated(node)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } - else if (languageVersion < 1) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (node.kind === 143 || node.kind === 144) { + else if (node.kind === 145 || node.kind === 146) { 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); @@ -21347,38 +21776,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 143: + case 145: + case 146: case 144: - case 142: - case 139: - case 138: case 141: case 140: - case 147: - case 216: - case 220: - case 219: - case 226: - case 225: - case 136: + case 143: + case 142: + case 149: + case 218: + case 222: + case 221: + case 228: + case 227: + case 138: break; - case 211: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 116) && - node.parent.kind !== 217 && node.parent.kind !== 246) { + case 213: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118) && + node.parent.kind !== 219 && node.parent.kind !== 248) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 212: - case 213: - case 191: case 214: - if (node.modifiers && node.parent.kind !== 217 && node.parent.kind !== 246) { + case 215: + case 193: + case 216: + if (node.modifiers && node.parent.kind !== 219 && node.parent.kind !== 248) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 215: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 72) && - node.parent.kind !== 217 && node.parent.kind !== 246) { + case 217: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74) && + node.parent.kind !== 219 && node.parent.kind !== 248) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -21393,14 +21822,14 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { + case 112: + case 111: case 110: - case 109: - case 108: var text = void 0; - if (modifier.kind === 110) { + if (modifier.kind === 112) { text = "public"; } - else if (modifier.kind === 109) { + else if (modifier.kind === 111) { text = "protected"; lastProtected = modifier; } @@ -21417,11 +21846,11 @@ var ts; else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 217 || node.parent.kind === 246) { + else if (node.parent.kind === 219 || node.parent.kind === 248) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 256) { - if (modifier.kind === 108) { + if (modifier.kind === 110) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -21430,17 +21859,17 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 111: + case 113: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 217 || node.parent.kind === 246) { + else if (node.parent.kind === 219 || node.parent.kind === 248) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 136) { + else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 256) { @@ -21449,7 +21878,7 @@ var ts; flags |= 128; lastStatic = modifier; break; - case 80: + case 82: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -21462,42 +21891,42 @@ var ts; else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 214) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 136) { + else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 120: + case 122: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 214) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 136) { + else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 217) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; - case 113: + case 115: if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 212) { - if (node.kind !== 141) { + if (node.kind !== 214) { + if (node.kind !== 143) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 212 && node.parent.flags & 256)) { + if (!(node.parent.kind === 214 && node.parent.flags & 256)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 128) { @@ -21509,14 +21938,14 @@ var ts; } flags |= 256; break; - case 116: + case 118: if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 136) { + else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 512; @@ -21524,7 +21953,7 @@ var ts; break; } } - if (node.kind === 142) { + if (node.kind === 144) { if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -21542,10 +21971,10 @@ var ts; } return; } - else if ((node.kind === 220 || node.kind === 219) && flags & 2) { + else if ((node.kind === 222 || node.kind === 221) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 136 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 138 && (flags & 112) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 512) { @@ -21557,10 +21986,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 141: - case 211: - case 171: - case 172: + case 143: + case 213: + case 173: + case 174: if (!node.asteriskToken) { return false; } @@ -21625,7 +22054,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 172) { + if (node.kind === 174) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -21660,7 +22089,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 !== 128 && parameter.type.kind !== 126) { + if (parameter.type.kind !== 130 && parameter.type.kind !== 128) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -21692,7 +22121,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < args.length; _i++) { var arg = args[_i]; - if (arg.kind === 185) { + if (arg.kind === 187) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -21719,7 +22148,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 81) { + if (heritageClause.token === 83) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -21732,7 +22161,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 104); + ts.Debug.assert(heritageClause.token === 106); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -21747,14 +22176,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 81) { + if (heritageClause.token === 83) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 104); + ts.Debug.assert(heritageClause.token === 106); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -21763,19 +22192,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 134) { + if (node.kind !== 136) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 179 && computedPropertyName.expression.operatorToken.kind === 24) { + if (computedPropertyName.expression.kind === 181 && computedPropertyName.expression.operatorToken.kind === 24) { 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 === 211 || - node.kind === 171 || - node.kind === 141); + ts.Debug.assert(node.kind === 213 || + node.kind === 173 || + node.kind === 143); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -21792,7 +22221,7 @@ var ts; return grammarErrorOnNode(questionToken, message); } } - function checkGrammarObjectLiteralExpression(node) { + function checkGrammarObjectLiteralExpression(node, inDestructuring) { var seen = {}; var Property = 1; var GetAccessor = 2; @@ -21801,26 +22230,29 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_16 = prop.name; - if (prop.kind === 185 || - name_16.kind === 134) { + if (prop.kind === 187 || + name_16.kind === 136) { checkGrammarComputedPropertyName(name_16); continue; } + if (prop.kind === 246 && !inDestructuring && prop.objectAssignmentInitializer) { + return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); + } var currentKind = void 0; - if (prop.kind === 243 || prop.kind === 244) { + if (prop.kind === 245 || prop.kind === 246) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_16.kind === 8) { checkGrammarNumericLiteral(name_16); } currentKind = Property; } - else if (prop.kind === 141) { + else if (prop.kind === 143) { currentKind = Property; } - else if (prop.kind === 143) { + else if (prop.kind === 145) { currentKind = GetAccessor; } - else if (prop.kind === 144) { + else if (prop.kind === 146) { currentKind = SetAccesor; } else { @@ -21852,7 +22284,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 237) { + if (attr.kind === 239) { continue; } var jsxAttr = attr; @@ -21864,7 +22296,7 @@ var ts; return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 238 && !initializer.expression) { + if (initializer && initializer.kind === 240 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -21873,24 +22305,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 210) { + if (forInOrOfStatement.initializer.kind === 212) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 198 + var diagnostic = forInOrOfStatement.kind === 200 ? 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 === 198 + var diagnostic = forInOrOfStatement.kind === 200 ? 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 === 198 + var diagnostic = forInOrOfStatement.kind === 200 ? 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); @@ -21913,10 +22345,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 143 && accessor.parameters.length) { + else if (kind === 145 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 144) { + else if (kind === 146) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -21941,7 +22373,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 134 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 136 && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -21951,7 +22383,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 163) { + if (node.parent.kind === 165) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -21970,22 +22402,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 === 213) { + else if (node.parent.kind === 215) { 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 === 153) { + else if (node.parent.kind === 155) { 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 199: + case 200: + case 201: case 197: case 198: - case 199: - case 195: - case 196: return true; - case 205: + case 207: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -21997,9 +22429,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 205: + case 207: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 200 + var isMisplacedContinueLabel = node.kind === 202 && !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); @@ -22007,8 +22439,8 @@ var ts; return false; } break; - case 204: - if (node.kind === 201 && !node.label) { + case 206: + if (node.kind === 203 && !node.label) { return false; } break; @@ -22021,13 +22453,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 201 + var message = node.kind === 203 ? 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 === 201 + var message = node.kind === 203 ? 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); @@ -22039,7 +22471,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 === 160 || node.name.kind === 159) { + if (node.name.kind === 162 || node.name.kind === 161) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -22048,7 +22480,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 198 && node.parent.parent.kind !== 199) { + if (node.parent.parent.kind !== 200 && node.parent.parent.kind !== 201) { if (ts.isInAmbientContext(node)) { if (node.initializer) { var equalsTokenLength = "=".length; @@ -22068,7 +22500,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 67) { + if (name.kind === 69) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -22077,7 +22509,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 185) { + if (element.kind !== 187) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -22094,15 +22526,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 194: - case 195: case 196: - case 203: case 197: case 198: + case 205: case 199: + case 200: + case 201: return false; - case 205: + case 207: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -22118,7 +22550,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 177) { + if (expression.kind === 179) { var unaryExpression = expression; if (unaryExpression.operator === 35 || unaryExpression.operator === 36) { expression = unaryExpression.operand; @@ -22129,32 +22561,6 @@ var ts; } return false; } - function checkGrammarEnumDeclaration(enumDecl) { - var enumIsConst = (enumDecl.flags & 32768) !== 0; - var hasError = false; - if (!enumIsConst) { - var inConstantEnumMemberSection = true; - var inAmbientContext = ts.isInAmbientContext(enumDecl); - for (var _i = 0, _a = enumDecl.members; _i < _a.length; _i++) { - var node = _a[_i]; - if (node.name.kind === 134) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); - } - else if (inAmbientContext) { - if (node.initializer && !isIntegerLiteral(node.initializer)) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers) || hasError; - } - } - else if (node.initializer) { - inConstantEnumMemberSection = isIntegerLiteral(node.initializer); - } - else if (!inConstantEnumMemberSection) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Enum_member_must_have_initializer) || hasError; - } - } - } - return hasError; - } function hasParseDiagnostics(sourceFile) { return sourceFile.parseDiagnostics.length > 0; } @@ -22180,7 +22586,7 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 67 && + return node.kind === 69 && (node.text === "eval" || node.text === "arguments"); } function checkGrammarConstructorTypeParameters(node) { @@ -22200,12 +22606,12 @@ var ts; return true; } } - else if (node.parent.kind === 213) { + else if (node.parent.kind === 215) { 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 === 153) { + else if (node.parent.kind === 155) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -22215,11 +22621,11 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 213 || - node.kind === 220 || - node.kind === 219 || - node.kind === 226 || - node.kind === 225 || + if (node.kind === 215 || + node.kind === 222 || + node.kind === 221 || + node.kind === 228 || + node.kind === 227 || (node.flags & 2) || (node.flags & (1 | 1024))) { return false; @@ -22229,7 +22635,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 === 191) { + if (ts.isDeclaration(decl) || decl.kind === 193) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -22248,7 +22654,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 === 190 || node.parent.kind === 217 || node.parent.kind === 246) { + if (node.parent.kind === 192 || node.parent.kind === 219 || node.parent.kind === 248) { 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); @@ -22274,7 +22680,6 @@ var ts; } ts.createTypeChecker = createTypeChecker; })(ts || (ts = {})); -/// var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, targetSourceFile) { @@ -22296,6 +22701,7 @@ var ts; var enclosingDeclaration; var currentSourceFile; var reportedDeclarationError = false; + var errorNameNode; var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var moduleElementDeclarationEmitInfo = []; @@ -22321,7 +22727,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 220); + ts.Debug.assert(aliasEmitInfo.node.kind === 222); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -22372,6 +22778,7 @@ var ts; function createAndSetNewTextWriterWithSymbolWriter() { var writer = ts.createTextWriter(newLine); writer.trackSymbol = trackSymbol; + writer.reportInaccessibleThisError = reportInaccessibleThisError; writer.writeKeyword = writer.write; writer.writeOperator = writer.write; writer.writePunctuation = writer.write; @@ -22394,10 +22801,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 209) { + if (declaration.kind === 211) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 223 || declaration.kind === 224 || declaration.kind === 221) { + else if (declaration.kind === 225 || declaration.kind === 226 || declaration.kind === 223) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -22408,7 +22815,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 220) { + if (moduleElementEmitInfo.node.kind === 222) { moduleElementEmitInfo.isVisible = true; } else { @@ -22416,12 +22823,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 216) { + if (nodeToCheck.kind === 218) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 216) { + if (nodeToCheck.kind === 218) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -22453,6 +22860,11 @@ var ts; function trackSymbol(symbol, enclosingDeclaration, meaning) { handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); } + function reportInaccessibleThisError() { + if (errorNameNode) { + diagnostics.push(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode))); + } + } function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); @@ -22460,7 +22872,9 @@ var ts; emitType(type); } else { + errorNameNode = declaration.name; resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2, writer); + errorNameNode = undefined; } } function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) { @@ -22470,7 +22884,9 @@ var ts; emitType(signature.type); } else { + errorNameNode = signature.name; resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2, writer); + errorNameNode = undefined; } } function emitLines(nodes) { @@ -22508,62 +22924,63 @@ var ts; } function emitType(type) { switch (type.kind) { - case 115: + case 117: + case 130: case 128: - case 126: - case 118: - case 129: - case 101: + case 120: + case 131: + case 103: + case 97: case 9: return writeTextOfNode(currentSourceFile, type); - case 186: + case 188: return emitExpressionWithTypeArguments(type); - case 149: + case 151: return emitTypeReference(type); - case 152: - return emitTypeQuery(type); case 154: + return emitTypeQuery(type); + case 156: return emitArrayType(type); - case 155: + case 157: return emitTupleType(type); - case 156: + case 158: return emitUnionType(type); - case 157: + case 159: return emitIntersectionType(type); - case 158: + case 160: return emitParenType(type); - case 150: - case 151: - return emitSignatureDeclarationWithJsDocComments(type); + case 152: case 153: + return emitSignatureDeclarationWithJsDocComments(type); + case 155: return emitTypeLiteral(type); - case 67: + case 69: return emitEntityName(type); - case 133: + case 135: return emitEntityName(type); - case 148: + case 150: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 67) { + if (entityName.kind === 69) { writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 133 ? entityName.left : entityName.expression; - var right = entityName.kind === 133 ? entityName.right : entityName.name; + var left = entityName.kind === 135 ? entityName.left : entityName.expression; + var right = entityName.kind === 135 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 219 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 221 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 67 || node.expression.kind === 164); + ts.Debug.assert(node.expression.kind === 69 || node.expression.kind === 166); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -22639,7 +23056,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 67) { + if (node.expression.kind === 69) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -22657,7 +23074,7 @@ var ts; } write(";"); writeLine(); - if (node.expression.kind === 67) { + if (node.expression.kind === 69) { var nodes = resolver.collectLinkedAliases(node.expression); writeAsynchronousModuleElements(nodes); } @@ -22675,10 +23092,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 219 || - (node.parent.kind === 246 && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 221 || + (node.parent.kind === 248 && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 246) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 248) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -22687,7 +23104,7 @@ var ts; }); } else { - if (node.kind === 220) { + if (node.kind === 222) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -22705,23 +23122,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 211: + case 213: return writeFunctionDeclaration(node); - case 191: + case 193: return writeVariableStatement(node); - case 213: + case 215: return writeInterfaceDeclaration(node); - case 212: - return writeClassDeclaration(node); case 214: + return writeClassDeclaration(node); + case 216: return writeTypeAliasDeclaration(node); - case 215: + case 217: return writeEnumDeclaration(node); - case 216: + case 218: return writeModuleDeclaration(node); - case 219: + case 221: return writeImportEqualsDeclaration(node); - case 220: + case 222: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -22735,7 +23152,7 @@ var ts; if (node.flags & 1024) { write("default "); } - else if (node.kind !== 213) { + else if (node.kind !== 215) { write("declare "); } } @@ -22782,7 +23199,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 222) { + if (namedBindings.kind === 224) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -22808,7 +23225,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 222) { + if (node.importClause.namedBindings.kind === 224) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -22864,7 +23281,7 @@ var ts; write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 217) { + while (node.body.kind !== 219) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -22929,7 +23346,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 141 && (node.parent.flags & 32); + return node.parent.kind === 143 && (node.parent.flags & 32); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -22939,15 +23356,15 @@ var ts; writeTextOfNode(currentSourceFile, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 150 || - node.parent.kind === 151 || - (node.parent.parent && node.parent.parent.kind === 153)) { - ts.Debug.assert(node.parent.kind === 141 || - node.parent.kind === 140 || - node.parent.kind === 150 || - node.parent.kind === 151 || - node.parent.kind === 145 || - node.parent.kind === 146); + if (node.parent.kind === 152 || + node.parent.kind === 153 || + (node.parent.parent && node.parent.parent.kind === 155)) { + ts.Debug.assert(node.parent.kind === 143 || + node.parent.kind === 142 || + node.parent.kind === 152 || + node.parent.kind === 153 || + node.parent.kind === 147 || + node.parent.kind === 148); emitType(node.constraint); } else { @@ -22957,31 +23374,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 212: + case 214: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 213: + case 215: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 146: + case 148: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 145: + case 147: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 141: - case 140: + case 143: + case 142: 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 === 212) { + else if (node.parent.parent.kind === 214) { 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 211: + case 213: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -23009,12 +23426,12 @@ var ts; if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } - else if (!isImplementsList && node.expression.kind === 91) { + else if (!isImplementsList && node.expression.kind === 93) { write("null"); } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 212) { + if (node.parent.parent.kind === 214) { 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; @@ -23094,16 +23511,16 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 209 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 211 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 139 || node.kind === 138) && ts.hasQuestionToken(node)) { + if ((node.kind === 141 || node.kind === 140) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 139 || node.kind === 138) && node.parent.kind === 153) { + if ((node.kind === 141 || node.kind === 140) && node.parent.kind === 155) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32)) { @@ -23112,14 +23529,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 209) { + if (node.kind === 211) { 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 === 139 || node.kind === 138) { + else if (node.kind === 141 || node.kind === 140) { if (node.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23127,7 +23544,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 === 212) { + else if (node.parent.kind === 214) { 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 : @@ -23153,7 +23570,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 185) { + if (element.kind !== 187) { elements.push(element); } } @@ -23219,7 +23636,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 143 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 145 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -23232,7 +23649,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 143 + return accessor.kind === 145 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -23241,7 +23658,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 144) { + if (accessorWithTypeAnnotation.kind === 146) { 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 : @@ -23287,17 +23704,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 211) { + if (node.kind === 213) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 141) { + else if (node.kind === 143) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 211) { + if (node.kind === 213) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 142) { + else if (node.kind === 144) { write("constructor"); } else { @@ -23314,11 +23731,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 146 || node.kind === 151) { + if (node.kind === 148 || node.kind === 153) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 147) { + if (node.kind === 149) { write("["); } else { @@ -23327,20 +23744,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 147) { + if (node.kind === 149) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 150 || node.kind === 151; - if (isFunctionTypeOrConstructorType || node.parent.kind === 153) { + var isFunctionTypeOrConstructorType = node.kind === 152 || node.kind === 153; + if (isFunctionTypeOrConstructorType || node.parent.kind === 155) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 142 && !(node.flags & 32)) { + else if (node.kind !== 144 && !(node.flags & 32)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -23351,23 +23768,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 146: + case 148: 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 145: + case 147: 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 147: + case 149: 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 141: - case 140: + case 143: + case 142: if (node.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23375,7 +23792,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 === 212) { + else if (node.parent.kind === 214) { 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 : @@ -23388,7 +23805,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 211: + case 213: 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 : @@ -23420,9 +23837,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 150 || - node.parent.kind === 151 || - node.parent.parent.kind === 153) { + if (node.parent.kind === 152 || + node.parent.kind === 153 || + node.parent.parent.kind === 155) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32)) { @@ -23438,22 +23855,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 142: + case 144: 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 146: + case 148: 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 145: + case 147: 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 141: - case 140: + case 143: + case 142: if (node.parent.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23461,7 +23878,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 === 212) { + else if (node.parent.parent.kind === 214) { 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 : @@ -23473,7 +23890,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 211: + case 213: 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 : @@ -23484,12 +23901,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 159) { + if (bindingPattern.kind === 161) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 160) { + else if (bindingPattern.kind === 162) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -23508,10 +23925,10 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 185) { + if (bindingElement.kind === 187) { write(" "); } - else if (bindingElement.kind === 161) { + else if (bindingElement.kind === 163) { if (bindingElement.propertyName) { writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); @@ -23521,7 +23938,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 67); + ts.Debug.assert(bindingElement.name.kind === 69); if (bindingElement.dotDotDotToken) { write("..."); } @@ -23533,39 +23950,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 211: - case 216: - case 219: case 213: - case 212: - case 214: + case 218: + case 221: case 215: + case 214: + case 216: + case 217: return emitModuleElement(node, isModuleElementVisible(node)); - case 191: + case 193: return emitModuleElement(node, isVariableStatementVisible(node)); - case 220: + case 222: return emitModuleElement(node, !node.importClause); - case 226: + case 228: return emitExportDeclaration(node); + case 144: + case 143: case 142: - case 141: - case 140: return writeFunctionDeclaration(node); - case 146: - case 145: + case 148: case 147: + case 149: return emitSignatureDeclarationWithJsDocComments(node); - case 143: - case 144: + case 145: + case 146: return emitAccessorDeclaration(node); - case 139: - case 138: + case 141: + case 140: return emitPropertyDeclaration(node); - case 245: + case 247: return emitEnumMemberDeclaration(node); - case 225: + case 227: return emitExportAssignment(node); - case 246: + case 248: return emitSourceFile(node); } } @@ -23602,5492 +24019,12 @@ var ts; } ts.writeDeclarationFile = writeDeclarationFile; })(ts || (ts = {})); -/// -/// var ts; (function (ts) { function isExternalModuleOrDeclarationFile(sourceFile) { return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); } 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 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};"; - var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; - var compilerOptions = host.getCompilerOptions(); - var languageVersion = compilerOptions.target || 0; - var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; - var diagnostics = []; - var newLine = host.getNewLine(); - var jsxDesugaring = host.getCompilerOptions().jsx !== 1; - var shouldEmitJsx = function (s) { return (s.languageVariant === 1 && !jsxDesugaring); }; - if (targetSourceFile === undefined) { - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); - emitFile(jsFilePath, sourceFile); - } - }); - if (compilerOptions.outFile || compilerOptions.out) { - emitFile(compilerOptions.outFile || compilerOptions.out); - } - } - else { - if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); - emitFile(jsFilePath, targetSourceFile); - } - else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { - emitFile(compilerOptions.outFile || compilerOptions.out); - } - } - diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); - return { - emitSkipped: false, - diagnostics: diagnostics, - sourceMaps: sourceMapDataList - }; - function isNodeDescendentOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; - } - return false; - } - function isUniqueLocalName(name, container) { - for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { - if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { - return false; - } - } - } - return true; - } - function emitJavaScript(jsFilePath, root) { - var writer = ts.createTextWriter(newLine); - var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; - var currentSourceFile; - var exportFunctionForFile; - var generatedNameSet = {}; - var nodeToGeneratedName = []; - var computedPropertyNamesToGeneratedNames; - var extendsEmitted = false; - var decorateEmitted = false; - var paramEmitted = false; - var awaiterEmitted = false; - var tempFlags = 0; - var tempVariables; - var tempParameters; - var externalImports; - var exportSpecifiers; - var exportEquals; - var hasExportStars; - var writeEmittedFiles = writeJavaScriptFile; - var detachedCommentsInfo; - var writeComment = ts.writeCommentRange; - var emit = emitNodeWithCommentsAndWithoutSourcemap; - var emitStart = function (node) { }; - var emitEnd = function (node) { }; - var emitToken = emitTokenText; - var scopeEmitStart = function (scopeDeclaration, scopeName) { }; - var scopeEmitEnd = function () { }; - var sourceMapData; - if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { - initializeEmitterWithSourceMaps(); - } - if (root) { - emitSourceFile(root); - } - else { - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (!isExternalModuleOrDeclarationFile(sourceFile)) { - emitSourceFile(sourceFile); - } - }); - } - writeLine(); - writeEmittedFiles(writer.getText(), compilerOptions.emitBOM); - return; - function emitSourceFile(sourceFile) { - currentSourceFile = sourceFile; - exportFunctionForFile = undefined; - emit(sourceFile); - } - function isUniqueName(name) { - return !resolver.hasGlobalName(name) && - !ts.hasProperty(currentSourceFile.identifiers, name) && - !ts.hasProperty(generatedNameSet, name); - } - function makeTempVariableName(flags) { - if (flags && !(tempFlags & flags)) { - var name_19 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_19)) { - tempFlags |= flags; - return name_19; - } - } - while (true) { - var count = tempFlags & 268435455; - tempFlags++; - if (count !== 8 && count !== 13) { - var name_20 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_20)) { - return name_20; - } - } - } - } - function makeUniqueName(baseName) { - if (baseName.charCodeAt(baseName.length - 1) !== 95) { - baseName += "_"; - } - var i = 1; - while (true) { - var generatedName = baseName + i; - if (isUniqueName(generatedName)) { - return generatedNameSet[generatedName] = generatedName; - } - i++; - } - } - function generateNameForModuleOrEnum(node) { - var name = node.name.text; - return isUniqueLocalName(name, node) ? name : makeUniqueName(name); - } - function generateNameForImportOrExportDeclaration(node) { - var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 9 ? - ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; - return makeUniqueName(baseName); - } - function generateNameForExportDefault() { - return makeUniqueName("default"); - } - function generateNameForClassExpression() { - return makeUniqueName("class"); - } - function generateNameForNode(node) { - switch (node.kind) { - case 67: - return makeUniqueName(node.text); - case 216: - case 215: - return generateNameForModuleOrEnum(node); - case 220: - case 226: - return generateNameForImportOrExportDeclaration(node); - case 211: - case 212: - case 225: - return generateNameForExportDefault(); - case 184: - return generateNameForClassExpression(); - } - } - function getGeneratedNameForNode(node) { - var id = ts.getNodeId(node); - return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); - } - function initializeEmitterWithSourceMaps() { - var sourceMapDir; - var sourceMapSourceIndex = -1; - var sourceMapNameIndexMap = {}; - var sourceMapNameIndices = []; - function getSourceMapNameIndex() { - return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1; - } - var lastRecordedSourceMapSpan; - var lastEncodedSourceMapSpan = { - emittedLine: 1, - emittedColumn: 1, - sourceLine: 1, - sourceColumn: 1, - sourceIndex: 0 - }; - var lastEncodedNameIndex = 0; - function encodeLastRecordedSourceMapSpan() { - if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { - return; - } - var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; - if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { - if (sourceMapData.sourceMapMappings) { - sourceMapData.sourceMapMappings += ","; - } - } - else { - for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { - sourceMapData.sourceMapMappings += ";"; - } - prevEncodedEmittedColumn = 1; - } - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); - if (lastRecordedSourceMapSpan.nameIndex >= 0) { - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); - lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; - } - lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); - function base64VLQFormatEncode(inValue) { - function base64FormatEncode(inValue) { - if (inValue < 64) { - return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - } - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } - else { - inValue = inValue << 1; - } - var encodedStr = ""; - do { - var currentDigit = inValue & 31; - inValue = inValue >> 5; - if (inValue > 0) { - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + base64FormatEncode(currentDigit); - } while (inValue > 0); - return encodedStr; - } - } - function recordSourceMapSpan(pos) { - var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSourceFile, pos); - sourceLinePos.line++; - sourceLinePos.character++; - var emittedLine = writer.getLine(); - var emittedColumn = writer.getColumn(); - if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine !== emittedLine || - lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || - (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && - (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || - (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { - encodeLastRecordedSourceMapSpan(); - lastRecordedSourceMapSpan = { - emittedLine: emittedLine, - emittedColumn: emittedColumn, - sourceLine: sourceLinePos.line, - sourceColumn: sourceLinePos.character, - nameIndex: getSourceMapNameIndex(), - sourceIndex: sourceMapSourceIndex - }; - } - else { - lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; - lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; - lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; - } - } - function recordEmitNodeStartSpan(node) { - recordSourceMapSpan(ts.skipTrivia(currentSourceFile.text, node.pos)); - } - function recordEmitNodeEndSpan(node) { - recordSourceMapSpan(node.end); - } - function writeTextWithSpanRecord(tokenKind, startPos, emitFn) { - var tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos); - recordSourceMapSpan(tokenStartPos); - var tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn); - recordSourceMapSpan(tokenEndPos); - return tokenEndPos; - } - function recordNewSourceFileStart(node) { - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true)); - sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; - sourceMapData.inputSourceFileNames.push(node.fileName); - if (compilerOptions.inlineSources) { - if (!sourceMapData.sourceMapSourcesContent) { - sourceMapData.sourceMapSourcesContent = []; - } - sourceMapData.sourceMapSourcesContent.push(node.text); - } - } - function recordScopeNameOfNode(node, scopeName) { - function recordScopeNameIndex(scopeNameIndex) { - sourceMapNameIndices.push(scopeNameIndex); - } - function recordScopeNameStart(scopeName) { - var scopeNameIndex = -1; - if (scopeName) { - var parentIndex = getSourceMapNameIndex(); - if (parentIndex !== -1) { - var name_21 = node.name; - if (!name_21 || name_21.kind !== 134) { - scopeName = "." + scopeName; - } - scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; - } - scopeNameIndex = ts.getProperty(sourceMapNameIndexMap, scopeName); - if (scopeNameIndex === undefined) { - scopeNameIndex = sourceMapData.sourceMapNames.length; - sourceMapData.sourceMapNames.push(scopeName); - sourceMapNameIndexMap[scopeName] = scopeNameIndex; - } - } - recordScopeNameIndex(scopeNameIndex); - } - if (scopeName) { - recordScopeNameStart(scopeName); - } - else if (node.kind === 211 || - node.kind === 171 || - node.kind === 141 || - node.kind === 140 || - node.kind === 143 || - node.kind === 144 || - node.kind === 216 || - node.kind === 212 || - node.kind === 215) { - if (node.name) { - var name_22 = node.name; - scopeName = name_22.kind === 134 - ? ts.getTextOfNode(name_22) - : node.name.text; - } - recordScopeNameStart(scopeName); - } - else { - recordScopeNameIndex(getSourceMapNameIndex()); - } - } - function recordScopeNameEnd() { - sourceMapNameIndices.pop(); - } - ; - function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { - recordSourceMapSpan(comment.pos); - ts.writeCommentRange(currentSourceFile, writer, comment, newLine); - recordSourceMapSpan(comment.end); - } - function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings, sourcesContent) { - if (typeof JSON !== "undefined") { - var map_1 = { - version: version, - file: file, - sourceRoot: sourceRoot, - sources: sources, - names: names, - mappings: mappings - }; - if (sourcesContent !== undefined) { - map_1.sourcesContent = sourcesContent; - } - return JSON.stringify(map_1); - } - return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\" " + (sourcesContent !== undefined ? ",\"sourcesContent\":[" + serializeStringArray(sourcesContent) + "]" : "") + "}"; - function serializeStringArray(list) { - var output = ""; - for (var i = 0, n = list.length; i < n; i++) { - if (i) { - output += ","; - } - output += "\"" + ts.escapeString(list[i]) + "\""; - } - return output; - } - } - function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { - encodeLastRecordedSourceMapSpan(); - var sourceMapText = serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings, sourceMapData.sourceMapSourcesContent); - sourceMapDataList.push(sourceMapData); - var sourceMapUrl; - if (compilerOptions.inlineSourceMap) { - var base64SourceMapText = ts.convertToBase64(sourceMapText); - sourceMapUrl = "//# sourceMappingURL=data:application/json;base64," + base64SourceMapText; - } - else { - ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, false); - sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; - } - writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark); - } - var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); - sourceMapData = { - sourceMapFilePath: jsFilePath + ".map", - jsSourceMappingURL: sourceMapJsFile + ".map", - sourceMapFile: sourceMapJsFile, - sourceMapSourceRoot: compilerOptions.sourceRoot || "", - sourceMapSources: [], - inputSourceFileNames: [], - sourceMapNames: [], - sourceMapMappings: "", - sourceMapSourcesContent: undefined, - sourceMapDecodedMappings: [] - }; - sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); - if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47) { - sourceMapData.sourceMapSourceRoot += ts.directorySeparator; - } - if (compilerOptions.mapRoot) { - sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (root) { - sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); - } - if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { - sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); - sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), host.getCurrentDirectory(), host.getCanonicalFileName, true); - } - else { - sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); - } - } - else { - sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); - } - function emitNodeWithSourceMap(node) { - if (node) { - if (ts.nodeIsSynthesized(node)) { - return emitNodeWithoutSourceMap(node); - } - if (node.kind !== 246) { - recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMap(node); - recordEmitNodeEndSpan(node); - } - else { - recordNewSourceFileStart(node); - emitNodeWithoutSourceMap(node); - } - } - } - function emitNodeWithCommentsAndWithSourcemap(node) { - emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); - } - writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithCommentsAndWithSourcemap; - emitStart = recordEmitNodeStartSpan; - emitEnd = recordEmitNodeEndSpan; - emitToken = writeTextWithSpanRecord; - scopeEmitStart = recordScopeNameOfNode; - scopeEmitEnd = recordScopeNameEnd; - writeComment = writeCommentRangeWithMap; - } - function writeJavaScriptFile(emitOutput, writeByteOrderMark) { - ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); - } - function createTempVariable(flags) { - var result = ts.createSynthesizedNode(67); - result.text = makeTempVariableName(flags); - return result; - } - function recordTempDeclaration(name) { - if (!tempVariables) { - tempVariables = []; - } - tempVariables.push(name); - } - function createAndRecordTempVariable(flags) { - var temp = createTempVariable(flags); - recordTempDeclaration(temp); - return temp; - } - function emitTempDeclarations(newLine) { - if (tempVariables) { - if (newLine) { - writeLine(); - } - else { - write(" "); - } - write("var "); - emitCommaList(tempVariables); - write(";"); - } - } - function emitTokenText(tokenKind, startPos, emitFn) { - var tokenString = ts.tokenToString(tokenKind); - if (emitFn) { - emitFn(); - } - else { - write(tokenString); - } - return startPos + tokenString.length; - } - function emitOptional(prefix, node) { - if (node) { - write(prefix); - emit(node); - } - } - function emitParenthesizedIf(node, parenthesized) { - if (parenthesized) { - write("("); - } - emit(node); - if (parenthesized) { - write(")"); - } - } - function emitTrailingCommaIfPresent(nodeList) { - if (nodeList.hasTrailingComma) { - write(","); - } - } - function emitLinePreservingList(parent, nodes, allowTrailingComma, spacesBetweenBraces) { - ts.Debug.assert(nodes.length > 0); - increaseIndent(); - if (nodeStartPositionsAreOnSameLine(parent, nodes[0])) { - if (spacesBetweenBraces) { - write(" "); - } - } - else { - writeLine(); - } - for (var i = 0, n = nodes.length; i < n; i++) { - if (i) { - if (nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) { - write(", "); - } - else { - write(","); - writeLine(); - } - } - emit(nodes[i]); - } - if (nodes.hasTrailingComma && allowTrailingComma) { - write(","); - } - decreaseIndent(); - if (nodeEndPositionsAreOnSameLine(parent, ts.lastOrUndefined(nodes))) { - if (spacesBetweenBraces) { - write(" "); - } - } - else { - writeLine(); - } - } - function emitList(nodes, start, count, multiLine, trailingComma, leadingComma, noTrailingNewLine, emitNode) { - if (!emitNode) { - emitNode = emit; - } - for (var i = 0; i < count; i++) { - if (multiLine) { - if (i || leadingComma) { - write(","); - } - writeLine(); - } - else { - if (i || leadingComma) { - write(", "); - } - } - var node = nodes[start + i]; - emitTrailingCommentsOfPosition(node.pos); - emitNode(node); - leadingComma = true; - } - if (trailingComma) { - write(","); - } - if (multiLine && !noTrailingNewLine) { - writeLine(); - } - return count; - } - function emitCommaList(nodes) { - if (nodes) { - emitList(nodes, 0, nodes.length, false, false); - } - } - function emitLines(nodes) { - emitLinesStartingAt(nodes, 0); - } - function emitLinesStartingAt(nodes, startIndex) { - for (var i = startIndex; i < nodes.length; i++) { - writeLine(); - emit(nodes[i]); - } - } - function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 8 && text.length > 1) { - switch (text.charCodeAt(1)) { - case 98: - case 66: - case 111: - case 79: - return true; - } - } - return false; - } - function emitLiteral(node) { - var text = getLiteralText(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 || ts.isTemplateLiteralKind(node.kind))) { - writer.writeLiteral(text); - } - else if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { - write(node.text); - } - else { - write(text); - } - } - function getLiteralText(node) { - if (languageVersion < 2 && (ts.isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText("\"", node.text, "\""); - } - if (node.parent) { - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - } - switch (node.kind) { - case 9: - return getQuotedEscapedLiteralText("\"", node.text, "\""); - case 11: - return getQuotedEscapedLiteralText("`", node.text, "`"); - case 12: - return getQuotedEscapedLiteralText("`", node.text, "${"); - case 13: - return getQuotedEscapedLiteralText("}", node.text, "${"); - case 14: - return getQuotedEscapedLiteralText("}", node.text, "`"); - case 8: - return node.text; - } - ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); - } - function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { - return leftQuote + ts.escapeNonAsciiCharacters(ts.escapeString(text)) + rightQuote; - } - function emitDownlevelRawTemplateLiteral(node) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - var isLast = node.kind === 11 || node.kind === 14; - text = text.substring(1, text.length - (isLast ? 1 : 2)); - text = text.replace(/\r\n?/g, "\n"); - text = ts.escapeString(text); - write("\"" + text + "\""); - } - function emitDownlevelTaggedTemplateArray(node, literalEmitter) { - write("["); - if (node.template.kind === 11) { - literalEmitter(node.template); - } - else { - literalEmitter(node.template.head); - ts.forEach(node.template.templateSpans, function (child) { - write(", "); - literalEmitter(child.literal); - }); - } - write("]"); - } - function emitDownlevelTaggedTemplate(node) { - var tempVariable = createAndRecordTempVariable(0); - write("("); - emit(tempVariable); - write(" = "); - emitDownlevelTaggedTemplateArray(node, emit); - write(", "); - emit(tempVariable); - write(".raw = "); - emitDownlevelTaggedTemplateArray(node, emitDownlevelRawTemplateLiteral); - write(", "); - emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); - write("("); - emit(tempVariable); - if (node.template.kind === 181) { - ts.forEach(node.template.templateSpans, function (templateSpan) { - write(", "); - var needsParens = templateSpan.expression.kind === 179 - && templateSpan.expression.operatorToken.kind === 24; - emitParenthesizedIf(templateSpan.expression, needsParens); - }); - } - write("))"); - } - function emitTemplateExpression(node) { - if (languageVersion >= 2) { - ts.forEachChild(node, emit); - return; - } - var emitOuterParens = ts.isExpression(node.parent) - && templateNeedsParens(node, node.parent); - if (emitOuterParens) { - write("("); - } - var headEmitted = false; - if (shouldEmitTemplateHead()) { - emitLiteral(node.head); - headEmitted = true; - } - for (var i = 0, n = node.templateSpans.length; i < n; i++) { - var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 170 - && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; - if (i > 0 || headEmitted) { - write(" + "); - } - emitParenthesizedIf(templateSpan.expression, needsParens); - if (templateSpan.literal.text.length !== 0) { - write(" + "); - emitLiteral(templateSpan.literal); - } - } - if (emitOuterParens) { - write(")"); - } - function shouldEmitTemplateHead() { - // If this expression has an empty head literal and the first template span has a non-empty - // literal, then emitting the empty head literal is not necessary. - // `${ foo } and ${ bar }` - // can be emitted as - // foo + " and " + bar - // This is because it is only required that one of the first two operands in the emit - // output must be a string literal, so that the other operand and all following operands - // are forced into strings. - // - // If the first template span has an empty literal, then the head must still be emitted. - // `${ foo }${ bar }` - // must still be emitted as - // "" + foo + bar - ts.Debug.assert(node.templateSpans.length !== 0); - return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; - } - function templateNeedsParens(template, parent) { - switch (parent.kind) { - case 166: - case 167: - return parent.expression === template; - case 168: - case 170: - return false; - default: - return comparePrecedenceToBinaryPlus(parent) !== -1; - } - } - function comparePrecedenceToBinaryPlus(expression) { - switch (expression.kind) { - case 179: - switch (expression.operatorToken.kind) { - case 37: - case 38: - case 39: - return 1; - case 35: - case 36: - return 0; - default: - return -1; - } - case 182: - case 180: - return -1; - default: - return 1; - } - } - } - function emitTemplateSpan(span) { - emit(span.expression); - emit(span.literal); - } - function jsxEmitReact(node) { - function emitTagName(name) { - if (name.kind === 67 && ts.isIntrinsicJsxName(name.text)) { - write("\""); - emit(name); - write("\""); - } - else { - emit(name); - } - } - function emitAttributeName(name) { - if (/[A-Za-z_]+[\w*]/.test(name.text)) { - write("\""); - emit(name); - write("\""); - } - else { - emit(name); - } - } - function emitJsxAttribute(node) { - emitAttributeName(node.name); - write(": "); - if (node.initializer) { - emit(node.initializer); - } - else { - write("true"); - } - } - function emitJsxElement(openingNode, children) { - var syntheticReactRef = ts.createSynthesizedNode(67); - syntheticReactRef.text = 'React'; - syntheticReactRef.parent = openingNode; - emitLeadingComments(openingNode); - emitExpressionIdentifier(syntheticReactRef); - write(".createElement("); - emitTagName(openingNode.tagName); - write(", "); - if (openingNode.attributes.length === 0) { - write("null"); - } - else { - var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 237; })) { - emitExpressionIdentifier(syntheticReactRef); - write(".__spread("); - var haveOpenedObjectLiteral = false; - for (var i_1 = 0; i_1 < attrs.length; i_1++) { - if (attrs[i_1].kind === 237) { - if (i_1 === 0) { - write("{}, "); - } - if (haveOpenedObjectLiteral) { - write("}"); - haveOpenedObjectLiteral = false; - } - if (i_1 > 0) { - write(", "); - } - emit(attrs[i_1].expression); - } - else { - ts.Debug.assert(attrs[i_1].kind === 236); - if (haveOpenedObjectLiteral) { - write(", "); - } - else { - haveOpenedObjectLiteral = true; - if (i_1 > 0) { - write(", "); - } - write("{"); - } - emitJsxAttribute(attrs[i_1]); - } - } - if (haveOpenedObjectLiteral) - write("}"); - write(")"); - } - else { - write("{"); - for (var i = 0; i < attrs.length; i++) { - if (i > 0) { - write(", "); - } - emitJsxAttribute(attrs[i]); - } - write("}"); - } - } - if (children) { - for (var i = 0; i < children.length; i++) { - if (children[i].kind === 238 && !(children[i].expression)) { - continue; - } - if (children[i].kind === 234) { - var text = getTextToEmit(children[i]); - if (text !== undefined) { - write(", \""); - write(text); - write("\""); - } - } - else { - write(", "); - emit(children[i]); - } - } - } - write(")"); - emitTrailingComments(openingNode); - } - if (node.kind === 231) { - emitJsxElement(node.openingElement, node.children); - } - else { - ts.Debug.assert(node.kind === 232); - emitJsxElement(node); - } - } - function jsxEmitPreserve(node) { - function emitJsxAttribute(node) { - emit(node.name); - if (node.initializer) { - write("="); - emit(node.initializer); - } - } - function emitJsxSpreadAttribute(node) { - write("{..."); - emit(node.expression); - write("}"); - } - function emitAttributes(attribs) { - for (var i = 0, n = attribs.length; i < n; i++) { - if (i > 0) { - write(" "); - } - if (attribs[i].kind === 237) { - emitJsxSpreadAttribute(attribs[i]); - } - else { - ts.Debug.assert(attribs[i].kind === 236); - emitJsxAttribute(attribs[i]); - } - } - } - function emitJsxOpeningOrSelfClosingElement(node) { - write("<"); - emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 232)) { - write(" "); - } - emitAttributes(node.attributes); - if (node.kind === 232) { - write("/>"); - } - else { - write(">"); - } - } - function emitJsxClosingElement(node) { - write(""); - } - function emitJsxElement(node) { - emitJsxOpeningOrSelfClosingElement(node.openingElement); - for (var i = 0, n = node.children.length; i < n; i++) { - emit(node.children[i]); - } - emitJsxClosingElement(node.closingElement); - } - if (node.kind === 231) { - emitJsxElement(node); - } - else { - ts.Debug.assert(node.kind === 232); - emitJsxOpeningOrSelfClosingElement(node); - } - } - function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 161); - if (node.kind === 9) { - emitLiteral(node); - } - else if (node.kind === 134) { - if (ts.nodeIsDecorated(node.parent)) { - if (!computedPropertyNamesToGeneratedNames) { - computedPropertyNamesToGeneratedNames = []; - } - var generatedName = computedPropertyNamesToGeneratedNames[ts.getNodeId(node)]; - if (generatedName) { - write(generatedName); - return; - } - generatedName = createAndRecordTempVariable(0).text; - computedPropertyNamesToGeneratedNames[ts.getNodeId(node)] = generatedName; - write(generatedName); - write(" = "); - } - emit(node.expression); - } - else { - write("\""); - if (node.kind === 8) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - write("\""); - } - } - function isExpressionIdentifier(node) { - var parent = node.parent; - switch (parent.kind) { - case 162: - case 179: - case 166: - case 239: - case 134: - case 180: - case 137: - case 173: - case 195: - case 165: - case 225: - case 193: - case 186: - case 197: - case 198: - case 199: - case 194: - case 232: - case 233: - case 237: - case 238: - case 167: - case 170: - case 178: - case 177: - case 202: - case 244: - case 183: - case 204: - case 168: - case 188: - case 206: - case 169: - case 174: - case 175: - case 196: - case 203: - case 182: - return true; - case 161: - case 245: - case 136: - case 243: - case 139: - case 209: - return parent.initializer === node; - case 164: - return parent.expression === node; - case 172: - case 171: - return parent.body === node; - case 219: - return parent.moduleReference === node; - case 133: - return parent.left === node; - } - return false; - } - function emitExpressionIdentifier(node) { - if (resolver.getNodeCheckFlags(node) & 2048) { - write("_arguments"); - return; - } - var container = resolver.getReferencedExportContainer(node); - if (container) { - if (container.kind === 246) { - if (languageVersion < 2 && compilerOptions.module !== 4) { - write("exports."); - } - } - else { - write(getGeneratedNameForNode(container)); - write("."); - } - } - else if (languageVersion < 2) { - var declaration = resolver.getReferencedImportDeclaration(node); - if (declaration) { - if (declaration.kind === 221) { - write(getGeneratedNameForNode(declaration.parent)); - write(languageVersion === 0 ? "[\"default\"]" : ".default"); - return; - } - else if (declaration.kind === 224) { - 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; - } - } - if (ts.nodeIsSynthesized(node)) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function isNameOfNestedRedeclaration(node) { - if (languageVersion < 2) { - var parent_6 = node.parent; - switch (parent_6.kind) { - case 161: - case 212: - case 215: - case 209: - return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); - } - } - return false; - } - function emitIdentifier(node) { - if (!node.parent) { - write(node.text); - } - else if (isExpressionIdentifier(node)) { - emitExpressionIdentifier(node); - } - else if (isNameOfNestedRedeclaration(node)) { - write(getGeneratedNameForNode(node)); - } - else if (ts.nodeIsSynthesized(node)) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function emitThis(node) { - if (resolver.getNodeCheckFlags(node) & 2) { - write("_this"); - } - else { - write("this"); - } - } - function emitSuper(node) { - if (languageVersion >= 2) { - write("super"); - } - else { - var flags = resolver.getNodeCheckFlags(node); - if (flags & 256) { - write("_super.prototype"); - } - else { - write("_super"); - } - } - } - function emitObjectBindingPattern(node) { - write("{ "); - var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); - write(" }"); - } - function emitArrayBindingPattern(node) { - write("["); - var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); - write("]"); - } - function emitBindingElement(node) { - if (node.propertyName) { - emit(node.propertyName); - write(": "); - } - if (node.dotDotDotToken) { - write("..."); - } - if (ts.isBindingPattern(node.name)) { - emit(node.name); - } - else { - emitModuleMemberName(node); - } - emitOptional(" = ", node.initializer); - } - function emitSpreadElementExpression(node) { - write("..."); - emit(node.expression); - } - function emitYieldExpression(node) { - write(ts.tokenToString(112)); - if (node.asteriskToken) { - write("*"); - } - if (node.expression) { - write(" "); - emit(node.expression); - } - } - function emitAwaitExpression(node) { - var needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); - if (needsParenthesis) { - write("("); - } - write(ts.tokenToString(112)); - write(" "); - emit(node.expression); - if (needsParenthesis) { - write(")"); - } - } - function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 179 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { - return true; - } - else if (node.parent.kind === 180 && node.parent.condition === node) { - return true; - } - return false; - } - function needsParenthesisForPropertyAccessOrInvocation(node) { - switch (node.kind) { - case 67: - case 162: - case 164: - case 165: - case 166: - case 170: - return false; - } - return true; - } - function emitListWithSpread(elements, needsUniqueCopy, multiLine, trailingComma, useConcat) { - var pos = 0; - var group = 0; - var length = elements.length; - while (pos < length) { - if (group === 1 && useConcat) { - write(".concat("); - } - else if (group > 0) { - write(", "); - } - var e = elements[pos]; - if (e.kind === 183) { - e = e.expression; - emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); - pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 162) { - write(".slice()"); - } - } - else { - var i = pos; - while (i < length && elements[i].kind !== 183) { - i++; - } - write("["); - if (multiLine) { - increaseIndent(); - } - emitList(elements, pos, i - pos, multiLine, trailingComma && i === length); - if (multiLine) { - decreaseIndent(); - } - write("]"); - pos = i; - } - group++; - } - if (group > 1) { - if (useConcat) { - write(")"); - } - } - } - function isSpreadElementExpression(node) { - return node.kind === 183; - } - function emitArrayLiteral(node) { - var elements = node.elements; - if (elements.length === 0) { - write("[]"); - } - else if (languageVersion >= 2 || !ts.forEach(elements, isSpreadElementExpression)) { - write("["); - emitLinePreservingList(node, node.elements, elements.hasTrailingComma, false); - write("]"); - } - else { - emitListWithSpread(elements, true, (node.flags & 2048) !== 0, elements.hasTrailingComma, true); - } - } - function emitObjectLiteralBody(node, numElements) { - if (numElements === 0) { - write("{}"); - return; - } - write("{"); - if (numElements > 0) { - var properties = node.properties; - if (numElements === properties.length) { - emitLinePreservingList(node, properties, languageVersion >= 1, true); - } - else { - var multiLine = (node.flags & 2048) !== 0; - if (!multiLine) { - write(" "); - } - else { - increaseIndent(); - } - emitList(properties, 0, numElements, multiLine, false); - if (!multiLine) { - write(" "); - } - else { - decreaseIndent(); - } - } - } - write("}"); - } - function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 2048) !== 0; - var properties = node.properties; - write("("); - if (multiLine) { - increaseIndent(); - } - var tempVar = createAndRecordTempVariable(0); - emit(tempVar); - write(" = "); - emitObjectLiteralBody(node, firstComputedPropertyIndex); - for (var i = firstComputedPropertyIndex, n = properties.length; i < n; i++) { - writeComma(); - var property = properties[i]; - emitStart(property); - if (property.kind === 143 || property.kind === 144) { - var accessors = ts.getAllAccessorDeclarations(node.properties, property); - if (property !== accessors.firstAccessor) { - continue; - } - write("Object.defineProperty("); - emit(tempVar); - write(", "); - emitStart(node.name); - emitExpressionForPropertyName(property.name); - emitEnd(property.name); - write(", {"); - increaseIndent(); - if (accessors.getAccessor) { - writeLine(); - emitLeadingComments(accessors.getAccessor); - write("get: "); - emitStart(accessors.getAccessor); - write("function "); - emitSignatureAndBody(accessors.getAccessor); - emitEnd(accessors.getAccessor); - emitTrailingComments(accessors.getAccessor); - write(","); - } - if (accessors.setAccessor) { - writeLine(); - emitLeadingComments(accessors.setAccessor); - write("set: "); - emitStart(accessors.setAccessor); - write("function "); - emitSignatureAndBody(accessors.setAccessor); - emitEnd(accessors.setAccessor); - emitTrailingComments(accessors.setAccessor); - write(","); - } - writeLine(); - write("enumerable: true,"); - writeLine(); - write("configurable: true"); - decreaseIndent(); - writeLine(); - write("})"); - emitEnd(property); - } - else { - emitLeadingComments(property); - emitStart(property.name); - emit(tempVar); - emitMemberAccessForPropertyName(property.name); - emitEnd(property.name); - write(" = "); - if (property.kind === 243) { - emit(property.initializer); - } - else if (property.kind === 244) { - emitExpressionIdentifier(property.name); - } - else if (property.kind === 141) { - emitFunctionDeclaration(property); - } - else { - ts.Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind); - } - } - emitEnd(property); - } - writeComma(); - emit(tempVar); - if (multiLine) { - decreaseIndent(); - writeLine(); - } - write(")"); - function writeComma() { - if (multiLine) { - write(","); - writeLine(); - } - else { - write(", "); - } - } - } - function emitObjectLiteral(node) { - var properties = node.properties; - if (languageVersion < 2) { - var numProperties = properties.length; - var numInitialNonComputedProperties = numProperties; - for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 134) { - numInitialNonComputedProperties = i; - break; - } - } - var hasComputedProperty = numInitialNonComputedProperties !== properties.length; - if (hasComputedProperty) { - emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties); - return; - } - } - emitObjectLiteralBody(node, properties.length); - } - function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(179, startsOnNewLine); - result.operatorToken = ts.createSynthesizedNode(operator); - result.left = left; - result.right = right; - return result; - } - function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(164); - result.expression = parenthesizeForAccess(expression); - result.dotToken = ts.createSynthesizedNode(21); - result.name = name; - return result; - } - function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(165); - result.expression = parenthesizeForAccess(expression); - result.argumentExpression = argumentExpression; - return result; - } - function parenthesizeForAccess(expr) { - while (expr.kind === 169 || expr.kind === 187) { - expr = expr.expression; - } - if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 167 && - expr.kind !== 8) { - return expr; - } - var node = ts.createSynthesizedNode(170); - node.expression = expr; - return node; - } - function emitComputedPropertyName(node) { - write("["); - emitExpressionForPropertyName(node); - write("]"); - } - function emitMethod(node) { - if (languageVersion >= 2 && node.asteriskToken) { - write("*"); - } - emit(node.name); - if (languageVersion < 2) { - write(": function "); - } - emitSignatureAndBody(node); - } - function emitPropertyAssignment(node) { - emit(node.name); - write(": "); - emitTrailingCommentsOfPosition(node.initializer.pos); - emit(node.initializer); - } - function isNamespaceExportReference(node) { - var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 246; - } - function emitShorthandPropertyAssignment(node) { - writeTextOfNode(currentSourceFile, node.name); - if (languageVersion < 2 || isNamespaceExportReference(node.name)) { - write(": "); - emit(node.name); - } - } - function tryEmitConstantValue(node) { - var constantValue = tryGetConstEnumValue(node); - if (constantValue !== undefined) { - write(constantValue.toString()); - if (!compilerOptions.removeComments) { - var propertyName = node.kind === 164 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); - write(" /* " + propertyName + " */"); - } - return true; - } - return false; - } - function tryGetConstEnumValue(node) { - if (compilerOptions.isolatedModules) { - return undefined; - } - return node.kind === 164 || node.kind === 165 - ? resolver.getConstantValue(node) - : undefined; - } - function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { - var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); - var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); - if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) { - increaseIndent(); - writeLine(); - return true; - } - else { - if (valueToWriteWhenNotIndenting) { - write(valueToWriteWhenNotIndenting); - } - return false; - } - } - function emitPropertyAccess(node) { - if (tryEmitConstantValue(node)) { - return; - } - emit(node.expression); - var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); - var shouldEmitSpace; - if (!indentedBeforeDot) { - if (node.expression.kind === 8) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); - shouldEmitSpace = text.indexOf(ts.tokenToString(21)) < 0; - } - else { - var constantValue = tryGetConstEnumValue(node.expression); - shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; - } - } - if (shouldEmitSpace) { - write(" ."); - } - else { - write("."); - } - var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); - emit(node.name); - decreaseIndentIf(indentedBeforeDot, indentedAfterDot); - } - function emitQualifiedName(node) { - emit(node.left); - write("."); - emit(node.right); - } - function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 67) { - emitEntityNameAsExpression(node.left, useFallback); - } - else if (useFallback) { - var temp = createAndRecordTempVariable(0); - write("("); - emitNodeWithoutSourceMap(temp); - write(" = "); - emitEntityNameAsExpression(node.left, true); - write(") && "); - emitNodeWithoutSourceMap(temp); - } - else { - emitEntityNameAsExpression(node.left, false); - } - write("."); - emit(node.right); - } - function emitEntityNameAsExpression(node, useFallback) { - switch (node.kind) { - case 67: - if (useFallback) { - write("typeof "); - emitExpressionIdentifier(node); - write(" !== 'undefined' && "); - } - emitExpressionIdentifier(node); - break; - case 133: - emitQualifiedNameAsExpression(node, useFallback); - break; - } - } - function emitIndexedAccess(node) { - if (tryEmitConstantValue(node)) { - return; - } - emit(node.expression); - write("["); - emit(node.argumentExpression); - write("]"); - } - function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 183; }); - } - function skipParentheses(node) { - while (node.kind === 170 || node.kind === 169 || node.kind === 187) { - node = node.expression; - } - return node; - } - function emitCallTarget(node) { - if (node.kind === 67 || node.kind === 95 || node.kind === 93) { - emit(node); - return node; - } - var temp = createAndRecordTempVariable(0); - write("("); - emit(temp); - write(" = "); - emit(node); - write(")"); - return temp; - } - function emitCallWithSpread(node) { - var target; - var expr = skipParentheses(node.expression); - if (expr.kind === 164) { - target = emitCallTarget(expr.expression); - write("."); - emit(expr.name); - } - else if (expr.kind === 165) { - target = emitCallTarget(expr.expression); - write("["); - emit(expr.argumentExpression); - write("]"); - } - else if (expr.kind === 93) { - target = expr; - write("_super"); - } - else { - emit(node.expression); - } - write(".apply("); - if (target) { - if (target.kind === 93) { - emitThis(target); - } - else { - emit(target); - } - } - else { - write("void 0"); - } - write(", "); - emitListWithSpread(node.arguments, false, false, false, true); - write(")"); - } - function emitCallExpression(node) { - if (languageVersion < 2 && hasSpreadElement(node.arguments)) { - emitCallWithSpread(node); - return; - } - var superCall = false; - if (node.expression.kind === 93) { - emitSuper(node.expression); - superCall = true; - } - else { - emit(node.expression); - superCall = node.expression.kind === 164 && node.expression.expression.kind === 93; - } - if (superCall && languageVersion < 2) { - write(".call("); - emitThis(node.expression); - if (node.arguments.length) { - write(", "); - emitCommaList(node.arguments); - } - write(")"); - } - else { - write("("); - emitCommaList(node.arguments); - write(")"); - } - } - function emitNewExpression(node) { - write("new "); - if (languageVersion === 1 && - node.arguments && - hasSpreadElement(node.arguments)) { - write("("); - var target = emitCallTarget(node.expression); - write(".bind.apply("); - emit(target); - write(", [void 0].concat("); - emitListWithSpread(node.arguments, false, false, false, false); - write(")))"); - write("()"); - } - else { - emit(node.expression); - if (node.arguments) { - write("("); - emitCommaList(node.arguments); - write(")"); - } - } - } - function emitTaggedTemplateExpression(node) { - if (languageVersion >= 2) { - emit(node.tag); - write(" "); - emit(node.template); - } - else { - emitDownlevelTaggedTemplate(node); - } - } - function emitParenExpression(node) { - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 172) { - if (node.expression.kind === 169 || node.expression.kind === 187) { - var operand = node.expression.expression; - while (operand.kind === 169 || operand.kind === 187) { - operand = operand.expression; - } - if (operand.kind !== 177 && - operand.kind !== 175 && - operand.kind !== 174 && - operand.kind !== 173 && - operand.kind !== 178 && - operand.kind !== 167 && - !(operand.kind === 166 && node.parent.kind === 167) && - !(operand.kind === 171 && node.parent.kind === 166)) { - emit(operand); - return; - } - } - } - write("("); - emit(node.expression); - write(")"); - } - function emitDeleteExpression(node) { - write(ts.tokenToString(76)); - write(" "); - emit(node.expression); - } - function emitVoidExpression(node) { - write(ts.tokenToString(101)); - write(" "); - emit(node.expression); - } - function emitTypeOfExpression(node) { - write(ts.tokenToString(99)); - write(" "); - emit(node.expression); - } - function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 67 || ts.nodeIsSynthesized(node)) { - return false; - } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 209 || node.parent.kind === 161); - var targetDeclaration = isVariableDeclarationOrBindingElement - ? node.parent - : resolver.getReferencedValueDeclaration(node); - return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, true); - } - function emitPrefixUnaryExpression(node) { - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.operand); - write("\", "); - } - write(ts.tokenToString(node.operator)); - if (node.operand.kind === 177) { - var operand = node.operand; - if (node.operator === 35 && (operand.operator === 35 || operand.operator === 40)) { - write(" "); - } - else if (node.operator === 36 && (operand.operator === 36 || operand.operator === 41)) { - write(" "); - } - } - emit(node.operand); - if (exportChanged) { - write(")"); - } - } - function emitPostfixUnaryExpression(node) { - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); - if (exportChanged) { - write("(" + exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.operand); - write("\", "); - write(ts.tokenToString(node.operator)); - emit(node.operand); - if (node.operator === 40) { - write(") - 1)"); - } - else { - write(") + 1)"); - } - } - else { - emit(node.operand); - write(ts.tokenToString(node.operator)); - } - } - function shouldHoistDeclarationInSystemJsModule(node) { - return isSourceFileLevelDeclarationInSystemJsModule(node, false); - } - function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) { - if (!node || languageVersion >= 2 || !isCurrentFileSystemExternalModule()) { - return false; - } - var current = node; - while (current) { - if (current.kind === 246) { - return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); - } - else if (ts.isFunctionLike(current) || current.kind === 217) { - return false; - } - else { - current = current.parent; - } - } - } - function emitBinaryExpression(node) { - if (languageVersion < 2 && node.operatorToken.kind === 55 && - (node.left.kind === 163 || node.left.kind === 162)) { - emitDestructuring(node, node.parent.kind === 193); - } - else { - var exportChanged = node.operatorToken.kind >= 55 && - node.operatorToken.kind <= 66 && - isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.left); - write("\", "); - } - emit(node.left); - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 ? " " : undefined); - write(ts.tokenToString(node.operatorToken.kind)); - var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); - emit(node.right); - decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); - if (exportChanged) { - write(")"); - } - } - } - function synthesizedNodeStartsOnNewLine(node) { - return ts.nodeIsSynthesized(node) && node.startsOnNewLine; - } - function emitConditionalExpression(node) { - emit(node.condition); - var indentedBeforeQuestion = indentIfOnDifferentLines(node, node.condition, node.questionToken, " "); - write("?"); - var indentedAfterQuestion = indentIfOnDifferentLines(node, node.questionToken, node.whenTrue, " "); - emit(node.whenTrue); - decreaseIndentIf(indentedBeforeQuestion, indentedAfterQuestion); - var indentedBeforeColon = indentIfOnDifferentLines(node, node.whenTrue, node.colonToken, " "); - write(":"); - var indentedAfterColon = indentIfOnDifferentLines(node, node.colonToken, node.whenFalse, " "); - emit(node.whenFalse); - decreaseIndentIf(indentedBeforeColon, indentedAfterColon); - } - function decreaseIndentIf(value1, value2) { - if (value1) { - decreaseIndent(); - } - if (value2) { - decreaseIndent(); - } - } - function isSingleLineEmptyBlock(node) { - if (node && node.kind === 190) { - var block = node; - return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); - } - } - function emitBlock(node) { - if (isSingleLineEmptyBlock(node)) { - emitToken(15, node.pos); - write(" "); - emitToken(16, node.statements.end); - return; - } - emitToken(15, node.pos); - increaseIndent(); - scopeEmitStart(node.parent); - if (node.kind === 217) { - ts.Debug.assert(node.parent.kind === 216); - emitCaptureThisForNodeIfNecessary(node.parent); - } - emitLines(node.statements); - if (node.kind === 217) { - emitTempDeclarations(true); - } - decreaseIndent(); - writeLine(); - emitToken(16, node.statements.end); - scopeEmitEnd(); - } - function emitEmbeddedStatement(node) { - if (node.kind === 190) { - write(" "); - emit(node); - } - else { - increaseIndent(); - writeLine(); - emit(node); - decreaseIndent(); - } - } - function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 172); - write(";"); - } - function emitIfStatement(node) { - var endPos = emitToken(86, node.pos); - write(" "); - endPos = emitToken(17, endPos); - emit(node.expression); - emitToken(18, node.expression.end); - emitEmbeddedStatement(node.thenStatement); - if (node.elseStatement) { - writeLine(); - emitToken(78, node.thenStatement.end); - if (node.elseStatement.kind === 194) { - write(" "); - emit(node.elseStatement); - } - else { - emitEmbeddedStatement(node.elseStatement); - } - } - } - function emitDoStatement(node) { - write("do"); - emitEmbeddedStatement(node.statement); - if (node.statement.kind === 190) { - write(" "); - } - else { - writeLine(); - } - write("while ("); - emit(node.expression); - write(");"); - } - function emitWhileStatement(node) { - write("while ("); - emit(node.expression); - write(")"); - emitEmbeddedStatement(node.statement); - } - function tryEmitStartOfVariableDeclarationList(decl, startPos) { - if (shouldHoistVariable(decl, true)) { - return false; - } - var tokenKind = 100; - if (decl && languageVersion >= 2) { - if (ts.isLet(decl)) { - tokenKind = 106; - } - else if (ts.isConst(decl)) { - tokenKind = 72; - } - } - if (startPos !== undefined) { - emitToken(tokenKind, startPos); - write(" "); - } - else { - switch (tokenKind) { - case 100: - write("var "); - break; - case 106: - write("let "); - break; - case 72: - write("const "); - break; - } - } - return true; - } - function emitVariableDeclarationListSkippingUninitializedEntries(list) { - var started = false; - for (var _a = 0, _b = list.declarations; _a < _b.length; _a++) { - var decl = _b[_a]; - if (!decl.initializer) { - continue; - } - if (!started) { - started = true; - } - else { - write(", "); - } - emit(decl); - } - return started; - } - function emitForStatement(node) { - var endPos = emitToken(84, node.pos); - write(" "); - endPos = emitToken(17, endPos); - if (node.initializer && node.initializer.kind === 210) { - var variableDeclarationList = node.initializer; - var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); - if (startIsEmitted) { - emitCommaList(variableDeclarationList.declarations); - } - else { - emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); - } - } - else if (node.initializer) { - emit(node.initializer); - } - write(";"); - emitOptional(" ", node.condition); - write(";"); - emitOptional(" ", node.incrementor); - write(")"); - emitEmbeddedStatement(node.statement); - } - function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 199) { - return emitDownLevelForOfStatement(node); - } - var endPos = emitToken(84, node.pos); - write(" "); - endPos = emitToken(17, endPos); - if (node.initializer.kind === 210) { - var variableDeclarationList = node.initializer; - if (variableDeclarationList.declarations.length >= 1) { - tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); - emit(variableDeclarationList.declarations[0]); - } - } - else { - emit(node.initializer); - } - if (node.kind === 198) { - write(" in "); - } - else { - write(" of "); - } - emit(node.expression); - emitToken(18, node.expression.end); - emitEmbeddedStatement(node.statement); - } - function emitDownLevelForOfStatement(node) { - // The following ES6 code: - // - // for (let v of expr) { } - // - // should be emitted as - // - // for (let _i = 0, _a = expr; _i < _a.length; _i++) { - // let v = _a[_i]; - // } - // - // where _a and _i are temps emitted to capture the RHS and the counter, - // respectively. - // When the left hand side is an expression instead of a let declaration, - // the "let v" is not emitted. - // When the left hand side is a let/const, the v is renamed if there is - // another v in scope. - // Note that all assignments to the LHS are emitted in the body, including - // all destructuring. - // Note also that because an extra statement is needed to assign to the LHS, - // for-of bodies are always emitted as blocks. - var endPos = emitToken(84, node.pos); - write(" "); - endPos = emitToken(17, endPos); - var rhsIsIdentifier = node.expression.kind === 67; - var counter = createTempVariable(268435456); - var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); - emitStart(node.expression); - write("var "); - emitNodeWithoutSourceMap(counter); - write(" = 0"); - emitEnd(node.expression); - if (!rhsIsIdentifier) { - write(", "); - emitStart(node.expression); - emitNodeWithoutSourceMap(rhsReference); - write(" = "); - emitNodeWithoutSourceMap(node.expression); - emitEnd(node.expression); - } - write("; "); - emitStart(node.initializer); - emitNodeWithoutSourceMap(counter); - write(" < "); - emitNodeWithCommentsAndWithoutSourcemap(rhsReference); - write(".length"); - emitEnd(node.initializer); - write("; "); - emitStart(node.initializer); - emitNodeWithoutSourceMap(counter); - write("++"); - emitEnd(node.initializer); - emitToken(18, node.expression.end); - write(" {"); - writeLine(); - increaseIndent(); - var rhsIterationValue = createElementAccessExpression(rhsReference, counter); - emitStart(node.initializer); - if (node.initializer.kind === 210) { - write("var "); - var variableDeclarationList = node.initializer; - if (variableDeclarationList.declarations.length > 0) { - var declaration = variableDeclarationList.declarations[0]; - if (ts.isBindingPattern(declaration.name)) { - emitDestructuring(declaration, false, rhsIterationValue); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(declaration); - write(" = "); - emitNodeWithoutSourceMap(rhsIterationValue); - } - } - else { - emitNodeWithoutSourceMap(createTempVariable(0)); - write(" = "); - emitNodeWithoutSourceMap(rhsIterationValue); - } - } - else { - var assignmentExpression = createBinaryExpression(node.initializer, 55, rhsIterationValue, false); - if (node.initializer.kind === 162 || node.initializer.kind === 163) { - emitDestructuring(assignmentExpression, true, undefined); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); - } - } - emitEnd(node.initializer); - write(";"); - if (node.statement.kind === 190) { - emitLines(node.statement.statements); - } - else { - writeLine(); - emit(node.statement); - } - writeLine(); - decreaseIndent(); - write("}"); - } - function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 201 ? 68 : 73, node.pos); - emitOptional(" ", node.label); - write(";"); - } - function emitReturnStatement(node) { - emitToken(92, node.pos); - emitOptional(" ", node.expression); - write(";"); - } - function emitWithStatement(node) { - write("with ("); - emit(node.expression); - write(")"); - emitEmbeddedStatement(node.statement); - } - function emitSwitchStatement(node) { - var endPos = emitToken(94, node.pos); - write(" "); - emitToken(17, endPos); - emit(node.expression); - endPos = emitToken(18, node.expression.end); - write(" "); - emitCaseBlock(node.caseBlock, endPos); - } - function emitCaseBlock(node, startPos) { - emitToken(15, startPos); - increaseIndent(); - emitLines(node.clauses); - decreaseIndent(); - writeLine(); - emitToken(16, node.clauses.end); - } - function nodeStartPositionsAreOnSameLine(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === - ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); - } - function nodeEndPositionsAreOnSameLine(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === - ts.getLineOfLocalPosition(currentSourceFile, node2.end); - } - function nodeEndIsOnSameLineAsNodeStart(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === - ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); - } - function emitCaseOrDefaultClause(node) { - if (node.kind === 239) { - write("case "); - emit(node.expression); - write(":"); - } - else { - write("default:"); - } - if (node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) { - write(" "); - emit(node.statements[0]); - } - else { - increaseIndent(); - emitLines(node.statements); - decreaseIndent(); - } - } - function emitThrowStatement(node) { - write("throw "); - emit(node.expression); - write(";"); - } - function emitTryStatement(node) { - write("try "); - emit(node.tryBlock); - emit(node.catchClause); - if (node.finallyBlock) { - writeLine(); - write("finally "); - emit(node.finallyBlock); - } - } - function emitCatchClause(node) { - writeLine(); - var endPos = emitToken(70, node.pos); - write(" "); - emitToken(17, endPos); - emit(node.variableDeclaration); - emitToken(18, node.variableDeclaration ? node.variableDeclaration.end : endPos); - write(" "); - emitBlock(node.block); - } - function emitDebuggerStatement(node) { - emitToken(74, node.pos); - write(";"); - } - function emitLabelledStatement(node) { - emit(node.label); - write(": "); - emit(node.statement); - } - function getContainingModule(node) { - do { - node = node.parent; - } while (node && node.kind !== 216); - return node; - } - function emitContainingModuleName(node) { - var container = getContainingModule(node); - write(container ? getGeneratedNameForNode(container) : "exports"); - } - function emitModuleMemberName(node) { - emitStart(node.name); - if (ts.getCombinedNodeFlags(node) & 1) { - var container = getContainingModule(node); - if (container) { - write(getGeneratedNameForNode(container)); - write("."); - } - else if (languageVersion < 2 && compilerOptions.module !== 4) { - write("exports."); - } - } - emitNodeWithCommentsAndWithoutSourcemap(node.name); - emitEnd(node.name); - } - function createVoidZero() { - var zero = ts.createSynthesizedNode(8); - zero.text = "0"; - var result = ts.createSynthesizedNode(175); - result.expression = zero; - return result; - } - function emitEs6ExportDefaultCompat(node) { - if (node.parent.kind === 246) { - ts.Debug.assert(!!(node.flags & 1024) || node.kind === 225); - if (compilerOptions.module === 1 || compilerOptions.module === 2 || compilerOptions.module === 3) { - if (!currentSourceFile.symbol.exports["___esModule"]) { - if (languageVersion === 1) { - write("Object.defineProperty(exports, \"__esModule\", { value: true });"); - writeLine(); - } - else if (languageVersion === 0) { - write("exports.__esModule = true;"); - writeLine(); - } - } - } - } - } - function emitExportMemberAssignment(node) { - if (node.flags & 1) { - writeLine(); - emitStart(node); - if (compilerOptions.module === 4 && node.parent === currentSourceFile) { - write(exportFunctionForFile + "(\""); - if (node.flags & 1024) { - write("default"); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(node.name); - } - write("\", "); - emitDeclarationName(node); - write(")"); - } - else { - if (node.flags & 1024) { - emitEs6ExportDefaultCompat(node); - if (languageVersion === 0) { - write("exports[\"default\"]"); - } - else { - write("exports.default"); - } - } - else { - emitModuleMemberName(node); - } - write(" = "); - emitDeclarationName(node); - } - emitEnd(node); - write(";"); - } - } - function emitExportMemberAssignments(name) { - if (compilerOptions.module === 4) { - return; - } - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { - var specifier = _b[_a]; - writeLine(); - emitStart(specifier.name); - emitContainingModuleName(specifier); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - emitEnd(specifier.name); - write(" = "); - emitExpressionIdentifier(name); - write(";"); - } - } - } - function emitExportSpecifierInSystemModule(specifier) { - ts.Debug.assert(compilerOptions.module === 4); - if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { - return; - } - writeLine(); - emitStart(specifier.name); - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - write("\", "); - emitExpressionIdentifier(specifier.propertyName || specifier.name); - write(")"); - emitEnd(specifier.name); - write(";"); - } - function emitDestructuring(root, isAssignmentExpressionStatement, value) { - var emitCount = 0; - var canDefineTempVariablesInPlace = false; - if (root.kind === 209) { - var isExported = ts.getCombinedNodeFlags(root) & 1; - var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); - canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; - } - else if (root.kind === 136) { - canDefineTempVariablesInPlace = true; - } - if (root.kind === 179) { - emitAssignmentExpression(root); - } - else { - ts.Debug.assert(!isAssignmentExpressionStatement); - emitBindingElement(root, value); - } - function emitAssignment(name, value) { - if (emitCount++) { - write(", "); - } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 209 || name.parent.kind === 161); - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(name); - write("\", "); - } - if (isVariableDeclarationOrBindingElement) { - emitModuleMemberName(name.parent); - } - else { - emit(name); - } - write(" = "); - emit(value); - if (exportChanged) { - write(")"); - } - } - function ensureIdentifier(expr, reuseIdentifierExpressions) { - if (expr.kind === 67 && reuseIdentifierExpressions) { - return expr; - } - var identifier = createTempVariable(0); - if (!canDefineTempVariablesInPlace) { - recordTempDeclaration(identifier); - } - emitAssignment(identifier, expr); - return identifier; - } - function createDefaultValueCheck(value, defaultValue) { - value = ensureIdentifier(value, true); - var equals = ts.createSynthesizedNode(179); - equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(32); - equals.right = createVoidZero(); - return createConditionalExpression(equals, defaultValue, value); - } - function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(180); - cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(52); - cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(53); - cond.whenFalse = whenFalse; - return cond; - } - function createNumericLiteral(value) { - var node = ts.createSynthesizedNode(8); - node.text = "" + value; - return node; - } - function createPropertyAccessForDestructuringProperty(object, propName) { - var syntheticName = ts.createSynthesizedNode(propName.kind); - syntheticName.text = propName.text; - if (syntheticName.kind !== 67) { - return createElementAccessExpression(object, syntheticName); - } - return createPropertyAccessExpression(object, syntheticName); - } - function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(166); - var sliceIdentifier = ts.createSynthesizedNode(67); - sliceIdentifier.text = "slice"; - call.expression = createPropertyAccessExpression(value, sliceIdentifier); - call.arguments = ts.createSynthesizedNodeArray(); - call.arguments[0] = createNumericLiteral(sliceIndex); - return call; - } - function emitObjectLiteralAssignment(target, value) { - var properties = target.properties; - if (properties.length !== 1) { - value = ensureIdentifier(value, true); - } - for (var _a = 0; _a < properties.length; _a++) { - var p = properties[_a]; - if (p.kind === 243 || p.kind === 244) { - var propName = p.name; - emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); - } - } - } - function emitArrayLiteralAssignment(target, value) { - var elements = target.elements; - if (elements.length !== 1) { - value = ensureIdentifier(value, true); - } - for (var i = 0; i < elements.length; i++) { - var e = elements[i]; - if (e.kind !== 185) { - if (e.kind !== 183) { - emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); - } - else if (i === elements.length - 1) { - emitDestructuringAssignment(e.expression, createSliceCall(value, i)); - } - } - } - } - function emitDestructuringAssignment(target, value) { - if (target.kind === 179 && target.operatorToken.kind === 55) { - value = createDefaultValueCheck(value, target.right); - target = target.left; - } - if (target.kind === 163) { - emitObjectLiteralAssignment(target, value); - } - else if (target.kind === 162) { - emitArrayLiteralAssignment(target, value); - } - else { - emitAssignment(target, value); - } - } - function emitAssignmentExpression(root) { - var target = root.left; - var value = root.right; - if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { - emit(value); - } - else if (isAssignmentExpressionStatement) { - emitDestructuringAssignment(target, value); - } - else { - if (root.parent.kind !== 170) { - write("("); - } - value = ensureIdentifier(value, true); - emitDestructuringAssignment(target, value); - write(", "); - emit(value); - if (root.parent.kind !== 170) { - write(")"); - } - } - } - function emitBindingElement(target, value) { - if (target.initializer) { - value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; - } - else if (!value) { - value = createVoidZero(); - } - if (ts.isBindingPattern(target.name)) { - var pattern = target.name; - var elements = pattern.elements; - var numElements = elements.length; - if (numElements !== 1) { - value = ensureIdentifier(value, numElements !== 0); - } - for (var i = 0; i < numElements; i++) { - var element = elements[i]; - if (pattern.kind === 159) { - var propName = element.propertyName || element.name; - emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); - } - else if (element.kind !== 185) { - if (!element.dotDotDotToken) { - emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); - } - else if (i === numElements - 1) { - emitBindingElement(element, createSliceCall(value, i)); - } - } - } - } - else { - emitAssignment(target.name, value); - } - } - } - function emitVariableDeclaration(node) { - if (ts.isBindingPattern(node.name)) { - if (languageVersion < 2) { - emitDestructuring(node, false); - } - else { - emit(node.name); - emitOptional(" = ", node.initializer); - } - } - else { - var initializer = node.initializer; - if (!initializer && languageVersion < 2) { - var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384) && - (getCombinedFlagsForIdentifier(node.name) & 16384); - if (isUninitializedLet && - node.parent.parent.kind !== 198 && - node.parent.parent.kind !== 199) { - initializer = createVoidZero(); - } - } - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(node.name); - write("\", "); - } - emitModuleMemberName(node); - emitOptional(" = ", initializer); - if (exportChanged) { - write(")"); - } - } - } - function emitExportVariableAssignments(node) { - if (node.kind === 185) { - return; - } - var name = node.name; - if (name.kind === 67) { - emitExportMemberAssignments(name); - } - else if (ts.isBindingPattern(name)) { - ts.forEach(name.elements, emitExportVariableAssignments); - } - } - function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 209 && node.parent.kind !== 161)) { - return 0; - } - return ts.getCombinedNodeFlags(node.parent); - } - function isES6ExportedDeclaration(node) { - return !!(node.flags & 1) && - languageVersion >= 2 && - node.parent.kind === 246; - } - function emitVariableStatement(node) { - var startIsEmitted = false; - if (node.flags & 1) { - if (isES6ExportedDeclaration(node)) { - write("export "); - startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); - } - } - else { - startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); - } - if (startIsEmitted) { - emitCommaList(node.declarationList.declarations); - write(";"); - } - else { - var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); - if (atLeastOneItem) { - write(";"); - } - } - if (languageVersion < 2 && node.parent === currentSourceFile) { - ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); - } - } - function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { - if (!(node.flags & 1)) { - return true; - } - if (isES6ExportedDeclaration(node)) { - return true; - } - for (var _a = 0, _b = node.declarationList.declarations; _a < _b.length; _a++) { - var declaration = _b[_a]; - if (declaration.initializer) { - return true; - } - } - return false; - } - function emitParameter(node) { - if (languageVersion < 2) { - if (ts.isBindingPattern(node.name)) { - var name_23 = createTempVariable(0); - if (!tempParameters) { - tempParameters = []; - } - tempParameters.push(name_23); - emit(name_23); - } - else { - emit(node.name); - } - } - else { - if (node.dotDotDotToken) { - write("..."); - } - emit(node.name); - emitOptional(" = ", node.initializer); - } - } - function emitDefaultValueAssignments(node) { - if (languageVersion < 2) { - var tempIndex = 0; - ts.forEach(node.parameters, function (parameter) { - if (parameter.dotDotDotToken) { - return; - } - var paramName = parameter.name, initializer = parameter.initializer; - if (ts.isBindingPattern(paramName)) { - var hasBindingElements = paramName.elements.length > 0; - if (hasBindingElements || initializer) { - writeLine(); - write("var "); - if (hasBindingElements) { - emitDestructuring(parameter, false, tempParameters[tempIndex]); - } - else { - emit(tempParameters[tempIndex]); - write(" = "); - emit(initializer); - } - write(";"); - tempIndex++; - } - } - else if (initializer) { - writeLine(); - emitStart(parameter); - write("if ("); - emitNodeWithoutSourceMap(paramName); - write(" === void 0)"); - emitEnd(parameter); - write(" { "); - emitStart(parameter); - emitNodeWithCommentsAndWithoutSourcemap(paramName); - write(" = "); - emitNodeWithCommentsAndWithoutSourcemap(initializer); - emitEnd(parameter); - write("; }"); - } - }); - } - } - function emitRestParameter(node) { - if (languageVersion < 2 && ts.hasRestParameter(node)) { - var restIndex = node.parameters.length - 1; - var restParam = node.parameters[restIndex]; - if (ts.isBindingPattern(restParam.name)) { - return; - } - var tempName = createTempVariable(268435456).text; - writeLine(); - emitLeadingComments(restParam); - emitStart(restParam); - write("var "); - emitNodeWithCommentsAndWithoutSourcemap(restParam.name); - write(" = [];"); - emitEnd(restParam); - emitTrailingComments(restParam); - writeLine(); - write("for ("); - emitStart(restParam); - write("var " + tempName + " = " + restIndex + ";"); - emitEnd(restParam); - write(" "); - emitStart(restParam); - write(tempName + " < arguments.length;"); - emitEnd(restParam); - write(" "); - emitStart(restParam); - write(tempName + "++"); - emitEnd(restParam); - write(") {"); - increaseIndent(); - writeLine(); - emitStart(restParam); - emitNodeWithCommentsAndWithoutSourcemap(restParam.name); - write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); - emitEnd(restParam); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function emitAccessor(node) { - write(node.kind === 143 ? "get " : "set "); - emit(node.name); - emitSignatureAndBody(node); - } - function shouldEmitAsArrowFunction(node) { - return node.kind === 172 && languageVersion >= 2; - } - function emitDeclarationName(node) { - if (node.name) { - emitNodeWithCommentsAndWithoutSourcemap(node.name); - } - else { - write(getGeneratedNameForNode(node)); - } - } - function shouldEmitFunctionName(node) { - if (node.kind === 171) { - return !!node.name; - } - if (node.kind === 211) { - return !!node.name || languageVersion < 2; - } - } - function emitFunctionDeclaration(node) { - if (ts.nodeIsMissing(node.body)) { - return emitOnlyPinnedOrTripleSlashComments(node); - } - if (node.kind !== 141 && node.kind !== 140 && - node.parent && node.parent.kind !== 243 && - node.parent.kind !== 166) { - emitLeadingComments(node); - } - emitStart(node); - if (!shouldEmitAsArrowFunction(node)) { - if (isES6ExportedDeclaration(node)) { - write("export "); - if (node.flags & 1024) { - write("default "); - } - } - write("function"); - if (languageVersion >= 2 && node.asteriskToken) { - write("*"); - } - write(" "); - } - if (shouldEmitFunctionName(node)) { - emitDeclarationName(node); - } - emitSignatureAndBody(node); - if (languageVersion < 2 && node.kind === 211 && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } - emitEnd(node); - if (node.kind !== 141 && node.kind !== 140) { - emitTrailingComments(node); - } - } - function emitCaptureThisForNodeIfNecessary(node) { - if (resolver.getNodeCheckFlags(node) & 4) { - writeLine(); - emitStart(node); - write("var _this = this;"); - emitEnd(node); - } - } - function emitSignatureParameters(node) { - increaseIndent(); - write("("); - if (node) { - var parameters = node.parameters; - var omitCount = languageVersion < 2 && ts.hasRestParameter(node) ? 1 : 0; - emitList(parameters, 0, parameters.length - omitCount, false, false); - } - write(")"); - decreaseIndent(); - } - function emitSignatureParametersForArrow(node) { - if (node.parameters.length === 1 && node.pos === node.parameters[0].pos) { - emit(node.parameters[0]); - return; - } - emitSignatureParameters(node); - } - function emitAsyncFunctionBodyForES6(node) { - var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 172; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096) !== 0; - var args; - if (!isArrowFunction) { - write(" {"); - increaseIndent(); - writeLine(); - write("return"); - } - write(" __awaiter(this"); - if (hasLexicalArguments) { - write(", arguments"); - } - else { - write(", void 0"); - } - if (promiseConstructor) { - write(", "); - emitNodeWithoutSourceMap(promiseConstructor); - } - else { - write(", Promise"); - } - if (hasLexicalArguments) { - write(", function* (_arguments)"); - } - else { - write(", function* ()"); - } - emitFunctionBody(node); - write(")"); - if (!isArrowFunction) { - write(";"); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function emitFunctionBody(node) { - if (!node.body) { - write(" { }"); - } - else { - if (node.body.kind === 190) { - emitBlockFunctionBody(node, node.body); - } - else { - emitExpressionFunctionBody(node, node.body); - } - } - } - function emitSignatureAndBody(node) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - if (shouldEmitAsArrowFunction(node)) { - emitSignatureParametersForArrow(node); - write(" =>"); - } - else { - emitSignatureParameters(node); - } - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync && languageVersion === 2) { - emitAsyncFunctionBodyForES6(node); - } - else { - emitFunctionBody(node); - } - if (!isES6ExportedDeclaration(node)) { - emitExportMemberAssignment(node); - } - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - } - function emitFunctionBodyPreamble(node) { - emitCaptureThisForNodeIfNecessary(node); - emitDefaultValueAssignments(node); - emitRestParameter(node); - } - function emitExpressionFunctionBody(node, body) { - if (languageVersion < 2 || node.flags & 512) { - emitDownLevelExpressionFunctionBody(node, body); - return; - } - write(" "); - var current = body; - while (current.kind === 169) { - current = current.expression; - } - emitParenthesizedIf(body, current.kind === 163); - } - function emitDownLevelExpressionFunctionBody(node, body) { - write(" {"); - scopeEmitStart(node); - increaseIndent(); - var outPos = writer.getTextPos(); - emitDetachedComments(node.body); - emitFunctionBodyPreamble(node); - var preambleEmitted = writer.getTextPos() !== outPos; - decreaseIndent(); - if (!preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) { - write(" "); - emitStart(body); - write("return "); - emit(body); - emitEnd(body); - write(";"); - emitTempDeclarations(false); - write(" "); - } - else { - increaseIndent(); - writeLine(); - emitLeadingComments(node.body); - write("return "); - emit(body); - write(";"); - emitTrailingComments(node.body); - emitTempDeclarations(true); - decreaseIndent(); - writeLine(); - } - emitStart(node.body); - write("}"); - emitEnd(node.body); - scopeEmitEnd(); - } - function emitBlockFunctionBody(node, body) { - write(" {"); - scopeEmitStart(node); - var initialTextPos = writer.getTextPos(); - increaseIndent(); - emitDetachedComments(body.statements); - var startIndex = emitDirectivePrologues(body.statements, true); - emitFunctionBodyPreamble(node); - decreaseIndent(); - var preambleEmitted = writer.getTextPos() !== initialTextPos; - if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { - for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { - var statement = _b[_a]; - write(" "); - emit(statement); - } - emitTempDeclarations(false); - write(" "); - emitLeadingCommentsOfPosition(body.statements.end); - } - else { - increaseIndent(); - emitLinesStartingAt(body.statements, startIndex); - emitTempDeclarations(true); - writeLine(); - emitLeadingCommentsOfPosition(body.statements.end); - decreaseIndent(); - } - emitToken(16, body.statements.end); - scopeEmitEnd(); - } - function findInitialSuperCall(ctor) { - if (ctor.body) { - var statement = ctor.body.statements[0]; - if (statement && statement.kind === 193) { - var expr = statement.expression; - if (expr && expr.kind === 166) { - var func = expr.expression; - if (func && func.kind === 93) { - return statement; - } - } - } - } - } - function emitParameterPropertyAssignments(node) { - ts.forEach(node.parameters, function (param) { - if (param.flags & 112) { - writeLine(); - emitStart(param); - emitStart(param.name); - write("this."); - emitNodeWithoutSourceMap(param.name); - emitEnd(param.name); - write(" = "); - emit(param.name); - write(";"); - emitEnd(param); - } - }); - } - function emitMemberAccessForPropertyName(memberName) { - if (memberName.kind === 9 || memberName.kind === 8) { - write("["); - emitNodeWithCommentsAndWithoutSourcemap(memberName); - write("]"); - } - else if (memberName.kind === 134) { - emitComputedPropertyName(memberName); - } - else { - write("."); - emitNodeWithCommentsAndWithoutSourcemap(memberName); - } - } - function getInitializedProperties(node, isStatic) { - var properties = []; - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if (member.kind === 139 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { - properties.push(member); - } - } - return properties; - } - function emitPropertyDeclarations(node, properties) { - for (var _a = 0; _a < properties.length; _a++) { - var property = properties[_a]; - emitPropertyDeclaration(node, property); - } - } - function emitPropertyDeclaration(node, property, receiver, isExpression) { - writeLine(); - emitLeadingComments(property); - emitStart(property); - emitStart(property.name); - if (receiver) { - emit(receiver); - } - else { - if (property.flags & 128) { - emitDeclarationName(node); - } - else { - write("this"); - } - } - emitMemberAccessForPropertyName(property.name); - emitEnd(property.name); - write(" = "); - emit(property.initializer); - if (!isExpression) { - write(";"); - } - emitEnd(property); - emitTrailingComments(property); - } - function emitMemberFunctionsForES5AndLower(node) { - ts.forEach(node.members, function (member) { - if (member.kind === 189) { - writeLine(); - write(";"); - } - else if (member.kind === 141 || node.kind === 140) { - if (!member.body) { - return emitOnlyPinnedOrTripleSlashComments(member); - } - writeLine(); - emitLeadingComments(member); - emitStart(member); - emitStart(member.name); - emitClassMemberPrefix(node, member); - emitMemberAccessForPropertyName(member.name); - emitEnd(member.name); - write(" = "); - emitFunctionDeclaration(member); - emitEnd(member); - write(";"); - emitTrailingComments(member); - } - else if (member.kind === 143 || member.kind === 144) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member === accessors.firstAccessor) { - writeLine(); - emitStart(member); - write("Object.defineProperty("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write(", {"); - increaseIndent(); - if (accessors.getAccessor) { - writeLine(); - emitLeadingComments(accessors.getAccessor); - write("get: "); - emitStart(accessors.getAccessor); - write("function "); - emitSignatureAndBody(accessors.getAccessor); - emitEnd(accessors.getAccessor); - emitTrailingComments(accessors.getAccessor); - write(","); - } - if (accessors.setAccessor) { - writeLine(); - emitLeadingComments(accessors.setAccessor); - write("set: "); - emitStart(accessors.setAccessor); - write("function "); - emitSignatureAndBody(accessors.setAccessor); - emitEnd(accessors.setAccessor); - emitTrailingComments(accessors.setAccessor); - write(","); - } - writeLine(); - write("enumerable: true,"); - writeLine(); - write("configurable: true"); - decreaseIndent(); - writeLine(); - write("});"); - emitEnd(member); - } - } - }); - } - function emitMemberFunctionsForES6AndHigher(node) { - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if ((member.kind === 141 || node.kind === 140) && !member.body) { - emitOnlyPinnedOrTripleSlashComments(member); - } - else if (member.kind === 141 || - member.kind === 143 || - member.kind === 144) { - writeLine(); - emitLeadingComments(member); - emitStart(member); - if (member.flags & 128) { - write("static "); - } - if (member.kind === 143) { - write("get "); - } - else if (member.kind === 144) { - write("set "); - } - if (member.asteriskToken) { - write("*"); - } - emit(member.name); - emitSignatureAndBody(member); - emitEnd(member); - emitTrailingComments(member); - } - else if (member.kind === 189) { - writeLine(); - write(";"); - } - } - } - function emitConstructor(node, baseTypeElement) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - emitConstructorWorker(node, baseTypeElement); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - } - function emitConstructorWorker(node, baseTypeElement) { - var hasInstancePropertyWithInitializer = false; - ts.forEach(node.members, function (member) { - if (member.kind === 142 && !member.body) { - emitOnlyPinnedOrTripleSlashComments(member); - } - if (member.kind === 139 && member.initializer && (member.flags & 128) === 0) { - hasInstancePropertyWithInitializer = true; - } - }); - var ctor = ts.getFirstConstructorWithBody(node); - if (languageVersion >= 2 && !ctor && !hasInstancePropertyWithInitializer) { - return; - } - if (ctor) { - emitLeadingComments(ctor); - } - emitStart(ctor || node); - if (languageVersion < 2) { - write("function "); - emitDeclarationName(node); - emitSignatureParameters(ctor); - } - else { - write("constructor"); - if (ctor) { - emitSignatureParameters(ctor); - } - else { - if (baseTypeElement) { - write("(...args)"); - } - else { - write("()"); - } - } - } - var startIndex = 0; - write(" {"); - scopeEmitStart(node, "constructor"); - increaseIndent(); - if (ctor) { - startIndex = emitDirectivePrologues(ctor.body.statements, true); - emitDetachedComments(ctor.body.statements); - } - emitCaptureThisForNodeIfNecessary(node); - var superCall; - if (ctor) { - emitDefaultValueAssignments(ctor); - emitRestParameter(ctor); - if (baseTypeElement) { - superCall = findInitialSuperCall(ctor); - if (superCall) { - writeLine(); - emit(superCall); - } - } - emitParameterPropertyAssignments(ctor); - } - else { - if (baseTypeElement) { - writeLine(); - emitStart(baseTypeElement); - if (languageVersion < 2) { - write("_super.apply(this, arguments);"); - } - else { - write("super(...args);"); - } - emitEnd(baseTypeElement); - } - } - emitPropertyDeclarations(node, getInitializedProperties(node, false)); - if (ctor) { - var statements = ctor.body.statements; - if (superCall) { - statements = statements.slice(1); - } - emitLinesStartingAt(statements, startIndex); - } - emitTempDeclarations(true); - writeLine(); - if (ctor) { - emitLeadingCommentsOfPosition(ctor.body.statements.end); - } - decreaseIndent(); - emitToken(16, ctor ? ctor.body.statements.end : node.members.end); - scopeEmitEnd(); - emitEnd(ctor || node); - if (ctor) { - emitTrailingComments(ctor); - } - } - function emitClassExpression(node) { - return emitClassLikeDeclaration(node); - } - function emitClassDeclaration(node) { - return emitClassLikeDeclaration(node); - } - function emitClassLikeDeclaration(node) { - if (languageVersion < 2) { - emitClassLikeDeclarationBelowES6(node); - } - else { - emitClassLikeDeclarationForES6AndHigher(node); - } - } - function emitClassLikeDeclarationForES6AndHigher(node) { - var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 212) { - if (thisNodeIsDecorated) { - if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { - write("export "); - } - write("let "); - emitDeclarationName(node); - write(" = "); - } - else if (isES6ExportedDeclaration(node)) { - write("export "); - if (node.flags & 1024) { - write("default "); - } - } - } - var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 184; - var tempVariable; - if (isClassExpressionWithStaticProperties) { - tempVariable = createAndRecordTempVariable(0); - write("("); - increaseIndent(); - emit(tempVariable); - write(" = "); - } - write("class"); - if ((node.name || !(node.flags & 1024)) && !thisNodeIsDecorated) { - write(" "); - emitDeclarationName(node); - } - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - write(" extends "); - emit(baseTypeNode.expression); - } - write(" {"); - increaseIndent(); - scopeEmitStart(node); - writeLine(); - emitConstructor(node, baseTypeNode); - emitMemberFunctionsForES6AndHigher(node); - decreaseIndent(); - writeLine(); - emitToken(16, node.members.end); - scopeEmitEnd(); - if (thisNodeIsDecorated) { - write(";"); - } - if (isClassExpressionWithStaticProperties) { - for (var _a = 0; _a < staticProperties.length; _a++) { - var property = staticProperties[_a]; - write(","); - writeLine(); - emitPropertyDeclaration(node, property, tempVariable, true); - } - write(","); - writeLine(); - emit(tempVariable); - decreaseIndent(); - write(")"); - } - else { - writeLine(); - emitPropertyDeclarations(node, staticProperties); - emitDecoratorsOfClass(node); - } - if (!isES6ExportedDeclaration(node) && (node.flags & 1)) { - writeLine(); - emitStart(node); - emitModuleMemberName(node); - write(" = "); - emitDeclarationName(node); - emitEnd(node); - write(";"); - } - else if (isES6ExportedDeclaration(node) && (node.flags & 1024) && thisNodeIsDecorated) { - writeLine(); - write("export default "); - emitDeclarationName(node); - write(";"); - } - } - function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 212) { - if (!shouldHoistDeclarationInSystemJsModule(node)) { - write("var "); - } - emitDeclarationName(node); - write(" = "); - } - write("(function ("); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - write("_super"); - } - write(") {"); - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - var saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - computedPropertyNamesToGeneratedNames = undefined; - increaseIndent(); - scopeEmitStart(node); - if (baseTypeNode) { - writeLine(); - emitStart(baseTypeNode); - write("__extends("); - emitDeclarationName(node); - write(", _super);"); - emitEnd(baseTypeNode); - } - writeLine(); - emitConstructor(node, baseTypeNode); - emitMemberFunctionsForES5AndLower(node); - emitPropertyDeclarations(node, getInitializedProperties(node, true)); - writeLine(); - emitDecoratorsOfClass(node); - writeLine(); - emitToken(16, node.members.end, function () { - write("return "); - emitDeclarationName(node); - }); - write(";"); - emitTempDeclarations(true); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; - decreaseIndent(); - writeLine(); - emitToken(16, node.members.end); - scopeEmitEnd(); - emitStart(node); - write(")("); - if (baseTypeNode) { - emit(baseTypeNode.expression); - } - write(")"); - if (node.kind === 212) { - write(";"); - } - emitEnd(node); - if (node.kind === 212) { - emitExportMemberAssignment(node); - } - if (languageVersion < 2 && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } - } - function emitClassMemberPrefix(node, member) { - emitDeclarationName(node); - if (!(member.flags & 128)) { - write(".prototype"); - } - } - function emitDecoratorsOfClass(node) { - emitDecoratorsOfMembers(node, 0); - emitDecoratorsOfMembers(node, 128); - emitDecoratorsOfConstructor(node); - } - function emitDecoratorsOfConstructor(node) { - var decorators = node.decorators; - var constructor = ts.getFirstConstructorWithBody(node); - var hasDecoratedParameters = constructor && ts.forEach(constructor.parameters, ts.nodeIsDecorated); - if (!decorators && !hasDecoratedParameters) { - return; - } - writeLine(); - emitStart(node); - emitDeclarationName(node); - write(" = __decorate(["); - increaseIndent(); - writeLine(); - var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); - argumentsWritten += emitDecoratorsOfParameters(constructor, argumentsWritten > 0); - emitSerializedTypeMetadata(node, argumentsWritten >= 0); - decreaseIndent(); - writeLine(); - write("], "); - emitDeclarationName(node); - write(");"); - emitEnd(node); - writeLine(); - } - function emitDecoratorsOfMembers(node, staticFlag) { - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if ((member.flags & 128) !== staticFlag) { - continue; - } - if (!ts.nodeCanBeDecorated(member)) { - continue; - } - if (!ts.nodeOrChildIsDecorated(member)) { - continue; - } - var decorators = void 0; - var functionLikeMember = void 0; - if (ts.isAccessor(member)) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member !== accessors.firstAccessor) { - continue; - } - decorators = accessors.firstAccessor.decorators; - if (!decorators && accessors.secondAccessor) { - decorators = accessors.secondAccessor.decorators; - } - functionLikeMember = accessors.setAccessor; - } - else { - decorators = member.decorators; - if (member.kind === 141) { - functionLikeMember = member; - } - } - writeLine(); - emitStart(member); - if (member.kind !== 139) { - write("Object.defineProperty("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write(","); - increaseIndent(); - writeLine(); - } - write("__decorate(["); - increaseIndent(); - writeLine(); - var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); - argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); - emitSerializedTypeMetadata(member, argumentsWritten > 0); - decreaseIndent(); - writeLine(); - write("], "); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - if (member.kind !== 139) { - write(", Object.getOwnPropertyDescriptor("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write("))"); - decreaseIndent(); - } - write(");"); - emitEnd(member); - writeLine(); - } - } - function emitDecoratorsOfParameters(node, leadingComma) { - var argumentsWritten = 0; - if (node) { - var parameterIndex = 0; - for (var _a = 0, _b = node.parameters; _a < _b.length; _a++) { - var parameter = _b[_a]; - if (ts.nodeIsDecorated(parameter)) { - var decorators = parameter.decorators; - argumentsWritten += emitList(decorators, 0, decorators.length, true, false, leadingComma, true, function (decorator) { - emitStart(decorator); - write("__param(" + parameterIndex + ", "); - emit(decorator.expression); - write(")"); - emitEnd(decorator); - }); - leadingComma = true; - } - ++parameterIndex; - } - } - return argumentsWritten; - } - function shouldEmitTypeMetadata(node) { - switch (node.kind) { - case 141: - case 143: - case 144: - case 139: - return true; - } - return false; - } - function shouldEmitReturnTypeMetadata(node) { - switch (node.kind) { - case 141: - return true; - } - return false; - } - function shouldEmitParamTypesMetadata(node) { - switch (node.kind) { - case 212: - case 141: - case 144: - return true; - } - return false; - } - function emitSerializedTypeOfNode(node) { - switch (node.kind) { - case 212: - write("Function"); - return; - case 139: - emitSerializedTypeNode(node.type); - return; - case 136: - emitSerializedTypeNode(node.type); - return; - case 143: - emitSerializedTypeNode(node.type); - return; - case 144: - emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - return; - } - if (ts.isFunctionLike(node)) { - write("Function"); - return; - } - write("void 0"); - } - function emitSerializedTypeNode(node) { - if (node) { - switch (node.kind) { - case 101: - write("void 0"); - return; - case 158: - emitSerializedTypeNode(node.type); - return; - case 150: - case 151: - write("Function"); - return; - case 154: - case 155: - write("Array"); - return; - case 148: - case 118: - write("Boolean"); - return; - case 128: - case 9: - write("String"); - return; - case 126: - write("Number"); - return; - case 129: - write("Symbol"); - return; - case 149: - emitSerializedTypeReferenceNode(node); - return; - case 152: - case 153: - case 156: - case 157: - case 115: - break; - default: - ts.Debug.fail("Cannot serialize unexpected type node."); - break; - } - } - write("Object"); - } - function emitSerializedTypeReferenceNode(node) { - var location = node.parent; - while (ts.isDeclaration(location) || ts.isTypeNode(location)) { - location = location.parent; - } - var typeName = ts.cloneEntityName(node.typeName); - typeName.parent = location; - var result = resolver.getTypeReferenceSerializationKind(typeName); - switch (result) { - case ts.TypeReferenceSerializationKind.Unknown: - var temp = createAndRecordTempVariable(0); - write("(typeof ("); - emitNodeWithoutSourceMap(temp); - write(" = "); - emitEntityNameAsExpression(typeName, true); - write(") === 'function' && "); - emitNodeWithoutSourceMap(temp); - write(") || Object"); - break; - case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: - emitEntityNameAsExpression(typeName, false); - break; - case ts.TypeReferenceSerializationKind.VoidType: - write("void 0"); - break; - case ts.TypeReferenceSerializationKind.BooleanType: - write("Boolean"); - break; - case ts.TypeReferenceSerializationKind.NumberLikeType: - write("Number"); - break; - case ts.TypeReferenceSerializationKind.StringLikeType: - write("String"); - break; - case ts.TypeReferenceSerializationKind.ArrayLikeType: - write("Array"); - break; - case ts.TypeReferenceSerializationKind.ESSymbolType: - if (languageVersion < 2) { - write("typeof Symbol === 'function' ? Symbol : Object"); - } - else { - write("Symbol"); - } - break; - case ts.TypeReferenceSerializationKind.TypeWithCallSignature: - write("Function"); - break; - case ts.TypeReferenceSerializationKind.ObjectType: - write("Object"); - break; - } - } - function emitSerializedParameterTypesOfNode(node) { - if (node) { - var valueDeclaration; - if (node.kind === 212) { - valueDeclaration = ts.getFirstConstructorWithBody(node); - } - else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { - valueDeclaration = node; - } - if (valueDeclaration) { - var parameters = valueDeclaration.parameters; - var parameterCount = parameters.length; - if (parameterCount > 0) { - for (var i = 0; i < parameterCount; i++) { - if (i > 0) { - write(", "); - } - if (parameters[i].dotDotDotToken) { - var parameterType = parameters[i].type; - if (parameterType.kind === 154) { - parameterType = parameterType.elementType; - } - else if (parameterType.kind === 149 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { - parameterType = parameterType.typeArguments[0]; - } - else { - parameterType = undefined; - } - emitSerializedTypeNode(parameterType); - } - else { - emitSerializedTypeOfNode(parameters[i]); - } - } - } - } - } - } - function emitSerializedReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node) && node.type) { - emitSerializedTypeNode(node.type); - return; - } - write("void 0"); - } - function emitSerializedTypeMetadata(node, writeComma) { - var argumentsWritten = 0; - if (compilerOptions.emitDecoratorMetadata) { - if (shouldEmitTypeMetadata(node)) { - if (writeComma) { - write(", "); - } - writeLine(); - write("__metadata('design:type', "); - emitSerializedTypeOfNode(node); - write(")"); - argumentsWritten++; - } - if (shouldEmitParamTypesMetadata(node)) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:paramtypes', ["); - emitSerializedParameterTypesOfNode(node); - write("])"); - argumentsWritten++; - } - if (shouldEmitReturnTypeMetadata(node)) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:returntype', "); - emitSerializedReturnTypeOfNode(node); - write(")"); - argumentsWritten++; - } - } - return argumentsWritten; - } - function emitInterfaceDeclaration(node) { - emitOnlyPinnedOrTripleSlashComments(node); - } - function shouldEmitEnumDeclaration(node) { - var isConstEnum = ts.isConst(node); - return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; - } - function emitEnumDeclaration(node) { - if (!shouldEmitEnumDeclaration(node)) { - return; - } - if (!shouldHoistDeclarationInSystemJsModule(node)) { - if (!(node.flags & 1) || isES6ExportedDeclaration(node)) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - } - write("var "); - emit(node.name); - emitEnd(node); - write(";"); - } - } - writeLine(); - emitStart(node); - write("(function ("); - emitStart(node.name); - write(getGeneratedNameForNode(node)); - emitEnd(node.name); - write(") {"); - increaseIndent(); - scopeEmitStart(node); - emitLines(node.members); - decreaseIndent(); - writeLine(); - emitToken(16, node.members.end); - scopeEmitEnd(); - write(")("); - emitModuleMemberName(node); - write(" || ("); - emitModuleMemberName(node); - write(" = {}));"); - emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 1 && !shouldHoistDeclarationInSystemJsModule(node)) { - writeLine(); - emitStart(node); - write("var "); - emit(node.name); - write(" = "); - emitModuleMemberName(node); - emitEnd(node); - write(";"); - } - if (languageVersion < 2 && node.parent === currentSourceFile) { - if (compilerOptions.module === 4 && (node.flags & 1)) { - writeLine(); - write(exportFunctionForFile + "(\""); - emitDeclarationName(node); - write("\", "); - emitDeclarationName(node); - write(");"); - } - emitExportMemberAssignments(node.name); - } - } - function emitEnumMember(node) { - var enumParent = node.parent; - emitStart(node); - write(getGeneratedNameForNode(enumParent)); - write("["); - write(getGeneratedNameForNode(enumParent)); - write("["); - emitExpressionForPropertyName(node.name); - write("] = "); - writeEnumMemberDeclarationValue(node); - write("] = "); - emitExpressionForPropertyName(node.name); - emitEnd(node); - write(";"); - } - function writeEnumMemberDeclarationValue(member) { - var value = resolver.getConstantValue(member); - if (value !== undefined) { - write(value.toString()); - return; - } - else if (member.initializer) { - emit(member.initializer); - } - else { - write("undefined"); - } - } - function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 216) { - var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); - return recursiveInnerModule || moduleDeclaration.body; - } - } - function shouldEmitModuleDeclaration(node) { - return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); - } - function isModuleMergedWithES6Class(node) { - return languageVersion === 2 && !!(resolver.getNodeCheckFlags(node) & 32768); - } - function emitModuleDeclaration(node) { - var shouldEmit = shouldEmitModuleDeclaration(node); - if (!shouldEmit) { - return emitOnlyPinnedOrTripleSlashComments(node); - } - var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); - var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); - if (emitVarForModule) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - } - write("var "); - emit(node.name); - write(";"); - emitEnd(node); - writeLine(); - } - emitStart(node); - write("(function ("); - emitStart(node.name); - write(getGeneratedNameForNode(node)); - emitEnd(node.name); - write(") "); - if (node.body.kind === 217) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - tempFlags = 0; - tempVariables = undefined; - emit(node.body); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - } - else { - write("{"); - increaseIndent(); - scopeEmitStart(node); - emitCaptureThisForNodeIfNecessary(node); - writeLine(); - emit(node.body); - decreaseIndent(); - writeLine(); - var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(16, moduleBlock.statements.end); - scopeEmitEnd(); - } - write(")("); - if ((node.flags & 1) && !isES6ExportedDeclaration(node)) { - emit(node.name); - write(" = "); - } - emitModuleMemberName(node); - write(" || ("); - emitModuleMemberName(node); - write(" = {}));"); - emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 67 && node.parent === currentSourceFile) { - if (compilerOptions.module === 4 && (node.flags & 1)) { - writeLine(); - write(exportFunctionForFile + "(\""); - emitDeclarationName(node); - write("\", "); - emitDeclarationName(node); - write(");"); - } - emitExportMemberAssignments(node.name); - } - } - function tryRenameExternalModule(moduleName) { - if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { - return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; - } - return undefined; - } - function emitRequire(moduleName) { - if (moduleName.kind === 9) { - write("require("); - var text = tryRenameExternalModule(moduleName); - if (text) { - write(text); - } - else { - emitStart(moduleName); - emitLiteral(moduleName); - emitEnd(moduleName); - } - emitToken(18, moduleName.end); - } - else { - write("require()"); - } - } - function getNamespaceDeclarationNode(node) { - if (node.kind === 219) { - return node; - } - var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 222) { - return importClause.namedBindings; - } - } - function isDefaultImport(node) { - return node.kind === 220 && node.importClause && !!node.importClause.name; - } - function emitExportImportAssignments(node) { - if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { - emitExportMemberAssignments(node.name); - } - ts.forEachChild(node, emitExportImportAssignments); - } - function emitImportDeclaration(node) { - if (languageVersion < 2) { - return emitExternalImportDeclaration(node); - } - if (node.importClause) { - var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); - var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, true); - if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { - write("import "); - emitStart(node.importClause); - if (shouldEmitDefaultBindings) { - emit(node.importClause.name); - if (shouldEmitNamedBindings) { - write(", "); - } - } - if (shouldEmitNamedBindings) { - emitLeadingComments(node.importClause.namedBindings); - emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 222) { - write("* as "); - emit(node.importClause.namedBindings.name); - } - else { - write("{ "); - emitExportOrImportSpecifierList(node.importClause.namedBindings.elements, resolver.isReferencedAliasDeclaration); - write(" }"); - } - emitEnd(node.importClause.namedBindings); - emitTrailingComments(node.importClause.namedBindings); - } - emitEnd(node.importClause); - write(" from "); - emit(node.moduleSpecifier); - write(";"); - } - } - else { - write("import "); - emit(node.moduleSpecifier); - write(";"); - } - } - function emitExternalImportDeclaration(node) { - if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 219 && (node.flags & 1) !== 0; - var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (compilerOptions.module !== 2) { - emitLeadingComments(node); - emitStart(node); - if (namespaceDeclaration && !isDefaultImport(node)) { - if (!isExportedImport) - write("var "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - } - else { - var isNakedImport = 220 && !node.importClause; - if (!isNakedImport) { - write("var "); - write(getGeneratedNameForNode(node)); - write(" = "); - } - } - emitRequire(ts.getExternalModuleName(node)); - if (namespaceDeclaration && isDefaultImport(node)) { - write(", "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - write(getGeneratedNameForNode(node)); - } - write(";"); - emitEnd(node); - emitExportImportAssignments(node); - emitTrailingComments(node); - } - else { - if (isExportedImport) { - emitModuleMemberName(namespaceDeclaration); - write(" = "); - emit(namespaceDeclaration.name); - write(";"); - } - else if (namespaceDeclaration && isDefaultImport(node)) { - write("var "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - write(getGeneratedNameForNode(node)); - write(";"); - } - emitExportImportAssignments(node); - } - } - } - function emitImportEqualsDeclaration(node) { - if (ts.isExternalModuleImportEqualsDeclaration(node)) { - emitExternalImportDeclaration(node); - return; - } - if (resolver.isReferencedAliasDeclaration(node) || - (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { - emitLeadingComments(node); - emitStart(node); - var variableDeclarationIsHoisted = shouldHoistVariable(node, true); - var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, true); - if (!variableDeclarationIsHoisted) { - ts.Debug.assert(!isExported); - if (isES6ExportedDeclaration(node)) { - write("export "); - write("var "); - } - else if (!(node.flags & 1)) { - write("var "); - } - } - if (isExported) { - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.name); - write("\", "); - } - emitModuleMemberName(node); - write(" = "); - emit(node.moduleReference); - if (isExported) { - write(")"); - } - write(";"); - emitEnd(node); - emitExportImportAssignments(node); - emitTrailingComments(node); - } - } - function emitExportDeclaration(node) { - ts.Debug.assert(compilerOptions.module !== 4); - if (languageVersion < 2) { - if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { - emitStart(node); - var generatedName = getGeneratedNameForNode(node); - if (node.exportClause) { - if (compilerOptions.module !== 2) { - write("var "); - write(generatedName); - write(" = "); - emitRequire(ts.getExternalModuleName(node)); - write(";"); - } - for (var _a = 0, _b = node.exportClause.elements; _a < _b.length; _a++) { - var specifier = _b[_a]; - if (resolver.isValueAliasDeclaration(specifier)) { - writeLine(); - emitStart(specifier); - emitContainingModuleName(specifier); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - write(" = "); - write(generatedName); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); - write(";"); - emitEnd(specifier); - } - } - } - else { - writeLine(); - write("__export("); - if (compilerOptions.module !== 2) { - emitRequire(ts.getExternalModuleName(node)); - } - else { - write(generatedName); - } - write(");"); - } - emitEnd(node); - } - } - else { - if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - write("export "); - if (node.exportClause) { - write("{ "); - emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); - write(" }"); - } - else { - write("*"); - } - if (node.moduleSpecifier) { - write(" from "); - emit(node.moduleSpecifier); - } - write(";"); - } - } - } - function emitExportOrImportSpecifierList(specifiers, shouldEmit) { - ts.Debug.assert(languageVersion >= 2); - var needsComma = false; - for (var _a = 0; _a < specifiers.length; _a++) { - var specifier = specifiers[_a]; - if (shouldEmit(specifier)) { - if (needsComma) { - write(", "); - } - if (specifier.propertyName) { - emit(specifier.propertyName); - write(" as "); - } - emit(specifier.name); - needsComma = true; - } - } - } - function emitExportAssignment(node) { - if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { - if (languageVersion >= 2) { - writeLine(); - emitStart(node); - write("export default "); - var expression = node.expression; - emit(expression); - if (expression.kind !== 211 && - expression.kind !== 212) { - write(";"); - } - emitEnd(node); - } - else { - writeLine(); - emitStart(node); - if (compilerOptions.module === 4) { - write(exportFunctionForFile + "(\"default\","); - emit(node.expression); - write(")"); - } - else { - emitEs6ExportDefaultCompat(node); - emitContainingModuleName(node); - if (languageVersion === 0) { - write("[\"default\"] = "); - } - else { - write(".default = "); - } - emit(node.expression); - } - write(";"); - emitEnd(node); - } - } - } - function collectExternalModuleInfo(sourceFile) { - externalImports = []; - exportSpecifiers = {}; - exportEquals = undefined; - hasExportStars = false; - for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { - var node = _b[_a]; - switch (node.kind) { - case 220: - if (!node.importClause || - resolver.isReferencedAliasDeclaration(node.importClause, true)) { - externalImports.push(node); - } - break; - case 219: - if (node.moduleReference.kind === 230 && resolver.isReferencedAliasDeclaration(node)) { - externalImports.push(node); - } - break; - case 226: - if (node.moduleSpecifier) { - if (!node.exportClause) { - externalImports.push(node); - hasExportStars = true; - } - else if (resolver.isValueAliasDeclaration(node)) { - externalImports.push(node); - } - } - 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); - } - } - break; - case 225: - if (node.isExportEquals && !exportEquals) { - exportEquals = node; - } - break; - } - } - } - function emitExportStarHelper() { - if (hasExportStars) { - writeLine(); - write("function __export(m) {"); - increaseIndent(); - writeLine(); - write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function getLocalNameForExternalImport(node) { - var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (namespaceDeclaration && !isDefaultImport(node)) { - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); - } - if (node.kind === 220 && node.importClause) { - return getGeneratedNameForNode(node); - } - if (node.kind === 226 && node.moduleSpecifier) { - return getGeneratedNameForNode(node); - } - } - function getExternalModuleNameText(importNode) { - var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 9) { - return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); - } - return undefined; - } - function emitVariableDeclarationsForImports() { - if (externalImports.length === 0) { - return; - } - writeLine(); - var started = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var importNode = externalImports[_a]; - var skipNode = importNode.kind === 226 || - (importNode.kind === 220 && !importNode.importClause); - if (skipNode) { - continue; - } - if (!started) { - write("var "); - started = true; - } - else { - write(", "); - } - write(getLocalNameForExternalImport(importNode)); - } - if (started) { - write(";"); - } - } - function emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) { - if (!hasExportStars) { - return undefined; - } - if (!exportedDeclarations && ts.isEmpty(exportSpecifiers)) { - var hasExportDeclarationWithExportClause = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var externalImport = externalImports[_a]; - if (externalImport.kind === 226 && externalImport.exportClause) { - hasExportDeclarationWithExportClause = true; - break; - } - } - if (!hasExportDeclarationWithExportClause) { - return emitExportStarFunction(undefined); - } - } - var exportedNamesStorageRef = makeUniqueName("exportedNames"); - writeLine(); - write("var " + exportedNamesStorageRef + " = {"); - increaseIndent(); - var started = false; - if (exportedDeclarations) { - for (var i = 0; i < exportedDeclarations.length; ++i) { - writeExportedName(exportedDeclarations[i]); - } - } - if (exportSpecifiers) { - for (var n in exportSpecifiers) { - for (var _b = 0, _c = exportSpecifiers[n]; _b < _c.length; _b++) { - var specifier = _c[_b]; - writeExportedName(specifier.name); - } - } - } - for (var _d = 0; _d < externalImports.length; _d++) { - var externalImport = externalImports[_d]; - if (externalImport.kind !== 226) { - continue; - } - var exportDecl = externalImport; - if (!exportDecl.exportClause) { - continue; - } - for (var _e = 0, _f = exportDecl.exportClause.elements; _e < _f.length; _e++) { - var element = _f[_e]; - writeExportedName(element.name || element.propertyName); - } - } - decreaseIndent(); - writeLine(); - write("};"); - return emitExportStarFunction(exportedNamesStorageRef); - function emitExportStarFunction(localNames) { - var exportStarFunction = makeUniqueName("exportStar"); - writeLine(); - write("function " + exportStarFunction + "(m) {"); - increaseIndent(); - writeLine(); - write("var exports = {};"); - writeLine(); - write("for(var n in m) {"); - increaseIndent(); - writeLine(); - write("if (n !== \"default\""); - if (localNames) { - write("&& !" + localNames + ".hasOwnProperty(n)"); - } - write(") exports[n] = m[n];"); - decreaseIndent(); - writeLine(); - write("}"); - writeLine(); - write(exportFunctionForFile + "(exports);"); - decreaseIndent(); - writeLine(); - write("}"); - return exportStarFunction; - } - function writeExportedName(node) { - if (node.kind !== 67 && node.flags & 1024) { - return; - } - if (started) { - write(","); - } - else { - started = true; - } - writeLine(); - write("'"); - if (node.kind === 67) { - emitNodeWithCommentsAndWithoutSourcemap(node); - } - else { - emitDeclarationName(node); - } - write("': true"); - } - } - function processTopLevelVariableAndFunctionDeclarations(node) { - var hoistedVars; - var hoistedFunctionDeclarations; - var exportedDeclarations; - visit(node); - if (hoistedVars) { - writeLine(); - write("var "); - var seen = {}; - for (var i = 0; i < hoistedVars.length; ++i) { - var local = hoistedVars[i]; - var name_25 = local.kind === 67 - ? local - : local.name; - if (name_25) { - var text = ts.unescapeIdentifier(name_25.text); - if (ts.hasProperty(seen, text)) { - continue; - } - else { - seen[text] = text; - } - } - if (i !== 0) { - write(", "); - } - if (local.kind === 212 || local.kind === 216 || local.kind === 215) { - emitDeclarationName(local); - } - else { - emit(local); - } - var flags = ts.getCombinedNodeFlags(local.kind === 67 ? local.parent : local); - if (flags & 1) { - if (!exportedDeclarations) { - exportedDeclarations = []; - } - exportedDeclarations.push(local); - } - } - write(";"); - } - if (hoistedFunctionDeclarations) { - for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { - var f = hoistedFunctionDeclarations[_a]; - writeLine(); - emit(f); - if (f.flags & 1) { - if (!exportedDeclarations) { - exportedDeclarations = []; - } - exportedDeclarations.push(f); - } - } - } - return exportedDeclarations; - function visit(node) { - if (node.flags & 2) { - return; - } - if (node.kind === 211) { - if (!hoistedFunctionDeclarations) { - hoistedFunctionDeclarations = []; - } - hoistedFunctionDeclarations.push(node); - return; - } - if (node.kind === 212) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - return; - } - if (node.kind === 215) { - if (shouldEmitEnumDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - } - return; - } - if (node.kind === 216) { - if (shouldEmitModuleDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - } - return; - } - if (node.kind === 209 || node.kind === 161) { - if (shouldHoistVariable(node, false)) { - var name_26 = node.name; - if (name_26.kind === 67) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(name_26); - } - else { - ts.forEachChild(name_26, visit); - } - } - return; - } - if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node.name); - return; - } - if (ts.isBindingPattern(node)) { - ts.forEach(node.elements, visit); - return; - } - if (!ts.isDeclaration(node)) { - ts.forEachChild(node, visit); - } - } - } - function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { - if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { - return false; - } - return (ts.getCombinedNodeFlags(node) & 49152) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 246; - } - function isCurrentFileSystemExternalModule() { - return compilerOptions.module === 4 && ts.isExternalModule(currentSourceFile); - } - function emitSystemModuleBody(node, dependencyGroups, startIndex) { - emitVariableDeclarationsForImports(); - writeLine(); - var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); - var exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); - writeLine(); - write("return {"); - increaseIndent(); - writeLine(); - emitSetters(exportStarFunction, dependencyGroups); - writeLine(); - emitExecute(node, startIndex); - decreaseIndent(); - writeLine(); - write("}"); - emitTempDeclarations(true); - } - function emitSetters(exportStarFunction, dependencyGroups) { - write("setters:["); - for (var i = 0; i < dependencyGroups.length; ++i) { - if (i !== 0) { - write(","); - } - writeLine(); - increaseIndent(); - var group = dependencyGroups[i]; - var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); - write("function (" + parameterName + ") {"); - increaseIndent(); - for (var _a = 0; _a < group.length; _a++) { - var entry = group[_a]; - var importVariableName = getLocalNameForExternalImport(entry) || ""; - switch (entry.kind) { - case 220: - if (!entry.importClause) { - break; - } - case 219: - ts.Debug.assert(importVariableName !== ""); - writeLine(); - write(importVariableName + " = " + parameterName + ";"); - writeLine(); - break; - case 226: - ts.Debug.assert(importVariableName !== ""); - if (entry.exportClause) { - writeLine(); - write(exportFunctionForFile + "({"); - writeLine(); - increaseIndent(); - for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { - if (i_2 !== 0) { - write(","); - writeLine(); - } - var e = entry.exportClause.elements[i_2]; - write("\""); - emitNodeWithCommentsAndWithoutSourcemap(e.name); - write("\": " + parameterName + "[\""); - emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); - write("\"]"); - } - decreaseIndent(); - writeLine(); - write("});"); - } - else { - writeLine(); - write(exportStarFunction + "(" + parameterName + ");"); - } - writeLine(); - break; - } - } - decreaseIndent(); - write("}"); - decreaseIndent(); - } - write("],"); - } - function emitExecute(node, startIndex) { - write("execute: function() {"); - increaseIndent(); - writeLine(); - for (var i = startIndex; i < node.statements.length; ++i) { - var statement = node.statements[i]; - switch (statement.kind) { - case 211: - case 220: - continue; - case 226: - if (!statement.moduleSpecifier) { - for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { - var element = _b[_a]; - emitExportSpecifierInSystemModule(element); - } - } - continue; - case 219: - if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { - continue; - } - default: - writeLine(); - emit(statement); - } - } - decreaseIndent(); - writeLine(); - write("}"); - } - function emitSystemModule(node, startIndex) { - collectExternalModuleInfo(node); - ts.Debug.assert(!exportFunctionForFile); - exportFunctionForFile = makeUniqueName("exports"); - writeLine(); - write("System.register("); - if (node.moduleName) { - write("\"" + node.moduleName + "\", "); - } - write("["); - var groupIndices = {}; - var dependencyGroups = []; - for (var i = 0; i < externalImports.length; ++i) { - var text = getExternalModuleNameText(externalImports[i]); - if (ts.hasProperty(groupIndices, text)) { - var groupIndex = groupIndices[text]; - dependencyGroups[groupIndex].push(externalImports[i]); - continue; - } - else { - groupIndices[text] = dependencyGroups.length; - dependencyGroups.push([externalImports[i]]); - } - if (i !== 0) { - write(", "); - } - write(text); - } - write("], function(" + exportFunctionForFile + ") {"); - writeLine(); - increaseIndent(); - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, dependencyGroups, startIndex); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitAMDDependencies(node, includeNonAmdDependencies) { - // An AMD define function has the following shape: - // define(id?, dependencies?, factory); - // - // This has the shape of - // define(name, ["module1", "module2"], function (module1Alias) { - // The location of the alias in the parameter list in the factory function needs to - // match the position of the module name in the dependency list. - // - // To ensure this is true in cases of modules with no aliases, e.g.: - // `import "module"` or `` - // we need to add modules without alias names to the end of the dependencies list - var aliasedModuleNames = []; - var unaliasedModuleNames = []; - var importAliasNames = []; - for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { - var amdDependency = _b[_a]; - if (amdDependency.name) { - aliasedModuleNames.push("\"" + amdDependency.path + "\""); - importAliasNames.push(amdDependency.name); - } - else { - unaliasedModuleNames.push("\"" + amdDependency.path + "\""); - } - } - for (var _c = 0; _c < externalImports.length; _c++) { - var importNode = externalImports[_c]; - var externalModuleName = getExternalModuleNameText(importNode); - var importAliasName = getLocalNameForExternalImport(importNode); - if (includeNonAmdDependencies && importAliasName) { - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(importAliasName); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - write("[\"require\", \"exports\""); - if (aliasedModuleNames.length) { - write(", "); - write(aliasedModuleNames.join(", ")); - } - if (unaliasedModuleNames.length) { - write(", "); - write(unaliasedModuleNames.join(", ")); - } - write("], function (require, exports"); - if (importAliasNames.length) { - write(", "); - write(importAliasNames.join(", ")); - } - } - function emitAMDModule(node, startIndex) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - writeLine(); - write("define("); - if (node.moduleName) { - write("\"" + node.moduleName + "\", "); - } - emitAMDDependencies(node, true); - write(") {"); - increaseIndent(); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(true); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitCommonJSModule(node, startIndex) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(false); - } - function emitUMDModule(node, startIndex) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); - emitAMDDependencies(node, false); - write(") {"); - increaseIndent(); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(true); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitES6Module(node, startIndex) { - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStars = false; - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - } - function emitExportEquals(emitAsReturn) { - if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { - writeLine(); - emitStart(exportEquals); - write(emitAsReturn ? "return " : "module.exports = "); - emit(exportEquals.expression); - write(";"); - emitEnd(exportEquals); - } - } - function emitJsxElement(node) { - switch (compilerOptions.jsx) { - case 2: - jsxEmitReact(node); - break; - case 1: - default: - jsxEmitPreserve(node); - break; - } - } - function trimReactWhitespaceAndApplyEntities(node) { - var result = undefined; - var text = ts.getTextOfNode(node, true); - var firstNonWhitespace = 0; - var lastNonWhitespace = -1; - for (var i = 0; i < text.length; i++) { - var c = text.charCodeAt(i); - if (ts.isLineBreak(c)) { - if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { - var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + "\" + ' ' + \"" : "") + part; - } - firstNonWhitespace = -1; - } - else if (!ts.isWhiteSpace(c)) { - lastNonWhitespace = i; - if (firstNonWhitespace === -1) { - firstNonWhitespace = i; - } - } - } - if (firstNonWhitespace !== -1) { - var part = text.substr(firstNonWhitespace); - result = (result ? result + "\" + ' ' + \"" : "") + part; - } - if (result) { - result = result.replace(/&(\w+);/g, function (s, m) { - if (entities[m] !== undefined) { - return String.fromCharCode(entities[m]); - } - else { - return s; - } - }); - } - return result; - } - function getTextToEmit(node) { - switch (compilerOptions.jsx) { - case 2: - var text = trimReactWhitespaceAndApplyEntities(node); - if (text === undefined || text.length === 0) { - return undefined; - } - else { - return text; - } - case 1: - default: - return ts.getTextOfNode(node, true); - } - } - function emitJsxText(node) { - switch (compilerOptions.jsx) { - case 2: - write("\""); - write(trimReactWhitespaceAndApplyEntities(node)); - write("\""); - break; - case 1: - default: - writer.writeLiteral(ts.getTextOfNode(node, true)); - break; - } - } - function emitJsxExpression(node) { - if (node.expression) { - switch (compilerOptions.jsx) { - case 1: - default: - write("{"); - emit(node.expression); - write("}"); - break; - case 2: - emit(node.expression); - break; - } - } - } - function emitDirectivePrologues(statements, startWithNewLine) { - for (var i = 0; i < statements.length; ++i) { - if (ts.isPrologueDirective(statements[i])) { - if (startWithNewLine || i > 0) { - writeLine(); - } - emit(statements[i]); - } - else { - return i; - } - } - return statements.length; - } - function writeLines(text) { - var lines = text.split(/\r\n|\r|\n/g); - for (var i = 0; i < lines.length; ++i) { - var line = lines[i]; - if (line.length) { - writeLine(); - write(line); - } - } - } - function emitEmitHelpers(node) { - if (!compilerOptions.noEmitHelpers) { - if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { - writeLines(extendsHelper); - extendsEmitted = true; - } - if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16) { - writeLines(decorateHelper); - if (compilerOptions.emitDecoratorMetadata) { - writeLines(metadataHelper); - } - decorateEmitted = true; - } - if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32) { - writeLines(paramHelper); - paramEmitted = true; - } - if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64) { - writeLines(awaiterHelper); - awaiterEmitted = true; - } - } - } - function emitSourceFileNode(node) { - writeLine(); - emitShebang(); - emitDetachedComments(node); - var startIndex = emitDirectivePrologues(node.statements, false); - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - if (languageVersion >= 2) { - emitES6Module(node, startIndex); - } - else if (compilerOptions.module === 2) { - emitAMDModule(node, startIndex); - } - else if (compilerOptions.module === 4) { - emitSystemModule(node, startIndex); - } - else if (compilerOptions.module === 3) { - emitUMDModule(node, startIndex); - } - else { - emitCommonJSModule(node, startIndex); - } - } - else { - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStars = false; - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - } - emitLeadingComments(node.endOfFileToken); - } - function emitNodeWithCommentsAndWithoutSourcemap(node) { - emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); - } - function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { - if (node) { - if (node.flags & 2) { - return emitOnlyPinnedOrTripleSlashComments(node); - } - if (isSpecializedCommentHandling(node)) { - return emitNodeWithoutSourceMap(node); - } - var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); - if (emitComments_1) { - emitLeadingComments(node); - } - emitNodeConsideringSourcemap(node); - if (emitComments_1) { - emitTrailingComments(node); - } - } - } - function emitNodeWithoutSourceMap(node) { - if (node) { - emitJavaScriptWorker(node); - } - } - function isSpecializedCommentHandling(node) { - switch (node.kind) { - case 213: - case 211: - case 220: - case 219: - case 214: - case 225: - return true; - } - } - function shouldEmitLeadingAndTrailingComments(node) { - switch (node.kind) { - case 191: - return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 216: - return shouldEmitModuleDeclaration(node); - case 215: - return shouldEmitEnumDeclaration(node); - } - ts.Debug.assert(!isSpecializedCommentHandling(node)); - if (node.kind !== 190 && - node.parent && - node.parent.kind === 172 && - node.parent.body === node && - compilerOptions.target <= 1) { - return false; - } - return true; - } - function emitJavaScriptWorker(node) { - switch (node.kind) { - case 67: - return emitIdentifier(node); - case 136: - return emitParameter(node); - case 141: - case 140: - return emitMethod(node); - case 143: - case 144: - return emitAccessor(node); - case 95: - return emitThis(node); - case 93: - return emitSuper(node); - case 91: - return write("null"); - case 97: - return write("true"); - case 82: - return write("false"); - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - return emitLiteral(node); - case 181: - return emitTemplateExpression(node); - case 188: - return emitTemplateSpan(node); - case 231: - case 232: - return emitJsxElement(node); - case 234: - return emitJsxText(node); - case 238: - return emitJsxExpression(node); - case 133: - return emitQualifiedName(node); - case 159: - return emitObjectBindingPattern(node); - case 160: - return emitArrayBindingPattern(node); - case 161: - return emitBindingElement(node); - case 162: - return emitArrayLiteral(node); - case 163: - return emitObjectLiteral(node); - case 243: - return emitPropertyAssignment(node); - case 244: - return emitShorthandPropertyAssignment(node); - case 134: - return emitComputedPropertyName(node); - case 164: - return emitPropertyAccess(node); - case 165: - return emitIndexedAccess(node); - case 166: - return emitCallExpression(node); - case 167: - return emitNewExpression(node); - case 168: - return emitTaggedTemplateExpression(node); - case 169: - return emit(node.expression); - case 187: - return emit(node.expression); - case 170: - return emitParenExpression(node); - case 211: - case 171: - case 172: - return emitFunctionDeclaration(node); - case 173: - return emitDeleteExpression(node); - case 174: - return emitTypeOfExpression(node); - case 175: - return emitVoidExpression(node); - case 176: - return emitAwaitExpression(node); - case 177: - return emitPrefixUnaryExpression(node); - case 178: - return emitPostfixUnaryExpression(node); - case 179: - return emitBinaryExpression(node); - case 180: - return emitConditionalExpression(node); - case 183: - return emitSpreadElementExpression(node); - case 182: - return emitYieldExpression(node); - case 185: - return; - case 190: - case 217: - return emitBlock(node); - case 191: - return emitVariableStatement(node); - case 192: - return write(";"); - case 193: - return emitExpressionStatement(node); - case 194: - return emitIfStatement(node); - case 195: - return emitDoStatement(node); - case 196: - return emitWhileStatement(node); - case 197: - return emitForStatement(node); - case 199: - case 198: - return emitForInOrForOfStatement(node); - case 200: - case 201: - return emitBreakOrContinueStatement(node); - case 202: - return emitReturnStatement(node); - case 203: - return emitWithStatement(node); - case 204: - return emitSwitchStatement(node); - case 239: - case 240: - return emitCaseOrDefaultClause(node); - case 205: - return emitLabelledStatement(node); - case 206: - return emitThrowStatement(node); - case 207: - return emitTryStatement(node); - case 242: - return emitCatchClause(node); - case 208: - return emitDebuggerStatement(node); - case 209: - return emitVariableDeclaration(node); - case 184: - return emitClassExpression(node); - case 212: - return emitClassDeclaration(node); - case 213: - return emitInterfaceDeclaration(node); - case 215: - return emitEnumDeclaration(node); - case 245: - return emitEnumMember(node); - case 216: - return emitModuleDeclaration(node); - case 220: - return emitImportDeclaration(node); - case 219: - return emitImportEqualsDeclaration(node); - case 226: - return emitExportDeclaration(node); - case 225: - return emitExportAssignment(node); - case 246: - return emitSourceFileNode(node); - } - } - function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; - } - function getLeadingCommentsWithoutDetachedComments() { - var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); - if (detachedCommentsInfo.length - 1) { - detachedCommentsInfo.pop(); - } - else { - detachedCommentsInfo = undefined; - } - return leadingComments; - } - function filterComments(ranges, onlyPinnedOrTripleSlashComments) { - if (ranges && onlyPinnedOrTripleSlashComments) { - ranges = ts.filter(ranges, isPinnedOrTripleSlashComment); - if (ranges.length === 0) { - return undefined; - } - } - return ranges; - } - function getLeadingCommentsToEmit(node) { - if (node.parent) { - if (node.parent.kind === 246 || node.pos !== node.parent.pos) { - if (hasDetachedComments(node.pos)) { - return getLeadingCommentsWithoutDetachedComments(); - } - else { - return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); - } - } - } - } - function getTrailingCommentsToEmit(node) { - if (node.parent) { - if (node.parent.kind === 246 || node.end !== node.parent.end) { - return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); - } - } - } - function emitOnlyPinnedOrTripleSlashComments(node) { - emitLeadingCommentsWorker(node, true); - } - function emitLeadingComments(node) { - return emitLeadingCommentsWorker(node, compilerOptions.removeComments); - } - function emitLeadingCommentsWorker(node, onlyPinnedOrTripleSlashComments) { - var leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments); - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); - } - function emitTrailingComments(node) { - var trailingComments = filterComments(getTrailingCommentsToEmit(node), compilerOptions.removeComments); - ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); - } - function emitTrailingCommentsOfPosition(pos) { - var trailingComments = filterComments(ts.getTrailingCommentRanges(currentSourceFile.text, pos), compilerOptions.removeComments); - ts.emitComments(currentSourceFile, writer, trailingComments, true, newLine, writeComment); - } - function emitLeadingCommentsOfPosition(pos) { - var leadingComments; - if (hasDetachedComments(pos)) { - leadingComments = getLeadingCommentsWithoutDetachedComments(); - } - else { - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); - } - leadingComments = filterComments(leadingComments, compilerOptions.removeComments); - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); - ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); - } - function emitDetachedComments(node) { - var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); - if (leadingComments) { - var detachedComments = []; - var lastComment; - ts.forEach(leadingComments, function (comment) { - if (lastComment) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); - var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); - if (commentLine >= lastCommentLine + 2) { - return detachedComments; - } - } - detachedComments.push(comment); - lastComment = comment; - }); - if (detachedComments.length) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); - var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); - var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } - } - } - } - function emitShebang() { - var shebang = ts.getShebang(currentSourceFile.text); - if (shebang) { - write(shebang); - } - } - function isPinnedOrTripleSlashComment(comment) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { - return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; - } - else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && - comment.pos + 2 < comment.end && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 && - currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) { - return true; - } - } - } - function emitFile(jsFilePath, sourceFile) { - emitJavaScript(jsFilePath, sourceFile); - if (compilerOptions.declaration) { - ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); - } - } - } - ts.emitFiles = emitFiles; var entities = { "quot": 0x0022, "amp": 0x0026, @@ -29343,10 +24280,5553 @@ var ts; "hearts": 0x2665, "diams": 0x2666 }; + 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 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 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\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};"; + var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; + var compilerOptions = host.getCompilerOptions(); + var languageVersion = compilerOptions.target || 0; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 ? 5 : 0; + var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; + var diagnostics = []; + var newLine = host.getNewLine(); + var jsxDesugaring = host.getCompilerOptions().jsx !== 1; + var shouldEmitJsx = function (s) { return (s.languageVariant === 1 && !jsxDesugaring); }; + if (targetSourceFile === undefined) { + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); + emitFile(jsFilePath, sourceFile); + } + }); + if (compilerOptions.outFile || compilerOptions.out) { + emitFile(compilerOptions.outFile || compilerOptions.out); + } + } + else { + if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); + emitFile(jsFilePath, targetSourceFile); + } + else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { + emitFile(compilerOptions.outFile || compilerOptions.out); + } + } + diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); + return { + emitSkipped: false, + diagnostics: diagnostics, + sourceMaps: sourceMapDataList + }; + function isNodeDescendentOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + function isUniqueLocalName(name, container) { + for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + if (node.locals && ts.hasProperty(node.locals, name)) { + if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { + return false; + } + } + } + return true; + } + function emitJavaScript(jsFilePath, root) { + var writer = ts.createTextWriter(newLine); + var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; + var currentSourceFile; + var exportFunctionForFile; + var generatedNameSet = {}; + var nodeToGeneratedName = []; + var computedPropertyNamesToGeneratedNames; + var extendsEmitted = false; + var decorateEmitted = false; + var paramEmitted = false; + var awaiterEmitted = false; + var tempFlags = 0; + var tempVariables; + var tempParameters; + var externalImports; + var exportSpecifiers; + var exportEquals; + var hasExportStars; + var writeEmittedFiles = writeJavaScriptFile; + var detachedCommentsInfo; + var writeComment = ts.writeCommentRange; + var emit = emitNodeWithCommentsAndWithoutSourcemap; + var emitStart = function (node) { }; + var emitEnd = function (node) { }; + var emitToken = emitTokenText; + var scopeEmitStart = function (scopeDeclaration, scopeName) { }; + var scopeEmitEnd = function () { }; + var sourceMapData; + var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; + var moduleEmitDelegates = (_a = {}, + _a[5] = emitES6Module, + _a[2] = emitAMDModule, + _a[4] = emitSystemModule, + _a[3] = emitUMDModule, + _a[1] = emitCommonJSModule, + _a + ); + if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { + initializeEmitterWithSourceMaps(); + } + if (root) { + emitSourceFile(root); + } + else { + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (!isExternalModuleOrDeclarationFile(sourceFile)) { + emitSourceFile(sourceFile); + } + }); + } + writeLine(); + writeEmittedFiles(writer.getText(), compilerOptions.emitBOM); + return; + function emitSourceFile(sourceFile) { + currentSourceFile = sourceFile; + exportFunctionForFile = undefined; + emit(sourceFile); + } + function isUniqueName(name) { + return !resolver.hasGlobalName(name) && + !ts.hasProperty(currentSourceFile.identifiers, name) && + !ts.hasProperty(generatedNameSet, name); + } + function makeTempVariableName(flags) { + if (flags && !(tempFlags & flags)) { + var name_19 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_19)) { + tempFlags |= flags; + return name_19; + } + } + while (true) { + var count = tempFlags & 268435455; + tempFlags++; + if (count !== 8 && count !== 13) { + var name_20 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); + if (isUniqueName(name_20)) { + return name_20; + } + } + } + } + function makeUniqueName(baseName) { + if (baseName.charCodeAt(baseName.length - 1) !== 95) { + baseName += "_"; + } + var i = 1; + while (true) { + var generatedName = baseName + i; + if (isUniqueName(generatedName)) { + return generatedNameSet[generatedName] = generatedName; + } + i++; + } + } + function generateNameForModuleOrEnum(node) { + var name = node.name.text; + return isUniqueLocalName(name, node) ? name : makeUniqueName(name); + } + function generateNameForImportOrExportDeclaration(node) { + var expr = ts.getExternalModuleName(node); + var baseName = expr.kind === 9 ? + ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; + return makeUniqueName(baseName); + } + function generateNameForExportDefault() { + return makeUniqueName("default"); + } + function generateNameForClassExpression() { + return makeUniqueName("class"); + } + function generateNameForNode(node) { + switch (node.kind) { + case 69: + return makeUniqueName(node.text); + case 218: + case 217: + return generateNameForModuleOrEnum(node); + case 222: + case 228: + return generateNameForImportOrExportDeclaration(node); + case 213: + case 214: + case 227: + return generateNameForExportDefault(); + case 186: + return generateNameForClassExpression(); + } + } + function getGeneratedNameForNode(node) { + var id = ts.getNodeId(node); + return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); + } + function initializeEmitterWithSourceMaps() { + var sourceMapDir; + var sourceMapSourceIndex = -1; + var sourceMapNameIndexMap = {}; + var sourceMapNameIndices = []; + function getSourceMapNameIndex() { + return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1; + } + var lastRecordedSourceMapSpan; + var lastEncodedSourceMapSpan = { + emittedLine: 1, + emittedColumn: 1, + sourceLine: 1, + sourceColumn: 1, + sourceIndex: 0 + }; + var lastEncodedNameIndex = 0; + function encodeLastRecordedSourceMapSpan() { + if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { + return; + } + var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; + if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { + if (sourceMapData.sourceMapMappings) { + sourceMapData.sourceMapMappings += ","; + } + } + else { + for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { + sourceMapData.sourceMapMappings += ";"; + } + prevEncodedEmittedColumn = 1; + } + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); + if (lastRecordedSourceMapSpan.nameIndex >= 0) { + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); + lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; + } + lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; + sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); + function base64VLQFormatEncode(inValue) { + function base64FormatEncode(inValue) { + if (inValue < 64) { + return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); + } + throw TypeError(inValue + ": not a 64 based value"); + } + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } + else { + inValue = inValue << 1; + } + var encodedStr = ""; + do { + var currentDigit = inValue & 31; + inValue = inValue >> 5; + if (inValue > 0) { + currentDigit = currentDigit | 32; + } + encodedStr = encodedStr + base64FormatEncode(currentDigit); + } while (inValue > 0); + return encodedStr; + } + } + function recordSourceMapSpan(pos) { + var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSourceFile, pos); + sourceLinePos.line++; + sourceLinePos.character++; + var emittedLine = writer.getLine(); + var emittedColumn = writer.getColumn(); + if (!lastRecordedSourceMapSpan || + lastRecordedSourceMapSpan.emittedLine !== emittedLine || + lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || + (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && + (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || + (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { + encodeLastRecordedSourceMapSpan(); + lastRecordedSourceMapSpan = { + emittedLine: emittedLine, + emittedColumn: emittedColumn, + sourceLine: sourceLinePos.line, + sourceColumn: sourceLinePos.character, + nameIndex: getSourceMapNameIndex(), + sourceIndex: sourceMapSourceIndex + }; + } + else { + lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; + lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; + lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; + } + } + function recordEmitNodeStartSpan(node) { + recordSourceMapSpan(ts.skipTrivia(currentSourceFile.text, node.pos)); + } + function recordEmitNodeEndSpan(node) { + recordSourceMapSpan(node.end); + } + function writeTextWithSpanRecord(tokenKind, startPos, emitFn) { + var tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos); + recordSourceMapSpan(tokenStartPos); + var tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn); + recordSourceMapSpan(tokenEndPos); + return tokenEndPos; + } + function recordNewSourceFileStart(node) { + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true)); + sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; + sourceMapData.inputSourceFileNames.push(node.fileName); + if (compilerOptions.inlineSources) { + if (!sourceMapData.sourceMapSourcesContent) { + sourceMapData.sourceMapSourcesContent = []; + } + sourceMapData.sourceMapSourcesContent.push(node.text); + } + } + function recordScopeNameOfNode(node, scopeName) { + function recordScopeNameIndex(scopeNameIndex) { + sourceMapNameIndices.push(scopeNameIndex); + } + function recordScopeNameStart(scopeName) { + var scopeNameIndex = -1; + if (scopeName) { + var parentIndex = getSourceMapNameIndex(); + if (parentIndex !== -1) { + var name_21 = node.name; + if (!name_21 || name_21.kind !== 136) { + scopeName = "." + scopeName; + } + scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; + } + scopeNameIndex = ts.getProperty(sourceMapNameIndexMap, scopeName); + if (scopeNameIndex === undefined) { + scopeNameIndex = sourceMapData.sourceMapNames.length; + sourceMapData.sourceMapNames.push(scopeName); + sourceMapNameIndexMap[scopeName] = scopeNameIndex; + } + } + recordScopeNameIndex(scopeNameIndex); + } + if (scopeName) { + recordScopeNameStart(scopeName); + } + else if (node.kind === 213 || + node.kind === 173 || + node.kind === 143 || + node.kind === 142 || + node.kind === 145 || + node.kind === 146 || + node.kind === 218 || + node.kind === 214 || + node.kind === 217) { + if (node.name) { + var name_22 = node.name; + scopeName = name_22.kind === 136 + ? ts.getTextOfNode(name_22) + : node.name.text; + } + recordScopeNameStart(scopeName); + } + else { + recordScopeNameIndex(getSourceMapNameIndex()); + } + } + function recordScopeNameEnd() { + sourceMapNameIndices.pop(); + } + ; + function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { + recordSourceMapSpan(comment.pos); + ts.writeCommentRange(currentSourceFile, writer, comment, newLine); + recordSourceMapSpan(comment.end); + } + function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings, sourcesContent) { + if (typeof JSON !== "undefined") { + var map_1 = { + version: version, + file: file, + sourceRoot: sourceRoot, + sources: sources, + names: names, + mappings: mappings + }; + if (sourcesContent !== undefined) { + map_1.sourcesContent = sourcesContent; + } + return JSON.stringify(map_1); + } + return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\" " + (sourcesContent !== undefined ? ",\"sourcesContent\":[" + serializeStringArray(sourcesContent) + "]" : "") + "}"; + function serializeStringArray(list) { + var output = ""; + for (var i = 0, n = list.length; i < n; i++) { + if (i) { + output += ","; + } + output += "\"" + ts.escapeString(list[i]) + "\""; + } + return output; + } + } + function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { + encodeLastRecordedSourceMapSpan(); + var sourceMapText = serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings, sourceMapData.sourceMapSourcesContent); + sourceMapDataList.push(sourceMapData); + var sourceMapUrl; + if (compilerOptions.inlineSourceMap) { + var base64SourceMapText = ts.convertToBase64(sourceMapText); + sourceMapUrl = "//# sourceMappingURL=data:application/json;base64," + base64SourceMapText; + } + else { + ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, false); + sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; + } + writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark); + } + var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); + sourceMapData = { + sourceMapFilePath: jsFilePath + ".map", + jsSourceMappingURL: sourceMapJsFile + ".map", + sourceMapFile: sourceMapJsFile, + sourceMapSourceRoot: compilerOptions.sourceRoot || "", + sourceMapSources: [], + inputSourceFileNames: [], + sourceMapNames: [], + sourceMapMappings: "", + sourceMapSourcesContent: undefined, + sourceMapDecodedMappings: [] + }; + sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); + if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47) { + sourceMapData.sourceMapSourceRoot += ts.directorySeparator; + } + if (compilerOptions.mapRoot) { + sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); + if (root) { + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); + } + if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { + sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); + sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), host.getCurrentDirectory(), host.getCanonicalFileName, true); + } + else { + sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); + } + } + else { + sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); + } + function emitNodeWithSourceMap(node) { + if (node) { + if (ts.nodeIsSynthesized(node)) { + return emitNodeWithoutSourceMap(node); + } + if (node.kind !== 248) { + recordEmitNodeStartSpan(node); + emitNodeWithoutSourceMap(node); + recordEmitNodeEndSpan(node); + } + else { + recordNewSourceFileStart(node); + emitNodeWithoutSourceMap(node); + } + } + } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } + writeEmittedFiles = writeJavaScriptAndSourceMapFile; + emit = emitNodeWithCommentsAndWithSourcemap; + emitStart = recordEmitNodeStartSpan; + emitEnd = recordEmitNodeEndSpan; + emitToken = writeTextWithSpanRecord; + scopeEmitStart = recordScopeNameOfNode; + scopeEmitEnd = recordScopeNameEnd; + writeComment = writeCommentRangeWithMap; + } + function writeJavaScriptFile(emitOutput, writeByteOrderMark) { + ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); + } + function createTempVariable(flags) { + var result = ts.createSynthesizedNode(69); + result.text = makeTempVariableName(flags); + return result; + } + function recordTempDeclaration(name) { + if (!tempVariables) { + tempVariables = []; + } + tempVariables.push(name); + } + function createAndRecordTempVariable(flags) { + var temp = createTempVariable(flags); + recordTempDeclaration(temp); + return temp; + } + function emitTempDeclarations(newLine) { + if (tempVariables) { + if (newLine) { + writeLine(); + } + else { + write(" "); + } + write("var "); + emitCommaList(tempVariables); + write(";"); + } + } + function emitTokenText(tokenKind, startPos, emitFn) { + var tokenString = ts.tokenToString(tokenKind); + if (emitFn) { + emitFn(); + } + else { + write(tokenString); + } + return startPos + tokenString.length; + } + function emitOptional(prefix, node) { + if (node) { + write(prefix); + emit(node); + } + } + function emitParenthesizedIf(node, parenthesized) { + if (parenthesized) { + write("("); + } + emit(node); + if (parenthesized) { + write(")"); + } + } + function emitTrailingCommaIfPresent(nodeList) { + if (nodeList.hasTrailingComma) { + write(","); + } + } + function emitLinePreservingList(parent, nodes, allowTrailingComma, spacesBetweenBraces) { + ts.Debug.assert(nodes.length > 0); + increaseIndent(); + if (nodeStartPositionsAreOnSameLine(parent, nodes[0])) { + if (spacesBetweenBraces) { + write(" "); + } + } + else { + writeLine(); + } + for (var i = 0, n = nodes.length; i < n; i++) { + if (i) { + if (nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) { + write(", "); + } + else { + write(","); + writeLine(); + } + } + emit(nodes[i]); + } + if (nodes.hasTrailingComma && allowTrailingComma) { + write(","); + } + decreaseIndent(); + if (nodeEndPositionsAreOnSameLine(parent, ts.lastOrUndefined(nodes))) { + if (spacesBetweenBraces) { + write(" "); + } + } + else { + writeLine(); + } + } + function emitList(nodes, start, count, multiLine, trailingComma, leadingComma, noTrailingNewLine, emitNode) { + if (!emitNode) { + emitNode = emit; + } + for (var i = 0; i < count; i++) { + if (multiLine) { + if (i || leadingComma) { + write(","); + } + writeLine(); + } + else { + if (i || leadingComma) { + write(", "); + } + } + var node = nodes[start + i]; + emitTrailingCommentsOfPosition(node.pos); + emitNode(node); + leadingComma = true; + } + if (trailingComma) { + write(","); + } + if (multiLine && !noTrailingNewLine) { + writeLine(); + } + return count; + } + function emitCommaList(nodes) { + if (nodes) { + emitList(nodes, 0, nodes.length, false, false); + } + } + function emitLines(nodes) { + emitLinesStartingAt(nodes, 0); + } + function emitLinesStartingAt(nodes, startIndex) { + for (var i = startIndex; i < nodes.length; i++) { + writeLine(); + emit(nodes[i]); + } + } + function isBinaryOrOctalIntegerLiteral(node, text) { + if (node.kind === 8 && text.length > 1) { + switch (text.charCodeAt(1)) { + case 98: + case 66: + case 111: + case 79: + return true; + } + } + return false; + } + function emitLiteral(node) { + var text = getLiteralText(node); + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 || ts.isTemplateLiteralKind(node.kind))) { + writer.writeLiteral(text); + } + else if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { + write(node.text); + } + else { + write(text); + } + } + function getLiteralText(node) { + if (languageVersion < 2 && (ts.isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { + return getQuotedEscapedLiteralText("\"", node.text, "\""); + } + if (node.parent) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + } + switch (node.kind) { + case 9: + return getQuotedEscapedLiteralText("\"", node.text, "\""); + case 11: + return getQuotedEscapedLiteralText("`", node.text, "`"); + case 12: + return getQuotedEscapedLiteralText("`", node.text, "${"); + case 13: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 14: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8: + return node.text; + } + ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + } + function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { + return leftQuote + ts.escapeNonAsciiCharacters(ts.escapeString(text)) + rightQuote; + } + function emitDownlevelRawTemplateLiteral(node) { + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + var isLast = node.kind === 11 || node.kind === 14; + text = text.substring(1, text.length - (isLast ? 1 : 2)); + text = text.replace(/\r\n?/g, "\n"); + text = ts.escapeString(text); + write("\"" + text + "\""); + } + function emitDownlevelTaggedTemplateArray(node, literalEmitter) { + write("["); + if (node.template.kind === 11) { + literalEmitter(node.template); + } + else { + literalEmitter(node.template.head); + ts.forEach(node.template.templateSpans, function (child) { + write(", "); + literalEmitter(child.literal); + }); + } + write("]"); + } + function emitDownlevelTaggedTemplate(node) { + var tempVariable = createAndRecordTempVariable(0); + write("("); + emit(tempVariable); + write(" = "); + emitDownlevelTaggedTemplateArray(node, emit); + write(", "); + emit(tempVariable); + write(".raw = "); + emitDownlevelTaggedTemplateArray(node, emitDownlevelRawTemplateLiteral); + write(", "); + emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); + write("("); + emit(tempVariable); + if (node.template.kind === 183) { + ts.forEach(node.template.templateSpans, function (templateSpan) { + write(", "); + var needsParens = templateSpan.expression.kind === 181 + && templateSpan.expression.operatorToken.kind === 24; + emitParenthesizedIf(templateSpan.expression, needsParens); + }); + } + write("))"); + } + function emitTemplateExpression(node) { + if (languageVersion >= 2) { + ts.forEachChild(node, emit); + return; + } + var emitOuterParens = ts.isExpression(node.parent) + && templateNeedsParens(node, node.parent); + if (emitOuterParens) { + write("("); + } + var headEmitted = false; + if (shouldEmitTemplateHead()) { + emitLiteral(node.head); + headEmitted = true; + } + for (var i = 0, n = node.templateSpans.length; i < n; i++) { + var templateSpan = node.templateSpans[i]; + var needsParens = templateSpan.expression.kind !== 172 + && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; + if (i > 0 || headEmitted) { + write(" + "); + } + emitParenthesizedIf(templateSpan.expression, needsParens); + if (templateSpan.literal.text.length !== 0) { + write(" + "); + emitLiteral(templateSpan.literal); + } + } + if (emitOuterParens) { + write(")"); + } + function shouldEmitTemplateHead() { + ts.Debug.assert(node.templateSpans.length !== 0); + return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; + } + function templateNeedsParens(template, parent) { + switch (parent.kind) { + case 168: + case 169: + return parent.expression === template; + case 170: + case 172: + return false; + default: + return comparePrecedenceToBinaryPlus(parent) !== -1; + } + } + function comparePrecedenceToBinaryPlus(expression) { + switch (expression.kind) { + case 181: + switch (expression.operatorToken.kind) { + case 37: + case 39: + case 40: + return 1; + case 35: + case 36: + return 0; + default: + return -1; + } + case 184: + case 182: + return -1; + default: + return 1; + } + } + } + function emitTemplateSpan(span) { + emit(span.expression); + emit(span.literal); + } + function jsxEmitReact(node) { + function emitTagName(name) { + if (name.kind === 69 && ts.isIntrinsicJsxName(name.text)) { + write("\""); + emit(name); + write("\""); + } + else { + emit(name); + } + } + function emitAttributeName(name) { + if (/[A-Za-z_]+[\w*]/.test(name.text)) { + write("\""); + emit(name); + write("\""); + } + else { + emit(name); + } + } + function emitJsxAttribute(node) { + emitAttributeName(node.name); + write(": "); + if (node.initializer) { + emit(node.initializer); + } + else { + write("true"); + } + } + function emitJsxElement(openingNode, children) { + var syntheticReactRef = ts.createSynthesizedNode(69); + syntheticReactRef.text = "React"; + syntheticReactRef.parent = openingNode; + emitLeadingComments(openingNode); + emitExpressionIdentifier(syntheticReactRef); + write(".createElement("); + emitTagName(openingNode.tagName); + write(", "); + if (openingNode.attributes.length === 0) { + write("null"); + } + else { + var attrs = openingNode.attributes; + if (ts.forEach(attrs, function (attr) { return attr.kind === 239; })) { + emitExpressionIdentifier(syntheticReactRef); + write(".__spread("); + var haveOpenedObjectLiteral = false; + for (var i_1 = 0; i_1 < attrs.length; i_1++) { + if (attrs[i_1].kind === 239) { + if (i_1 === 0) { + write("{}, "); + } + if (haveOpenedObjectLiteral) { + write("}"); + haveOpenedObjectLiteral = false; + } + if (i_1 > 0) { + write(", "); + } + emit(attrs[i_1].expression); + } + else { + ts.Debug.assert(attrs[i_1].kind === 238); + if (haveOpenedObjectLiteral) { + write(", "); + } + else { + haveOpenedObjectLiteral = true; + if (i_1 > 0) { + write(", "); + } + write("{"); + } + emitJsxAttribute(attrs[i_1]); + } + } + if (haveOpenedObjectLiteral) + write("}"); + write(")"); + } + else { + write("{"); + for (var i = 0; i < attrs.length; i++) { + if (i > 0) { + write(", "); + } + emitJsxAttribute(attrs[i]); + } + write("}"); + } + } + if (children) { + for (var i = 0; i < children.length; i++) { + if (children[i].kind === 240 && !(children[i].expression)) { + continue; + } + if (children[i].kind === 236) { + var text = getTextToEmit(children[i]); + if (text !== undefined) { + write(", \""); + write(text); + write("\""); + } + } + else { + write(", "); + emit(children[i]); + } + } + } + write(")"); + emitTrailingComments(openingNode); + } + if (node.kind === 233) { + emitJsxElement(node.openingElement, node.children); + } + else { + ts.Debug.assert(node.kind === 234); + emitJsxElement(node); + } + } + function jsxEmitPreserve(node) { + function emitJsxAttribute(node) { + emit(node.name); + if (node.initializer) { + write("="); + emit(node.initializer); + } + } + function emitJsxSpreadAttribute(node) { + write("{..."); + emit(node.expression); + write("}"); + } + function emitAttributes(attribs) { + for (var i = 0, n = attribs.length; i < n; i++) { + if (i > 0) { + write(" "); + } + if (attribs[i].kind === 239) { + emitJsxSpreadAttribute(attribs[i]); + } + else { + ts.Debug.assert(attribs[i].kind === 238); + emitJsxAttribute(attribs[i]); + } + } + } + function emitJsxOpeningOrSelfClosingElement(node) { + write("<"); + emit(node.tagName); + if (node.attributes.length > 0 || (node.kind === 234)) { + write(" "); + } + emitAttributes(node.attributes); + if (node.kind === 234) { + write("/>"); + } + else { + write(">"); + } + } + function emitJsxClosingElement(node) { + write(""); + } + function emitJsxElement(node) { + emitJsxOpeningOrSelfClosingElement(node.openingElement); + for (var i = 0, n = node.children.length; i < n; i++) { + emit(node.children[i]); + } + emitJsxClosingElement(node.closingElement); + } + if (node.kind === 233) { + emitJsxElement(node); + } + else { + ts.Debug.assert(node.kind === 234); + emitJsxOpeningOrSelfClosingElement(node); + } + } + function emitExpressionForPropertyName(node) { + ts.Debug.assert(node.kind !== 163); + if (node.kind === 9) { + emitLiteral(node); + } + else if (node.kind === 136) { + if (ts.nodeIsDecorated(node.parent)) { + if (!computedPropertyNamesToGeneratedNames) { + computedPropertyNamesToGeneratedNames = []; + } + var generatedName = computedPropertyNamesToGeneratedNames[ts.getNodeId(node)]; + if (generatedName) { + write(generatedName); + return; + } + generatedName = createAndRecordTempVariable(0).text; + computedPropertyNamesToGeneratedNames[ts.getNodeId(node)] = generatedName; + write(generatedName); + write(" = "); + } + emit(node.expression); + } + else { + write("\""); + if (node.kind === 8) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + write("\""); + } + } + function isExpressionIdentifier(node) { + var parent = node.parent; + switch (parent.kind) { + case 164: + case 189: + case 181: + case 168: + case 241: + case 136: + case 182: + case 139: + case 175: + case 197: + case 167: + case 227: + case 195: + case 188: + case 199: + case 200: + case 201: + case 196: + case 234: + case 235: + case 239: + case 240: + case 169: + case 172: + case 180: + case 179: + case 204: + case 246: + case 185: + case 206: + case 170: + case 190: + case 208: + case 171: + case 176: + case 177: + case 198: + case 205: + case 184: + return true; + case 163: + case 247: + case 138: + case 245: + case 141: + case 211: + return parent.initializer === node; + case 166: + return parent.expression === node; + case 174: + case 173: + return parent.body === node; + case 221: + return parent.moduleReference === node; + case 135: + return parent.left === node; + } + return false; + } + function emitExpressionIdentifier(node) { + if (resolver.getNodeCheckFlags(node) & 2048) { + write("_arguments"); + return; + } + var container = resolver.getReferencedExportContainer(node); + if (container) { + if (container.kind === 248) { + if (modulekind !== 5 && modulekind !== 4) { + write("exports."); + } + } + else { + write(getGeneratedNameForNode(container)); + write("."); + } + } + else if (modulekind !== 5) { + var declaration = resolver.getReferencedImportDeclaration(node); + if (declaration) { + if (declaration.kind === 223) { + write(getGeneratedNameForNode(declaration.parent)); + write(languageVersion === 0 ? "[\"default\"]" : ".default"); + return; + } + else if (declaration.kind === 226) { + write(getGeneratedNameForNode(declaration.parent.parent.parent)); + var name_23 = declaration.propertyName || declaration.name; + var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name_23); + if (languageVersion === 0 && identifier === "default") { + write("[\"default\"]"); + } + else { + write("."); + write(identifier); + } + return; + } + } + declaration = resolver.getReferencedNestedRedeclaration(node); + if (declaration) { + write(getGeneratedNameForNode(declaration.name)); + return; + } + } + if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + } + function isNameOfNestedRedeclaration(node) { + if (languageVersion < 2) { + var parent_6 = node.parent; + switch (parent_6.kind) { + case 163: + case 214: + case 217: + case 211: + return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); + } + } + return false; + } + function emitIdentifier(node) { + if (!node.parent) { + write(node.text); + } + else if (isExpressionIdentifier(node)) { + emitExpressionIdentifier(node); + } + else if (isNameOfNestedRedeclaration(node)) { + write(getGeneratedNameForNode(node)); + } + else if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + } + function emitThis(node) { + if (resolver.getNodeCheckFlags(node) & 2) { + write("_this"); + } + else { + write("this"); + } + } + function emitSuper(node) { + if (languageVersion >= 2) { + write("super"); + } + else { + var flags = resolver.getNodeCheckFlags(node); + if (flags & 256) { + write("_super.prototype"); + } + else { + write("_super"); + } + } + } + function emitObjectBindingPattern(node) { + write("{ "); + var elements = node.elements; + emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + write(" }"); + } + function emitArrayBindingPattern(node) { + write("["); + var elements = node.elements; + emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + write("]"); + } + function emitBindingElement(node) { + if (node.propertyName) { + emit(node.propertyName); + write(": "); + } + if (node.dotDotDotToken) { + write("..."); + } + if (ts.isBindingPattern(node.name)) { + emit(node.name); + } + else { + emitModuleMemberName(node); + } + emitOptional(" = ", node.initializer); + } + function emitSpreadElementExpression(node) { + write("..."); + emit(node.expression); + } + function emitYieldExpression(node) { + write(ts.tokenToString(114)); + if (node.asteriskToken) { + write("*"); + } + if (node.expression) { + write(" "); + emit(node.expression); + } + } + function emitAwaitExpression(node) { + var needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); + if (needsParenthesis) { + write("("); + } + write(ts.tokenToString(114)); + write(" "); + emit(node.expression); + if (needsParenthesis) { + write(")"); + } + } + function needsParenthesisForAwaitExpressionAsYield(node) { + if (node.parent.kind === 181 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + return true; + } + else if (node.parent.kind === 182 && node.parent.condition === node) { + return true; + } + return false; + } + function needsParenthesisForPropertyAccessOrInvocation(node) { + switch (node.kind) { + case 69: + case 164: + case 166: + case 167: + case 168: + case 172: + return false; + } + return true; + } + function emitListWithSpread(elements, needsUniqueCopy, multiLine, trailingComma, useConcat) { + var pos = 0; + var group = 0; + var length = elements.length; + while (pos < length) { + if (group === 1 && useConcat) { + write(".concat("); + } + else if (group > 0) { + write(", "); + } + var e = elements[pos]; + if (e.kind === 185) { + e = e.expression; + emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); + pos++; + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 164) { + write(".slice()"); + } + } + else { + var i = pos; + while (i < length && elements[i].kind !== 185) { + i++; + } + write("["); + if (multiLine) { + increaseIndent(); + } + emitList(elements, pos, i - pos, multiLine, trailingComma && i === length); + if (multiLine) { + decreaseIndent(); + } + write("]"); + pos = i; + } + group++; + } + if (group > 1) { + if (useConcat) { + write(")"); + } + } + } + function isSpreadElementExpression(node) { + return node.kind === 185; + } + function emitArrayLiteral(node) { + var elements = node.elements; + if (elements.length === 0) { + write("[]"); + } + else if (languageVersion >= 2 || !ts.forEach(elements, isSpreadElementExpression)) { + write("["); + emitLinePreservingList(node, node.elements, elements.hasTrailingComma, false); + write("]"); + } + else { + emitListWithSpread(elements, true, (node.flags & 2048) !== 0, elements.hasTrailingComma, true); + } + } + function emitObjectLiteralBody(node, numElements) { + if (numElements === 0) { + write("{}"); + return; + } + write("{"); + if (numElements > 0) { + var properties = node.properties; + if (numElements === properties.length) { + emitLinePreservingList(node, properties, languageVersion >= 1, true); + } + else { + var multiLine = (node.flags & 2048) !== 0; + if (!multiLine) { + write(" "); + } + else { + increaseIndent(); + } + emitList(properties, 0, numElements, multiLine, false); + if (!multiLine) { + write(" "); + } + else { + decreaseIndent(); + } + } + } + write("}"); + } + function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { + var multiLine = (node.flags & 2048) !== 0; + var properties = node.properties; + write("("); + if (multiLine) { + increaseIndent(); + } + var tempVar = createAndRecordTempVariable(0); + emit(tempVar); + write(" = "); + emitObjectLiteralBody(node, firstComputedPropertyIndex); + for (var i = firstComputedPropertyIndex, n = properties.length; i < n; i++) { + writeComma(); + var property = properties[i]; + emitStart(property); + if (property.kind === 145 || property.kind === 146) { + var accessors = ts.getAllAccessorDeclarations(node.properties, property); + if (property !== accessors.firstAccessor) { + continue; + } + write("Object.defineProperty("); + emit(tempVar); + write(", "); + emitStart(node.name); + emitExpressionForPropertyName(property.name); + emitEnd(property.name); + write(", {"); + increaseIndent(); + if (accessors.getAccessor) { + writeLine(); + emitLeadingComments(accessors.getAccessor); + write("get: "); + emitStart(accessors.getAccessor); + write("function "); + emitSignatureAndBody(accessors.getAccessor); + emitEnd(accessors.getAccessor); + emitTrailingComments(accessors.getAccessor); + write(","); + } + if (accessors.setAccessor) { + writeLine(); + emitLeadingComments(accessors.setAccessor); + write("set: "); + emitStart(accessors.setAccessor); + write("function "); + emitSignatureAndBody(accessors.setAccessor); + emitEnd(accessors.setAccessor); + emitTrailingComments(accessors.setAccessor); + write(","); + } + writeLine(); + write("enumerable: true,"); + writeLine(); + write("configurable: true"); + decreaseIndent(); + writeLine(); + write("})"); + emitEnd(property); + } + else { + emitLeadingComments(property); + emitStart(property.name); + emit(tempVar); + emitMemberAccessForPropertyName(property.name); + emitEnd(property.name); + write(" = "); + if (property.kind === 245) { + emit(property.initializer); + } + else if (property.kind === 246) { + emitExpressionIdentifier(property.name); + } + else if (property.kind === 143) { + emitFunctionDeclaration(property); + } + else { + ts.Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind); + } + } + emitEnd(property); + } + writeComma(); + emit(tempVar); + if (multiLine) { + decreaseIndent(); + writeLine(); + } + write(")"); + function writeComma() { + if (multiLine) { + write(","); + writeLine(); + } + else { + write(", "); + } + } + } + function emitObjectLiteral(node) { + var properties = node.properties; + if (languageVersion < 2) { + var numProperties = properties.length; + var numInitialNonComputedProperties = numProperties; + for (var i = 0, n = properties.length; i < n; i++) { + if (properties[i].name.kind === 136) { + numInitialNonComputedProperties = i; + break; + } + } + var hasComputedProperty = numInitialNonComputedProperties !== properties.length; + if (hasComputedProperty) { + emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties); + return; + } + } + emitObjectLiteralBody(node, properties.length); + } + function createBinaryExpression(left, operator, right, startsOnNewLine) { + var result = ts.createSynthesizedNode(181, startsOnNewLine); + result.operatorToken = ts.createSynthesizedNode(operator); + result.left = left; + result.right = right; + return result; + } + function createPropertyAccessExpression(expression, name) { + var result = ts.createSynthesizedNode(166); + result.expression = parenthesizeForAccess(expression); + result.dotToken = ts.createSynthesizedNode(21); + result.name = name; + return result; + } + function createElementAccessExpression(expression, argumentExpression) { + var result = ts.createSynthesizedNode(167); + result.expression = parenthesizeForAccess(expression); + result.argumentExpression = argumentExpression; + return result; + } + function parenthesizeForAccess(expr) { + while (expr.kind === 171 || expr.kind === 189) { + expr = expr.expression; + } + if (ts.isLeftHandSideExpression(expr) && + expr.kind !== 169 && + expr.kind !== 8) { + return expr; + } + var node = ts.createSynthesizedNode(172); + node.expression = expr; + return node; + } + function emitComputedPropertyName(node) { + write("["); + emitExpressionForPropertyName(node); + write("]"); + } + function emitMethod(node) { + if (languageVersion >= 2 && node.asteriskToken) { + write("*"); + } + emit(node.name); + if (languageVersion < 2) { + write(": function "); + } + emitSignatureAndBody(node); + } + function emitPropertyAssignment(node) { + emit(node.name); + write(": "); + emitTrailingCommentsOfPosition(node.initializer.pos); + emit(node.initializer); + } + function isNamespaceExportReference(node) { + var container = resolver.getReferencedExportContainer(node); + return container && container.kind !== 248; + } + function emitShorthandPropertyAssignment(node) { + writeTextOfNode(currentSourceFile, node.name); + if (languageVersion < 2 || isNamespaceExportReference(node.name)) { + write(": "); + emit(node.name); + } + if (languageVersion >= 2 && node.objectAssignmentInitializer) { + write(" = "); + emit(node.objectAssignmentInitializer); + } + } + function tryEmitConstantValue(node) { + var constantValue = tryGetConstEnumValue(node); + if (constantValue !== undefined) { + write(constantValue.toString()); + if (!compilerOptions.removeComments) { + var propertyName = node.kind === 166 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + write(" /* " + propertyName + " */"); + } + return true; + } + return false; + } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return node.kind === 166 || node.kind === 167 + ? resolver.getConstantValue(node) + : undefined; + } + function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { + var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); + var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); + if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) { + increaseIndent(); + writeLine(); + return true; + } + else { + if (valueToWriteWhenNotIndenting) { + write(valueToWriteWhenNotIndenting); + } + return false; + } + } + function emitPropertyAccess(node) { + if (tryEmitConstantValue(node)) { + return; + } + emit(node.expression); + var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); + var shouldEmitSpace; + if (!indentedBeforeDot) { + if (node.expression.kind === 8) { + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(21)) < 0; + } + else { + var constantValue = tryGetConstEnumValue(node.expression); + shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; + } + } + if (shouldEmitSpace) { + write(" ."); + } + else { + write("."); + } + var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); + emit(node.name); + decreaseIndentIf(indentedBeforeDot, indentedAfterDot); + } + function emitQualifiedName(node) { + emit(node.left); + write("."); + emit(node.right); + } + function emitQualifiedNameAsExpression(node, useFallback) { + if (node.left.kind === 69) { + emitEntityNameAsExpression(node.left, useFallback); + } + else if (useFallback) { + var temp = createAndRecordTempVariable(0); + write("("); + emitNodeWithoutSourceMap(temp); + write(" = "); + emitEntityNameAsExpression(node.left, true); + write(") && "); + emitNodeWithoutSourceMap(temp); + } + else { + emitEntityNameAsExpression(node.left, false); + } + write("."); + emit(node.right); + } + function emitEntityNameAsExpression(node, useFallback) { + switch (node.kind) { + case 69: + if (useFallback) { + write("typeof "); + emitExpressionIdentifier(node); + write(" !== 'undefined' && "); + } + emitExpressionIdentifier(node); + break; + case 135: + emitQualifiedNameAsExpression(node, useFallback); + break; + } + } + function emitIndexedAccess(node) { + if (tryEmitConstantValue(node)) { + return; + } + emit(node.expression); + write("["); + emit(node.argumentExpression); + write("]"); + } + function hasSpreadElement(elements) { + return ts.forEach(elements, function (e) { return e.kind === 185; }); + } + function skipParentheses(node) { + while (node.kind === 172 || node.kind === 171 || node.kind === 189) { + node = node.expression; + } + return node; + } + function emitCallTarget(node) { + if (node.kind === 69 || node.kind === 97 || node.kind === 95) { + emit(node); + return node; + } + var temp = createAndRecordTempVariable(0); + write("("); + emit(temp); + write(" = "); + emit(node); + write(")"); + return temp; + } + function emitCallWithSpread(node) { + var target; + var expr = skipParentheses(node.expression); + if (expr.kind === 166) { + target = emitCallTarget(expr.expression); + write("."); + emit(expr.name); + } + else if (expr.kind === 167) { + target = emitCallTarget(expr.expression); + write("["); + emit(expr.argumentExpression); + write("]"); + } + else if (expr.kind === 95) { + target = expr; + write("_super"); + } + else { + emit(node.expression); + } + write(".apply("); + if (target) { + if (target.kind === 95) { + emitThis(target); + } + else { + emit(target); + } + } + else { + write("void 0"); + } + write(", "); + emitListWithSpread(node.arguments, false, false, false, true); + write(")"); + } + function emitCallExpression(node) { + if (languageVersion < 2 && hasSpreadElement(node.arguments)) { + emitCallWithSpread(node); + return; + } + var superCall = false; + if (node.expression.kind === 95) { + emitSuper(node.expression); + superCall = true; + } + else { + emit(node.expression); + superCall = node.expression.kind === 166 && node.expression.expression.kind === 95; + } + if (superCall && languageVersion < 2) { + write(".call("); + emitThis(node.expression); + if (node.arguments.length) { + write(", "); + emitCommaList(node.arguments); + } + write(")"); + } + else { + write("("); + emitCommaList(node.arguments); + write(")"); + } + } + function emitNewExpression(node) { + write("new "); + if (languageVersion === 1 && + node.arguments && + hasSpreadElement(node.arguments)) { + write("("); + var target = emitCallTarget(node.expression); + write(".bind.apply("); + emit(target); + write(", [void 0].concat("); + emitListWithSpread(node.arguments, false, false, false, false); + write(")))"); + write("()"); + } + else { + emit(node.expression); + if (node.arguments) { + write("("); + emitCommaList(node.arguments); + write(")"); + } + } + } + function emitTaggedTemplateExpression(node) { + if (languageVersion >= 2) { + emit(node.tag); + write(" "); + emit(node.template); + } + else { + emitDownlevelTaggedTemplate(node); + } + } + function emitParenExpression(node) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 174) { + if (node.expression.kind === 171 || node.expression.kind === 189) { + var operand = node.expression.expression; + while (operand.kind === 171 || operand.kind === 189) { + operand = operand.expression; + } + if (operand.kind !== 179 && + operand.kind !== 177 && + operand.kind !== 176 && + operand.kind !== 175 && + operand.kind !== 180 && + operand.kind !== 169 && + !(operand.kind === 168 && node.parent.kind === 169) && + !(operand.kind === 173 && node.parent.kind === 168) && + !(operand.kind === 8 && node.parent.kind === 166)) { + emit(operand); + return; + } + } + } + write("("); + emit(node.expression); + write(")"); + } + function emitDeleteExpression(node) { + write(ts.tokenToString(78)); + write(" "); + emit(node.expression); + } + function emitVoidExpression(node) { + write(ts.tokenToString(103)); + write(" "); + emit(node.expression); + } + function emitTypeOfExpression(node) { + write(ts.tokenToString(101)); + write(" "); + emit(node.expression); + } + function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 69 || ts.nodeIsSynthesized(node)) { + return false; + } + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 211 || node.parent.kind === 163); + var targetDeclaration = isVariableDeclarationOrBindingElement + ? node.parent + : resolver.getReferencedValueDeclaration(node); + return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, true); + } + function emitPrefixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + } + write(ts.tokenToString(node.operator)); + if (node.operand.kind === 179) { + var operand = node.operand; + if (node.operator === 35 && (operand.operator === 35 || operand.operator === 41)) { + write(" "); + } + else if (node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) { + write(" "); + } + } + emit(node.operand); + if (exportChanged) { + write(")"); + } + } + function emitPostfixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + write("(" + exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + write(ts.tokenToString(node.operator)); + emit(node.operand); + if (node.operator === 41) { + write(") - 1)"); + } + else { + write(") + 1)"); + } + } + else { + emit(node.operand); + write(ts.tokenToString(node.operator)); + } + } + function shouldHoistDeclarationInSystemJsModule(node) { + return isSourceFileLevelDeclarationInSystemJsModule(node, false); + } + function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) { + if (!node || languageVersion >= 2 || !isCurrentFileSystemExternalModule()) { + return false; + } + var current = node; + while (current) { + if (current.kind === 248) { + return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); + } + else if (ts.isFunctionLike(current) || current.kind === 219) { + return false; + } + else { + current = current.parent; + } + } + } + function emitExponentiationOperator(node) { + var leftHandSideExpression = node.left; + if (node.operatorToken.kind === 60) { + var synthesizedLHS; + var shouldEmitParentheses = false; + if (ts.isElementAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(167, false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); + synthesizedLHS.expression = identifier; + if (leftHandSideExpression.argumentExpression.kind !== 8 && + leftHandSideExpression.argumentExpression.kind !== 9) { + var tempArgumentExpression = createAndRecordTempVariable(268435456); + synthesizedLHS.argumentExpression = tempArgumentExpression; + emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, true); + } + else { + synthesizedLHS.argumentExpression = leftHandSideExpression.argumentExpression; + } + write(", "); + } + else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(166, false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); + synthesizedLHS.expression = identifier; + synthesizedLHS.dotToken = leftHandSideExpression.dotToken; + synthesizedLHS.name = leftHandSideExpression.name; + write(", "); + } + emit(synthesizedLHS || leftHandSideExpression); + write(" = "); + write("Math.pow("); + emit(synthesizedLHS || leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + if (shouldEmitParentheses) { + write(")"); + } + } + else { + write("Math.pow("); + emit(leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + } + } + function emitBinaryExpression(node) { + if (languageVersion < 2 && node.operatorToken.kind === 56 && + (node.left.kind === 165 || node.left.kind === 164)) { + emitDestructuring(node, node.parent.kind === 195); + } + else { + var exportChanged = node.operatorToken.kind >= 56 && + node.operatorToken.kind <= 68 && + isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.left); + write("\", "); + } + if (node.operatorToken.kind === 38 || node.operatorToken.kind === 60) { + emitExponentiationOperator(node); + } + else { + emit(node.left); + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 ? " " : undefined); + write(ts.tokenToString(node.operatorToken.kind)); + var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); + emit(node.right); + decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); + } + if (exportChanged) { + write(")"); + } + } + } + function synthesizedNodeStartsOnNewLine(node) { + return ts.nodeIsSynthesized(node) && node.startsOnNewLine; + } + function emitConditionalExpression(node) { + emit(node.condition); + var indentedBeforeQuestion = indentIfOnDifferentLines(node, node.condition, node.questionToken, " "); + write("?"); + var indentedAfterQuestion = indentIfOnDifferentLines(node, node.questionToken, node.whenTrue, " "); + emit(node.whenTrue); + decreaseIndentIf(indentedBeforeQuestion, indentedAfterQuestion); + var indentedBeforeColon = indentIfOnDifferentLines(node, node.whenTrue, node.colonToken, " "); + write(":"); + var indentedAfterColon = indentIfOnDifferentLines(node, node.colonToken, node.whenFalse, " "); + emit(node.whenFalse); + decreaseIndentIf(indentedBeforeColon, indentedAfterColon); + } + function decreaseIndentIf(value1, value2) { + if (value1) { + decreaseIndent(); + } + if (value2) { + decreaseIndent(); + } + } + function isSingleLineEmptyBlock(node) { + if (node && node.kind === 192) { + var block = node; + return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); + } + } + function emitBlock(node) { + if (isSingleLineEmptyBlock(node)) { + emitToken(15, node.pos); + write(" "); + emitToken(16, node.statements.end); + return; + } + emitToken(15, node.pos); + increaseIndent(); + scopeEmitStart(node.parent); + if (node.kind === 219) { + ts.Debug.assert(node.parent.kind === 218); + emitCaptureThisForNodeIfNecessary(node.parent); + } + emitLines(node.statements); + if (node.kind === 219) { + emitTempDeclarations(true); + } + decreaseIndent(); + writeLine(); + emitToken(16, node.statements.end); + scopeEmitEnd(); + } + function emitEmbeddedStatement(node) { + if (node.kind === 192) { + write(" "); + emit(node); + } + else { + increaseIndent(); + writeLine(); + emit(node); + decreaseIndent(); + } + } + function emitExpressionStatement(node) { + emitParenthesizedIf(node.expression, node.expression.kind === 174); + write(";"); + } + function emitIfStatement(node) { + var endPos = emitToken(88, node.pos); + write(" "); + endPos = emitToken(17, endPos); + emit(node.expression); + emitToken(18, node.expression.end); + emitEmbeddedStatement(node.thenStatement); + if (node.elseStatement) { + writeLine(); + emitToken(80, node.thenStatement.end); + if (node.elseStatement.kind === 196) { + write(" "); + emit(node.elseStatement); + } + else { + emitEmbeddedStatement(node.elseStatement); + } + } + } + function emitDoStatement(node) { + write("do"); + emitEmbeddedStatement(node.statement); + if (node.statement.kind === 192) { + write(" "); + } + else { + writeLine(); + } + write("while ("); + emit(node.expression); + write(");"); + } + function emitWhileStatement(node) { + write("while ("); + emit(node.expression); + write(")"); + emitEmbeddedStatement(node.statement); + } + function tryEmitStartOfVariableDeclarationList(decl, startPos) { + if (shouldHoistVariable(decl, true)) { + return false; + } + var tokenKind = 102; + if (decl && languageVersion >= 2) { + if (ts.isLet(decl)) { + tokenKind = 108; + } + else if (ts.isConst(decl)) { + tokenKind = 74; + } + } + if (startPos !== undefined) { + emitToken(tokenKind, startPos); + write(" "); + } + else { + switch (tokenKind) { + case 102: + write("var "); + break; + case 108: + write("let "); + break; + case 74: + write("const "); + break; + } + } + return true; + } + function emitVariableDeclarationListSkippingUninitializedEntries(list) { + var started = false; + for (var _a = 0, _b = list.declarations; _a < _b.length; _a++) { + var decl = _b[_a]; + if (!decl.initializer) { + continue; + } + if (!started) { + started = true; + } + else { + write(", "); + } + emit(decl); + } + return started; + } + function emitForStatement(node) { + var endPos = emitToken(86, node.pos); + write(" "); + endPos = emitToken(17, endPos); + if (node.initializer && node.initializer.kind === 212) { + var variableDeclarationList = node.initializer; + var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + if (startIsEmitted) { + emitCommaList(variableDeclarationList.declarations); + } + else { + emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); + } + } + else if (node.initializer) { + emit(node.initializer); + } + write(";"); + emitOptional(" ", node.condition); + write(";"); + emitOptional(" ", node.incrementor); + write(")"); + emitEmbeddedStatement(node.statement); + } + function emitForInOrForOfStatement(node) { + if (languageVersion < 2 && node.kind === 201) { + return emitDownLevelForOfStatement(node); + } + var endPos = emitToken(86, node.pos); + write(" "); + endPos = emitToken(17, endPos); + if (node.initializer.kind === 212) { + var variableDeclarationList = node.initializer; + if (variableDeclarationList.declarations.length >= 1) { + tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + emit(variableDeclarationList.declarations[0]); + } + } + else { + emit(node.initializer); + } + if (node.kind === 200) { + write(" in "); + } + else { + write(" of "); + } + emit(node.expression); + emitToken(18, node.expression.end); + emitEmbeddedStatement(node.statement); + } + function emitDownLevelForOfStatement(node) { + var endPos = emitToken(86, node.pos); + write(" "); + endPos = emitToken(17, endPos); + var rhsIsIdentifier = node.expression.kind === 69; + var counter = createTempVariable(268435456); + var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); + emitStart(node.expression); + write("var "); + emitNodeWithoutSourceMap(counter); + write(" = 0"); + emitEnd(node.expression); + if (!rhsIsIdentifier) { + write(", "); + emitStart(node.expression); + emitNodeWithoutSourceMap(rhsReference); + write(" = "); + emitNodeWithoutSourceMap(node.expression); + emitEnd(node.expression); + } + write("; "); + emitStart(node.initializer); + emitNodeWithoutSourceMap(counter); + write(" < "); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); + write(".length"); + emitEnd(node.initializer); + write("; "); + emitStart(node.initializer); + emitNodeWithoutSourceMap(counter); + write("++"); + emitEnd(node.initializer); + emitToken(18, node.expression.end); + write(" {"); + writeLine(); + increaseIndent(); + var rhsIterationValue = createElementAccessExpression(rhsReference, counter); + emitStart(node.initializer); + if (node.initializer.kind === 212) { + write("var "); + var variableDeclarationList = node.initializer; + if (variableDeclarationList.declarations.length > 0) { + var declaration = variableDeclarationList.declarations[0]; + if (ts.isBindingPattern(declaration.name)) { + emitDestructuring(declaration, false, rhsIterationValue); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(declaration); + write(" = "); + emitNodeWithoutSourceMap(rhsIterationValue); + } + } + else { + emitNodeWithoutSourceMap(createTempVariable(0)); + write(" = "); + emitNodeWithoutSourceMap(rhsIterationValue); + } + } + else { + var assignmentExpression = createBinaryExpression(node.initializer, 56, rhsIterationValue, false); + if (node.initializer.kind === 164 || node.initializer.kind === 165) { + emitDestructuring(assignmentExpression, true, undefined); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); + } + } + emitEnd(node.initializer); + write(";"); + if (node.statement.kind === 192) { + emitLines(node.statement.statements); + } + else { + writeLine(); + emit(node.statement); + } + writeLine(); + decreaseIndent(); + write("}"); + } + function emitBreakOrContinueStatement(node) { + emitToken(node.kind === 203 ? 70 : 75, node.pos); + emitOptional(" ", node.label); + write(";"); + } + function emitReturnStatement(node) { + emitToken(94, node.pos); + emitOptional(" ", node.expression); + write(";"); + } + function emitWithStatement(node) { + write("with ("); + emit(node.expression); + write(")"); + emitEmbeddedStatement(node.statement); + } + function emitSwitchStatement(node) { + var endPos = emitToken(96, node.pos); + write(" "); + emitToken(17, endPos); + emit(node.expression); + endPos = emitToken(18, node.expression.end); + write(" "); + emitCaseBlock(node.caseBlock, endPos); + } + function emitCaseBlock(node, startPos) { + emitToken(15, startPos); + increaseIndent(); + emitLines(node.clauses); + decreaseIndent(); + writeLine(); + emitToken(16, node.clauses.end); + } + function nodeStartPositionsAreOnSameLine(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + } + function nodeEndPositionsAreOnSameLine(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, node2.end); + } + function nodeEndIsOnSameLineAsNodeStart(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + } + function emitCaseOrDefaultClause(node) { + if (node.kind === 241) { + write("case "); + emit(node.expression); + write(":"); + } + else { + write("default:"); + } + if (node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) { + write(" "); + emit(node.statements[0]); + } + else { + increaseIndent(); + emitLines(node.statements); + decreaseIndent(); + } + } + function emitThrowStatement(node) { + write("throw "); + emit(node.expression); + write(";"); + } + function emitTryStatement(node) { + write("try "); + emit(node.tryBlock); + emit(node.catchClause); + if (node.finallyBlock) { + writeLine(); + write("finally "); + emit(node.finallyBlock); + } + } + function emitCatchClause(node) { + writeLine(); + var endPos = emitToken(72, node.pos); + write(" "); + emitToken(17, endPos); + emit(node.variableDeclaration); + emitToken(18, node.variableDeclaration ? node.variableDeclaration.end : endPos); + write(" "); + emitBlock(node.block); + } + function emitDebuggerStatement(node) { + emitToken(76, node.pos); + write(";"); + } + function emitLabelledStatement(node) { + emit(node.label); + write(": "); + emit(node.statement); + } + function getContainingModule(node) { + do { + node = node.parent; + } while (node && node.kind !== 218); + return node; + } + function emitContainingModuleName(node) { + var container = getContainingModule(node); + write(container ? getGeneratedNameForNode(container) : "exports"); + } + function emitModuleMemberName(node) { + emitStart(node.name); + if (ts.getCombinedNodeFlags(node) & 1) { + var container = getContainingModule(node); + if (container) { + write(getGeneratedNameForNode(container)); + write("."); + } + else if (modulekind !== 5 && modulekind !== 4) { + write("exports."); + } + } + emitNodeWithCommentsAndWithoutSourcemap(node.name); + emitEnd(node.name); + } + function createVoidZero() { + var zero = ts.createSynthesizedNode(8); + zero.text = "0"; + var result = ts.createSynthesizedNode(177); + result.expression = zero; + return result; + } + function emitEs6ExportDefaultCompat(node) { + if (node.parent.kind === 248) { + ts.Debug.assert(!!(node.flags & 1024) || node.kind === 227); + if (modulekind === 1 || modulekind === 2 || modulekind === 3) { + if (!currentSourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 1) { + write("Object.defineProperty(exports, \"__esModule\", { value: true });"); + writeLine(); + } + else if (languageVersion === 0) { + write("exports.__esModule = true;"); + writeLine(); + } + } + } + } + } + function emitExportMemberAssignment(node) { + if (node.flags & 1) { + writeLine(); + emitStart(node); + if (modulekind === 4 && node.parent === currentSourceFile) { + write(exportFunctionForFile + "(\""); + if (node.flags & 1024) { + write("default"); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(node.name); + } + write("\", "); + emitDeclarationName(node); + write(")"); + } + else { + if (node.flags & 1024) { + emitEs6ExportDefaultCompat(node); + if (languageVersion === 0) { + write("exports[\"default\"]"); + } + else { + write("exports.default"); + } + } + else { + emitModuleMemberName(node); + } + write(" = "); + emitDeclarationName(node); + } + emitEnd(node); + write(";"); + } + } + function emitExportMemberAssignments(name) { + if (modulekind === 4) { + return; + } + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { + var specifier = _b[_a]; + writeLine(); + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); + write(";"); + } + } + } + function emitExportSpecifierInSystemModule(specifier) { + ts.Debug.assert(modulekind === 4); + if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { + return; + } + writeLine(); + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write("\", "); + emitExpressionIdentifier(specifier.propertyName || specifier.name); + write(")"); + emitEnd(specifier.name); + write(";"); + } + function emitAssignment(name, value, shouldEmitCommaBeforeAssignment) { + if (shouldEmitCommaBeforeAssignment) { + write(", "); + } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(name); + write("\", "); + } + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 211 || name.parent.kind === 163); + if (isVariableDeclarationOrBindingElement) { + emitModuleMemberName(name.parent); + } + else { + emit(name); + } + write(" = "); + emit(value); + if (exportChanged) { + write(")"); + } + } + function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment) { + var identifier = createTempVariable(0); + if (!canDefineTempVariablesInPlace) { + recordTempDeclaration(identifier); + } + emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment); + return identifier; + } + function emitDestructuring(root, isAssignmentExpressionStatement, value) { + var emitCount = 0; + var canDefineTempVariablesInPlace = false; + if (root.kind === 211) { + var isExported = ts.getCombinedNodeFlags(root) & 1; + var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); + canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; + } + else if (root.kind === 138) { + canDefineTempVariablesInPlace = true; + } + if (root.kind === 181) { + emitAssignmentExpression(root); + } + else { + ts.Debug.assert(!isAssignmentExpressionStatement); + emitBindingElement(root, value); + } + function ensureIdentifier(expr, reuseIdentifierExpressions) { + if (expr.kind === 69 && reuseIdentifierExpressions) { + return expr; + } + var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0); + emitCount++; + return identifier; + } + function createDefaultValueCheck(value, defaultValue) { + value = ensureIdentifier(value, true); + var equals = ts.createSynthesizedNode(181); + equals.left = value; + equals.operatorToken = ts.createSynthesizedNode(32); + equals.right = createVoidZero(); + return createConditionalExpression(equals, defaultValue, value); + } + function createConditionalExpression(condition, whenTrue, whenFalse) { + var cond = ts.createSynthesizedNode(182); + cond.condition = condition; + cond.questionToken = ts.createSynthesizedNode(53); + cond.whenTrue = whenTrue; + cond.colonToken = ts.createSynthesizedNode(54); + cond.whenFalse = whenFalse; + return cond; + } + function createNumericLiteral(value) { + var node = ts.createSynthesizedNode(8); + node.text = "" + value; + return node; + } + function createPropertyAccessForDestructuringProperty(object, propName) { + var syntheticName = ts.createSynthesizedNode(propName.kind); + syntheticName.text = propName.text; + if (syntheticName.kind !== 69) { + return createElementAccessExpression(object, syntheticName); + } + return createPropertyAccessExpression(object, syntheticName); + } + function createSliceCall(value, sliceIndex) { + var call = ts.createSynthesizedNode(168); + var sliceIdentifier = ts.createSynthesizedNode(69); + sliceIdentifier.text = "slice"; + call.expression = createPropertyAccessExpression(value, sliceIdentifier); + call.arguments = ts.createSynthesizedNodeArray(); + call.arguments[0] = createNumericLiteral(sliceIndex); + return call; + } + function emitObjectLiteralAssignment(target, value) { + var properties = target.properties; + if (properties.length !== 1) { + value = ensureIdentifier(value, true); + } + for (var _a = 0; _a < properties.length; _a++) { + var p = properties[_a]; + if (p.kind === 245 || p.kind === 246) { + var propName = p.name; + var target_1 = p.kind === 246 ? p : p.initializer || propName; + emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName)); + } + } + } + function emitArrayLiteralAssignment(target, value) { + var elements = target.elements; + if (elements.length !== 1) { + value = ensureIdentifier(value, true); + } + for (var i = 0; i < elements.length; i++) { + var e = elements[i]; + if (e.kind !== 187) { + if (e.kind !== 185) { + emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); + } + else if (i === elements.length - 1) { + emitDestructuringAssignment(e.expression, createSliceCall(value, i)); + } + } + } + } + function emitDestructuringAssignment(target, value) { + if (target.kind === 246) { + if (target.objectAssignmentInitializer) { + value = createDefaultValueCheck(value, target.objectAssignmentInitializer); + } + target = target.name; + } + else if (target.kind === 181 && target.operatorToken.kind === 56) { + value = createDefaultValueCheck(value, target.right); + target = target.left; + } + if (target.kind === 165) { + emitObjectLiteralAssignment(target, value); + } + else if (target.kind === 164) { + emitArrayLiteralAssignment(target, value); + } + else { + emitAssignment(target, value, emitCount > 0); + emitCount++; + } + } + function emitAssignmentExpression(root) { + var target = root.left; + var value = root.right; + if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { + emit(value); + } + else if (isAssignmentExpressionStatement) { + emitDestructuringAssignment(target, value); + } + else { + if (root.parent.kind !== 172) { + write("("); + } + value = ensureIdentifier(value, true); + emitDestructuringAssignment(target, value); + write(", "); + emit(value); + if (root.parent.kind !== 172) { + write(")"); + } + } + } + function emitBindingElement(target, value) { + if (target.initializer) { + value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; + } + else if (!value) { + value = createVoidZero(); + } + if (ts.isBindingPattern(target.name)) { + var pattern = target.name; + var elements = pattern.elements; + var numElements = elements.length; + if (numElements !== 1) { + value = ensureIdentifier(value, numElements !== 0); + } + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (pattern.kind === 161) { + var propName = element.propertyName || element.name; + emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); + } + else if (element.kind !== 187) { + if (!element.dotDotDotToken) { + emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); + } + else if (i === numElements - 1) { + emitBindingElement(element, createSliceCall(value, i)); + } + } + } + } + else { + emitAssignment(target.name, value, emitCount > 0); + emitCount++; + } + } + } + function emitVariableDeclaration(node) { + if (ts.isBindingPattern(node.name)) { + if (languageVersion < 2) { + emitDestructuring(node, false); + } + else { + emit(node.name); + emitOptional(" = ", node.initializer); + } + } + else { + var initializer = node.initializer; + if (!initializer && languageVersion < 2) { + var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384) && + (getCombinedFlagsForIdentifier(node.name) & 16384); + if (isUninitializedLet && + node.parent.parent.kind !== 200 && + node.parent.parent.kind !== 201) { + initializer = createVoidZero(); + } + } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(node.name); + write("\", "); + } + emitModuleMemberName(node); + emitOptional(" = ", initializer); + if (exportChanged) { + write(")"); + } + } + } + function emitExportVariableAssignments(node) { + if (node.kind === 187) { + return; + } + var name = node.name; + if (name.kind === 69) { + emitExportMemberAssignments(name); + } + else if (ts.isBindingPattern(name)) { + ts.forEach(name.elements, emitExportVariableAssignments); + } + } + function getCombinedFlagsForIdentifier(node) { + if (!node.parent || (node.parent.kind !== 211 && node.parent.kind !== 163)) { + return 0; + } + return ts.getCombinedNodeFlags(node.parent); + } + function isES6ExportedDeclaration(node) { + return !!(node.flags & 1) && + modulekind === 5 && + node.parent.kind === 248; + } + function emitVariableStatement(node) { + var startIsEmitted = false; + if (node.flags & 1) { + if (isES6ExportedDeclaration(node)) { + write("export "); + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + } + else { + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + if (startIsEmitted) { + emitCommaList(node.declarationList.declarations); + write(";"); + } + else { + var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); + if (atLeastOneItem) { + write(";"); + } + } + if (modulekind !== 5 && node.parent === currentSourceFile) { + ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); + } + } + function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { + if (!(node.flags & 1)) { + return true; + } + if (isES6ExportedDeclaration(node)) { + return true; + } + for (var _a = 0, _b = node.declarationList.declarations; _a < _b.length; _a++) { + var declaration = _b[_a]; + if (declaration.initializer) { + return true; + } + } + return false; + } + function emitParameter(node) { + if (languageVersion < 2) { + if (ts.isBindingPattern(node.name)) { + var name_24 = createTempVariable(0); + if (!tempParameters) { + tempParameters = []; + } + tempParameters.push(name_24); + emit(name_24); + } + else { + emit(node.name); + } + } + else { + if (node.dotDotDotToken) { + write("..."); + } + emit(node.name); + emitOptional(" = ", node.initializer); + } + } + function emitDefaultValueAssignments(node) { + if (languageVersion < 2) { + var tempIndex = 0; + ts.forEach(node.parameters, function (parameter) { + if (parameter.dotDotDotToken) { + return; + } + var paramName = parameter.name, initializer = parameter.initializer; + if (ts.isBindingPattern(paramName)) { + var hasBindingElements = paramName.elements.length > 0; + if (hasBindingElements || initializer) { + writeLine(); + write("var "); + if (hasBindingElements) { + emitDestructuring(parameter, false, tempParameters[tempIndex]); + } + else { + emit(tempParameters[tempIndex]); + write(" = "); + emit(initializer); + } + write(";"); + tempIndex++; + } + } + else if (initializer) { + writeLine(); + emitStart(parameter); + write("if ("); + emitNodeWithoutSourceMap(paramName); + write(" === void 0)"); + emitEnd(parameter); + write(" { "); + emitStart(parameter); + emitNodeWithCommentsAndWithoutSourcemap(paramName); + write(" = "); + emitNodeWithCommentsAndWithoutSourcemap(initializer); + emitEnd(parameter); + write("; }"); + } + }); + } + } + function emitRestParameter(node) { + if (languageVersion < 2 && ts.hasRestParameter(node)) { + var restIndex = node.parameters.length - 1; + var restParam = node.parameters[restIndex]; + if (ts.isBindingPattern(restParam.name)) { + return; + } + var tempName = createTempVariable(268435456).text; + writeLine(); + emitLeadingComments(restParam); + emitStart(restParam); + write("var "); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); + write(" = [];"); + emitEnd(restParam); + emitTrailingComments(restParam); + writeLine(); + write("for ("); + emitStart(restParam); + write("var " + tempName + " = " + restIndex + ";"); + emitEnd(restParam); + write(" "); + emitStart(restParam); + write(tempName + " < arguments.length;"); + emitEnd(restParam); + write(" "); + emitStart(restParam); + write(tempName + "++"); + emitEnd(restParam); + write(") {"); + increaseIndent(); + writeLine(); + emitStart(restParam); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); + write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); + emitEnd(restParam); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function emitAccessor(node) { + write(node.kind === 145 ? "get " : "set "); + emit(node.name); + emitSignatureAndBody(node); + } + function shouldEmitAsArrowFunction(node) { + return node.kind === 174 && languageVersion >= 2; + } + function emitDeclarationName(node) { + if (node.name) { + emitNodeWithCommentsAndWithoutSourcemap(node.name); + } + else { + write(getGeneratedNameForNode(node)); + } + } + function shouldEmitFunctionName(node) { + if (node.kind === 173) { + return !!node.name; + } + if (node.kind === 213) { + return !!node.name || languageVersion < 2; + } + } + function emitFunctionDeclaration(node) { + if (ts.nodeIsMissing(node.body)) { + return emitCommentsOnNotEmittedNode(node); + } + if (node.kind !== 143 && node.kind !== 142 && + node.parent && node.parent.kind !== 245 && + node.parent.kind !== 168) { + emitLeadingComments(node); + } + emitStart(node); + if (!shouldEmitAsArrowFunction(node)) { + if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 1024) { + write("default "); + } + } + write("function"); + if (languageVersion >= 2 && node.asteriskToken) { + write("*"); + } + write(" "); + } + if (shouldEmitFunctionName(node)) { + emitDeclarationName(node); + } + emitSignatureAndBody(node); + if (modulekind !== 5 && node.kind === 213 && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } + emitEnd(node); + if (node.kind !== 143 && node.kind !== 142) { + emitTrailingComments(node); + } + } + function emitCaptureThisForNodeIfNecessary(node) { + if (resolver.getNodeCheckFlags(node) & 4) { + writeLine(); + emitStart(node); + write("var _this = this;"); + emitEnd(node); + } + } + function emitSignatureParameters(node) { + increaseIndent(); + write("("); + if (node) { + var parameters = node.parameters; + var omitCount = languageVersion < 2 && ts.hasRestParameter(node) ? 1 : 0; + emitList(parameters, 0, parameters.length - omitCount, false, false); + } + write(")"); + decreaseIndent(); + } + function emitSignatureParametersForArrow(node) { + if (node.parameters.length === 1 && node.pos === node.parameters[0].pos) { + emit(node.parameters[0]); + return; + } + emitSignatureParameters(node); + } + function emitAsyncFunctionBodyForES6(node) { + var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); + var isArrowFunction = node.kind === 174; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096) !== 0; + var args; + if (!isArrowFunction) { + write(" {"); + increaseIndent(); + writeLine(); + write("return"); + } + write(" __awaiter(this"); + if (hasLexicalArguments) { + write(", arguments"); + } + else { + write(", void 0"); + } + if (promiseConstructor) { + write(", "); + emitNodeWithoutSourceMap(promiseConstructor); + } + else { + write(", Promise"); + } + if (hasLexicalArguments) { + write(", function* (_arguments)"); + } + else { + write(", function* ()"); + } + emitFunctionBody(node); + write(")"); + if (!isArrowFunction) { + write(";"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function emitFunctionBody(node) { + if (!node.body) { + write(" { }"); + } + else { + if (node.body.kind === 192) { + emitBlockFunctionBody(node, node.body); + } + else { + emitExpressionFunctionBody(node, node.body); + } + } + } + function emitSignatureAndBody(node) { + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + if (shouldEmitAsArrowFunction(node)) { + emitSignatureParametersForArrow(node); + write(" =>"); + } + else { + emitSignatureParameters(node); + } + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync && languageVersion === 2) { + emitAsyncFunctionBodyForES6(node); + } + else { + emitFunctionBody(node); + } + if (!isES6ExportedDeclaration(node)) { + emitExportMemberAssignment(node); + } + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } + function emitFunctionBodyPreamble(node) { + emitCaptureThisForNodeIfNecessary(node); + emitDefaultValueAssignments(node); + emitRestParameter(node); + } + function emitExpressionFunctionBody(node, body) { + if (languageVersion < 2 || node.flags & 512) { + emitDownLevelExpressionFunctionBody(node, body); + return; + } + write(" "); + var current = body; + while (current.kind === 171) { + current = current.expression; + } + emitParenthesizedIf(body, current.kind === 165); + } + function emitDownLevelExpressionFunctionBody(node, body) { + write(" {"); + scopeEmitStart(node); + increaseIndent(); + var outPos = writer.getTextPos(); + emitDetachedComments(node.body); + emitFunctionBodyPreamble(node); + var preambleEmitted = writer.getTextPos() !== outPos; + decreaseIndent(); + if (!preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) { + write(" "); + emitStart(body); + write("return "); + emit(body); + emitEnd(body); + write(";"); + emitTempDeclarations(false); + write(" "); + } + else { + increaseIndent(); + writeLine(); + emitLeadingComments(node.body); + write("return "); + emit(body); + write(";"); + emitTrailingComments(node.body); + emitTempDeclarations(true); + decreaseIndent(); + writeLine(); + } + emitStart(node.body); + write("}"); + emitEnd(node.body); + scopeEmitEnd(); + } + function emitBlockFunctionBody(node, body) { + write(" {"); + scopeEmitStart(node); + var initialTextPos = writer.getTextPos(); + increaseIndent(); + emitDetachedComments(body.statements); + var startIndex = emitDirectivePrologues(body.statements, true); + emitFunctionBodyPreamble(node); + decreaseIndent(); + var preambleEmitted = writer.getTextPos() !== initialTextPos; + if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { + for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { + var statement = _b[_a]; + write(" "); + emit(statement); + } + emitTempDeclarations(false); + write(" "); + emitLeadingCommentsOfPosition(body.statements.end); + } + else { + increaseIndent(); + emitLinesStartingAt(body.statements, startIndex); + emitTempDeclarations(true); + writeLine(); + emitLeadingCommentsOfPosition(body.statements.end); + decreaseIndent(); + } + emitToken(16, body.statements.end); + scopeEmitEnd(); + } + function findInitialSuperCall(ctor) { + if (ctor.body) { + var statement = ctor.body.statements[0]; + if (statement && statement.kind === 195) { + var expr = statement.expression; + if (expr && expr.kind === 168) { + var func = expr.expression; + if (func && func.kind === 95) { + return statement; + } + } + } + } + } + function emitParameterPropertyAssignments(node) { + ts.forEach(node.parameters, function (param) { + if (param.flags & 112) { + writeLine(); + emitStart(param); + emitStart(param.name); + write("this."); + emitNodeWithoutSourceMap(param.name); + emitEnd(param.name); + write(" = "); + emit(param.name); + write(";"); + emitEnd(param); + } + }); + } + function emitMemberAccessForPropertyName(memberName) { + if (memberName.kind === 9 || memberName.kind === 8) { + write("["); + emitNodeWithCommentsAndWithoutSourcemap(memberName); + write("]"); + } + else if (memberName.kind === 136) { + emitComputedPropertyName(memberName); + } + else { + write("."); + emitNodeWithCommentsAndWithoutSourcemap(memberName); + } + } + function getInitializedProperties(node, isStatic) { + var properties = []; + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if (member.kind === 141 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { + properties.push(member); + } + } + return properties; + } + function emitPropertyDeclarations(node, properties) { + for (var _a = 0; _a < properties.length; _a++) { + var property = properties[_a]; + emitPropertyDeclaration(node, property); + } + } + function emitPropertyDeclaration(node, property, receiver, isExpression) { + writeLine(); + emitLeadingComments(property); + emitStart(property); + emitStart(property.name); + if (receiver) { + emit(receiver); + } + else { + if (property.flags & 128) { + emitDeclarationName(node); + } + else { + write("this"); + } + } + emitMemberAccessForPropertyName(property.name); + emitEnd(property.name); + write(" = "); + emit(property.initializer); + if (!isExpression) { + write(";"); + } + emitEnd(property); + emitTrailingComments(property); + } + function emitMemberFunctionsForES5AndLower(node) { + ts.forEach(node.members, function (member) { + if (member.kind === 191) { + writeLine(); + write(";"); + } + else if (member.kind === 143 || node.kind === 142) { + if (!member.body) { + return emitCommentsOnNotEmittedNode(member); + } + writeLine(); + emitLeadingComments(member); + emitStart(member); + emitStart(member.name); + emitClassMemberPrefix(node, member); + emitMemberAccessForPropertyName(member.name); + emitEnd(member.name); + write(" = "); + emitFunctionDeclaration(member); + emitEnd(member); + write(";"); + emitTrailingComments(member); + } + else if (member.kind === 145 || member.kind === 146) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member === accessors.firstAccessor) { + writeLine(); + emitStart(member); + write("Object.defineProperty("); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + write(", {"); + increaseIndent(); + if (accessors.getAccessor) { + writeLine(); + emitLeadingComments(accessors.getAccessor); + write("get: "); + emitStart(accessors.getAccessor); + write("function "); + emitSignatureAndBody(accessors.getAccessor); + emitEnd(accessors.getAccessor); + emitTrailingComments(accessors.getAccessor); + write(","); + } + if (accessors.setAccessor) { + writeLine(); + emitLeadingComments(accessors.setAccessor); + write("set: "); + emitStart(accessors.setAccessor); + write("function "); + emitSignatureAndBody(accessors.setAccessor); + emitEnd(accessors.setAccessor); + emitTrailingComments(accessors.setAccessor); + write(","); + } + writeLine(); + write("enumerable: true,"); + writeLine(); + write("configurable: true"); + decreaseIndent(); + writeLine(); + write("});"); + emitEnd(member); + } + } + }); + } + function emitMemberFunctionsForES6AndHigher(node) { + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if ((member.kind === 143 || node.kind === 142) && !member.body) { + emitCommentsOnNotEmittedNode(member); + } + else if (member.kind === 143 || + member.kind === 145 || + member.kind === 146) { + writeLine(); + emitLeadingComments(member); + emitStart(member); + if (member.flags & 128) { + write("static "); + } + if (member.kind === 145) { + write("get "); + } + else if (member.kind === 146) { + write("set "); + } + if (member.asteriskToken) { + write("*"); + } + emit(member.name); + emitSignatureAndBody(member); + emitEnd(member); + emitTrailingComments(member); + } + else if (member.kind === 191) { + writeLine(); + write(";"); + } + } + } + function emitConstructor(node, baseTypeElement) { + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + emitConstructorWorker(node, baseTypeElement); + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } + function emitConstructorWorker(node, baseTypeElement) { + var hasInstancePropertyWithInitializer = false; + ts.forEach(node.members, function (member) { + if (member.kind === 144 && !member.body) { + emitCommentsOnNotEmittedNode(member); + } + if (member.kind === 141 && member.initializer && (member.flags & 128) === 0) { + hasInstancePropertyWithInitializer = true; + } + }); + var ctor = ts.getFirstConstructorWithBody(node); + if (languageVersion >= 2 && !ctor && !hasInstancePropertyWithInitializer) { + return; + } + if (ctor) { + emitLeadingComments(ctor); + } + emitStart(ctor || node); + if (languageVersion < 2) { + write("function "); + emitDeclarationName(node); + emitSignatureParameters(ctor); + } + else { + write("constructor"); + if (ctor) { + emitSignatureParameters(ctor); + } + else { + if (baseTypeElement) { + write("(...args)"); + } + else { + write("()"); + } + } + } + var startIndex = 0; + write(" {"); + scopeEmitStart(node, "constructor"); + increaseIndent(); + if (ctor) { + startIndex = emitDirectivePrologues(ctor.body.statements, true); + emitDetachedComments(ctor.body.statements); + } + emitCaptureThisForNodeIfNecessary(node); + var superCall; + if (ctor) { + emitDefaultValueAssignments(ctor); + emitRestParameter(ctor); + if (baseTypeElement) { + superCall = findInitialSuperCall(ctor); + if (superCall) { + writeLine(); + emit(superCall); + } + } + emitParameterPropertyAssignments(ctor); + } + else { + if (baseTypeElement) { + writeLine(); + emitStart(baseTypeElement); + if (languageVersion < 2) { + write("_super.apply(this, arguments);"); + } + else { + write("super(...args);"); + } + emitEnd(baseTypeElement); + } + } + emitPropertyDeclarations(node, getInitializedProperties(node, false)); + if (ctor) { + var statements = ctor.body.statements; + if (superCall) { + statements = statements.slice(1); + } + emitLinesStartingAt(statements, startIndex); + } + emitTempDeclarations(true); + writeLine(); + if (ctor) { + emitLeadingCommentsOfPosition(ctor.body.statements.end); + } + decreaseIndent(); + emitToken(16, ctor ? ctor.body.statements.end : node.members.end); + scopeEmitEnd(); + emitEnd(ctor || node); + if (ctor) { + emitTrailingComments(ctor); + } + } + function emitClassExpression(node) { + return emitClassLikeDeclaration(node); + } + function emitClassDeclaration(node) { + return emitClassLikeDeclaration(node); + } + function emitClassLikeDeclaration(node) { + if (languageVersion < 2) { + emitClassLikeDeclarationBelowES6(node); + } + else { + emitClassLikeDeclarationForES6AndHigher(node); + } + if (modulekind !== 5 && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } + } + function emitClassLikeDeclarationForES6AndHigher(node) { + var thisNodeIsDecorated = ts.nodeIsDecorated(node); + if (node.kind === 214) { + if (thisNodeIsDecorated) { + if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { + write("export "); + } + write("let "); + emitDeclarationName(node); + write(" = "); + } + else if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 1024) { + write("default "); + } + } + } + var staticProperties = getInitializedProperties(node, true); + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 186; + var tempVariable; + if (isClassExpressionWithStaticProperties) { + tempVariable = createAndRecordTempVariable(0); + write("("); + increaseIndent(); + emit(tempVariable); + write(" = "); + } + write("class"); + if ((node.name || (node.flags & 1024 && staticProperties.length > 0)) && !thisNodeIsDecorated) { + write(" "); + emitDeclarationName(node); + } + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + write(" extends "); + emit(baseTypeNode.expression); + } + write(" {"); + increaseIndent(); + scopeEmitStart(node); + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES6AndHigher(node); + decreaseIndent(); + writeLine(); + emitToken(16, node.members.end); + scopeEmitEnd(); + if (thisNodeIsDecorated) { + write(";"); + } + if (isClassExpressionWithStaticProperties) { + for (var _a = 0; _a < staticProperties.length; _a++) { + var property = staticProperties[_a]; + write(","); + writeLine(); + emitPropertyDeclaration(node, property, tempVariable, true); + } + write(","); + writeLine(); + emit(tempVariable); + decreaseIndent(); + write(")"); + } + else { + writeLine(); + emitPropertyDeclarations(node, staticProperties); + emitDecoratorsOfClass(node); + } + if (!isES6ExportedDeclaration(node) && (node.flags & 1)) { + writeLine(); + emitStart(node); + emitModuleMemberName(node); + write(" = "); + emitDeclarationName(node); + emitEnd(node); + write(";"); + } + else if (isES6ExportedDeclaration(node) && (node.flags & 1024) && thisNodeIsDecorated) { + writeLine(); + write("export default "); + emitDeclarationName(node); + write(";"); + } + } + function emitClassLikeDeclarationBelowES6(node) { + if (node.kind === 214) { + if (!shouldHoistDeclarationInSystemJsModule(node)) { + write("var "); + } + emitDeclarationName(node); + write(" = "); + } + write("(function ("); + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + write("_super"); + } + write(") {"); + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + var saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + computedPropertyNamesToGeneratedNames = undefined; + increaseIndent(); + scopeEmitStart(node); + if (baseTypeNode) { + writeLine(); + emitStart(baseTypeNode); + write("__extends("); + emitDeclarationName(node); + write(", _super);"); + emitEnd(baseTypeNode); + } + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES5AndLower(node); + emitPropertyDeclarations(node, getInitializedProperties(node, true)); + writeLine(); + emitDecoratorsOfClass(node); + writeLine(); + emitToken(16, node.members.end, function () { + write("return "); + emitDeclarationName(node); + }); + write(";"); + emitTempDeclarations(true); + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; + decreaseIndent(); + writeLine(); + emitToken(16, node.members.end); + scopeEmitEnd(); + emitStart(node); + write(")("); + if (baseTypeNode) { + emit(baseTypeNode.expression); + } + write(")"); + if (node.kind === 214) { + write(";"); + } + emitEnd(node); + if (node.kind === 214) { + emitExportMemberAssignment(node); + } + } + function emitClassMemberPrefix(node, member) { + emitDeclarationName(node); + if (!(member.flags & 128)) { + write(".prototype"); + } + } + function emitDecoratorsOfClass(node) { + emitDecoratorsOfMembers(node, 0); + emitDecoratorsOfMembers(node, 128); + emitDecoratorsOfConstructor(node); + } + function emitDecoratorsOfConstructor(node) { + var decorators = node.decorators; + var constructor = ts.getFirstConstructorWithBody(node); + var hasDecoratedParameters = constructor && ts.forEach(constructor.parameters, ts.nodeIsDecorated); + if (!decorators && !hasDecoratedParameters) { + return; + } + writeLine(); + emitStart(node); + emitDeclarationName(node); + write(" = __decorate(["); + increaseIndent(); + writeLine(); + var decoratorCount = decorators ? decorators.length : 0; + var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + }); + argumentsWritten += emitDecoratorsOfParameters(constructor, argumentsWritten > 0); + emitSerializedTypeMetadata(node, argumentsWritten >= 0); + decreaseIndent(); + writeLine(); + write("], "); + emitDeclarationName(node); + write(");"); + emitEnd(node); + writeLine(); + } + function emitDecoratorsOfMembers(node, staticFlag) { + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if ((member.flags & 128) !== staticFlag) { + continue; + } + if (!ts.nodeCanBeDecorated(member)) { + continue; + } + if (!ts.nodeOrChildIsDecorated(member)) { + continue; + } + var decorators = void 0; + var functionLikeMember = void 0; + if (ts.isAccessor(member)) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member !== accessors.firstAccessor) { + continue; + } + decorators = accessors.firstAccessor.decorators; + if (!decorators && accessors.secondAccessor) { + decorators = accessors.secondAccessor.decorators; + } + functionLikeMember = accessors.setAccessor; + } + else { + decorators = member.decorators; + if (member.kind === 143) { + functionLikeMember = member; + } + } + writeLine(); + emitStart(member); + write("__decorate(["); + increaseIndent(); + writeLine(); + var decoratorCount = decorators ? decorators.length : 0; + var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + }); + argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); + emitSerializedTypeMetadata(member, argumentsWritten > 0); + decreaseIndent(); + writeLine(); + write("], "); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + if (languageVersion > 0) { + if (member.kind !== 141) { + write(", null"); + } + else { + write(", void 0"); + } + } + write(");"); + emitEnd(member); + writeLine(); + } + } + function emitDecoratorsOfParameters(node, leadingComma) { + var argumentsWritten = 0; + if (node) { + var parameterIndex = 0; + for (var _a = 0, _b = node.parameters; _a < _b.length; _a++) { + var parameter = _b[_a]; + if (ts.nodeIsDecorated(parameter)) { + var decorators = parameter.decorators; + argumentsWritten += emitList(decorators, 0, decorators.length, true, false, leadingComma, true, function (decorator) { + emitStart(decorator); + write("__param(" + parameterIndex + ", "); + emit(decorator.expression); + write(")"); + emitEnd(decorator); + }); + leadingComma = true; + } + ++parameterIndex; + } + } + return argumentsWritten; + } + function shouldEmitTypeMetadata(node) { + switch (node.kind) { + case 143: + case 145: + case 146: + case 141: + return true; + } + return false; + } + function shouldEmitReturnTypeMetadata(node) { + switch (node.kind) { + case 143: + return true; + } + return false; + } + function shouldEmitParamTypesMetadata(node) { + switch (node.kind) { + case 214: + case 143: + case 146: + return true; + } + return false; + } + function emitSerializedTypeOfNode(node) { + switch (node.kind) { + case 214: + write("Function"); + return; + case 141: + emitSerializedTypeNode(node.type); + return; + case 138: + emitSerializedTypeNode(node.type); + return; + case 145: + emitSerializedTypeNode(node.type); + return; + case 146: + emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); + return; + } + if (ts.isFunctionLike(node)) { + write("Function"); + return; + } + write("void 0"); + } + function emitSerializedTypeNode(node) { + if (node) { + switch (node.kind) { + case 103: + write("void 0"); + return; + case 160: + emitSerializedTypeNode(node.type); + return; + case 152: + case 153: + write("Function"); + return; + case 156: + case 157: + write("Array"); + return; + case 150: + case 120: + write("Boolean"); + return; + case 130: + case 9: + write("String"); + return; + case 128: + write("Number"); + return; + case 131: + write("Symbol"); + return; + case 151: + emitSerializedTypeReferenceNode(node); + return; + case 154: + case 155: + case 158: + case 159: + case 117: + break; + default: + ts.Debug.fail("Cannot serialize unexpected type node."); + break; + } + } + write("Object"); + } + function emitSerializedTypeReferenceNode(node) { + var location = node.parent; + while (ts.isDeclaration(location) || ts.isTypeNode(location)) { + location = location.parent; + } + var typeName = ts.cloneEntityName(node.typeName); + typeName.parent = location; + var result = resolver.getTypeReferenceSerializationKind(typeName); + switch (result) { + case ts.TypeReferenceSerializationKind.Unknown: + var temp = createAndRecordTempVariable(0); + write("(typeof ("); + emitNodeWithoutSourceMap(temp); + write(" = "); + emitEntityNameAsExpression(typeName, true); + write(") === 'function' && "); + emitNodeWithoutSourceMap(temp); + write(") || Object"); + break; + case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: + emitEntityNameAsExpression(typeName, false); + break; + case ts.TypeReferenceSerializationKind.VoidType: + write("void 0"); + break; + case ts.TypeReferenceSerializationKind.BooleanType: + write("Boolean"); + break; + case ts.TypeReferenceSerializationKind.NumberLikeType: + write("Number"); + break; + case ts.TypeReferenceSerializationKind.StringLikeType: + write("String"); + break; + case ts.TypeReferenceSerializationKind.ArrayLikeType: + write("Array"); + break; + case ts.TypeReferenceSerializationKind.ESSymbolType: + if (languageVersion < 2) { + write("typeof Symbol === 'function' ? Symbol : Object"); + } + else { + write("Symbol"); + } + break; + case ts.TypeReferenceSerializationKind.TypeWithCallSignature: + write("Function"); + break; + case ts.TypeReferenceSerializationKind.ObjectType: + write("Object"); + break; + } + } + function emitSerializedParameterTypesOfNode(node) { + if (node) { + var valueDeclaration; + if (node.kind === 214) { + valueDeclaration = ts.getFirstConstructorWithBody(node); + } + else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { + valueDeclaration = node; + } + if (valueDeclaration) { + var parameters = valueDeclaration.parameters; + var parameterCount = parameters.length; + if (parameterCount > 0) { + for (var i = 0; i < parameterCount; i++) { + if (i > 0) { + write(", "); + } + if (parameters[i].dotDotDotToken) { + var parameterType = parameters[i].type; + if (parameterType.kind === 156) { + parameterType = parameterType.elementType; + } + else if (parameterType.kind === 151 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + parameterType = parameterType.typeArguments[0]; + } + else { + parameterType = undefined; + } + emitSerializedTypeNode(parameterType); + } + else { + emitSerializedTypeOfNode(parameters[i]); + } + } + } + } + } + } + function emitSerializedReturnTypeOfNode(node) { + if (node && ts.isFunctionLike(node) && node.type) { + emitSerializedTypeNode(node.type); + return; + } + write("void 0"); + } + function emitSerializedTypeMetadata(node, writeComma) { + var argumentsWritten = 0; + if (compilerOptions.emitDecoratorMetadata) { + if (shouldEmitTypeMetadata(node)) { + if (writeComma) { + write(", "); + } + writeLine(); + write("__metadata('design:type', "); + emitSerializedTypeOfNode(node); + write(")"); + argumentsWritten++; + } + if (shouldEmitParamTypesMetadata(node)) { + if (writeComma || argumentsWritten) { + write(", "); + } + writeLine(); + write("__metadata('design:paramtypes', ["); + emitSerializedParameterTypesOfNode(node); + write("])"); + argumentsWritten++; + } + if (shouldEmitReturnTypeMetadata(node)) { + if (writeComma || argumentsWritten) { + write(", "); + } + writeLine(); + write("__metadata('design:returntype', "); + emitSerializedReturnTypeOfNode(node); + write(")"); + argumentsWritten++; + } + } + return argumentsWritten; + } + function emitInterfaceDeclaration(node) { + emitCommentsOnNotEmittedNode(node); + } + function shouldEmitEnumDeclaration(node) { + var isConstEnum = ts.isConst(node); + return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; + } + function emitEnumDeclaration(node) { + if (!shouldEmitEnumDeclaration(node)) { + return; + } + if (!shouldHoistDeclarationInSystemJsModule(node)) { + if (!(node.flags & 1) || isES6ExportedDeclaration(node)) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + emitEnd(node); + write(";"); + } + } + writeLine(); + emitStart(node); + write("(function ("); + emitStart(node.name); + write(getGeneratedNameForNode(node)); + emitEnd(node.name); + write(") {"); + increaseIndent(); + scopeEmitStart(node); + emitLines(node.members); + decreaseIndent(); + writeLine(); + emitToken(16, node.members.end); + scopeEmitEnd(); + write(")("); + emitModuleMemberName(node); + write(" || ("); + emitModuleMemberName(node); + write(" = {}));"); + emitEnd(node); + if (!isES6ExportedDeclaration(node) && node.flags & 1 && !shouldHoistDeclarationInSystemJsModule(node)) { + writeLine(); + emitStart(node); + write("var "); + emit(node.name); + write(" = "); + emitModuleMemberName(node); + emitEnd(node); + write(";"); + } + if (modulekind !== 5 && node.parent === currentSourceFile) { + if (modulekind === 4 && (node.flags & 1)) { + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(");"); + } + emitExportMemberAssignments(node.name); + } + } + function emitEnumMember(node) { + var enumParent = node.parent; + emitStart(node); + write(getGeneratedNameForNode(enumParent)); + write("["); + write(getGeneratedNameForNode(enumParent)); + write("["); + emitExpressionForPropertyName(node.name); + write("] = "); + writeEnumMemberDeclarationValue(node); + write("] = "); + emitExpressionForPropertyName(node.name); + emitEnd(node); + write(";"); + } + function writeEnumMemberDeclarationValue(member) { + var value = resolver.getConstantValue(member); + if (value !== undefined) { + write(value.toString()); + return; + } + else if (member.initializer) { + emit(member.initializer); + } + else { + write("undefined"); + } + } + function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { + if (moduleDeclaration.body.kind === 218) { + var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); + return recursiveInnerModule || moduleDeclaration.body; + } + } + function shouldEmitModuleDeclaration(node) { + return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); + } + function isModuleMergedWithES6Class(node) { + return languageVersion === 2 && !!(resolver.getNodeCheckFlags(node) & 32768); + } + function emitModuleDeclaration(node) { + var shouldEmit = shouldEmitModuleDeclaration(node); + if (!shouldEmit) { + return emitCommentsOnNotEmittedNode(node); + } + var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); + var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); + if (emitVarForModule) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + write(";"); + emitEnd(node); + writeLine(); + } + emitStart(node); + write("(function ("); + emitStart(node.name); + write(getGeneratedNameForNode(node)); + emitEnd(node.name); + write(") "); + if (node.body.kind === 219) { + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + tempFlags = 0; + tempVariables = undefined; + emit(node.body); + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + } + else { + write("{"); + increaseIndent(); + scopeEmitStart(node); + emitCaptureThisForNodeIfNecessary(node); + writeLine(); + emit(node.body); + decreaseIndent(); + writeLine(); + var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; + emitToken(16, moduleBlock.statements.end); + scopeEmitEnd(); + } + write(")("); + if ((node.flags & 1) && !isES6ExportedDeclaration(node)) { + emit(node.name); + write(" = "); + } + emitModuleMemberName(node); + write(" || ("); + emitModuleMemberName(node); + write(" = {}));"); + emitEnd(node); + if (!isES6ExportedDeclaration(node) && node.name.kind === 69 && node.parent === currentSourceFile) { + if (modulekind === 4 && (node.flags & 1)) { + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(");"); + } + emitExportMemberAssignments(node.name); + } + } + function tryRenameExternalModule(moduleName) { + if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { + return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; + } + return undefined; + } + function emitRequire(moduleName) { + if (moduleName.kind === 9) { + write("require("); + var text = tryRenameExternalModule(moduleName); + if (text) { + write(text); + } + else { + emitStart(moduleName); + emitLiteral(moduleName); + emitEnd(moduleName); + } + emitToken(18, moduleName.end); + } + else { + write("require()"); + } + } + function getNamespaceDeclarationNode(node) { + if (node.kind === 221) { + return node; + } + var importClause = node.importClause; + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 224) { + return importClause.namedBindings; + } + } + function isDefaultImport(node) { + return node.kind === 222 && node.importClause && !!node.importClause.name; + } + function emitExportImportAssignments(node) { + if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + emitExportMemberAssignments(node.name); + } + ts.forEachChild(node, emitExportImportAssignments); + } + function emitImportDeclaration(node) { + if (modulekind !== 5) { + return emitExternalImportDeclaration(node); + } + if (node.importClause) { + var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); + var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, true); + if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { + write("import "); + emitStart(node.importClause); + if (shouldEmitDefaultBindings) { + emit(node.importClause.name); + if (shouldEmitNamedBindings) { + write(", "); + } + } + if (shouldEmitNamedBindings) { + emitLeadingComments(node.importClause.namedBindings); + emitStart(node.importClause.namedBindings); + if (node.importClause.namedBindings.kind === 224) { + write("* as "); + emit(node.importClause.namedBindings.name); + } + else { + write("{ "); + emitExportOrImportSpecifierList(node.importClause.namedBindings.elements, resolver.isReferencedAliasDeclaration); + write(" }"); + } + emitEnd(node.importClause.namedBindings); + emitTrailingComments(node.importClause.namedBindings); + } + emitEnd(node.importClause); + write(" from "); + emit(node.moduleSpecifier); + write(";"); + } + } + else { + write("import "); + emit(node.moduleSpecifier); + write(";"); + } + } + function emitExternalImportDeclaration(node) { + if (ts.contains(externalImports, node)) { + var isExportedImport = node.kind === 221 && (node.flags & 1) !== 0; + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (modulekind !== 2) { + emitLeadingComments(node); + emitStart(node); + if (namespaceDeclaration && !isDefaultImport(node)) { + if (!isExportedImport) + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + } + else { + var isNakedImport = 222 && !node.importClause; + if (!isNakedImport) { + write("var "); + write(getGeneratedNameForNode(node)); + write(" = "); + } + } + emitRequire(ts.getExternalModuleName(node)); + if (namespaceDeclaration && isDefaultImport(node)) { + write(", "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + } + write(";"); + emitEnd(node); + emitExportImportAssignments(node); + emitTrailingComments(node); + } + else { + if (isExportedImport) { + emitModuleMemberName(namespaceDeclaration); + write(" = "); + emit(namespaceDeclaration.name); + write(";"); + } + else if (namespaceDeclaration && isDefaultImport(node)) { + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + write(";"); + } + emitExportImportAssignments(node); + } + } + } + function emitImportEqualsDeclaration(node) { + if (ts.isExternalModuleImportEqualsDeclaration(node)) { + emitExternalImportDeclaration(node); + return; + } + if (resolver.isReferencedAliasDeclaration(node) || + (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { + emitLeadingComments(node); + emitStart(node); + var variableDeclarationIsHoisted = shouldHoistVariable(node, true); + var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, true); + if (!variableDeclarationIsHoisted) { + ts.Debug.assert(!isExported); + if (isES6ExportedDeclaration(node)) { + write("export "); + write("var "); + } + else if (!(node.flags & 1)) { + write("var "); + } + } + if (isExported) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); + } + emitModuleMemberName(node); + write(" = "); + emit(node.moduleReference); + if (isExported) { + write(")"); + } + write(";"); + emitEnd(node); + emitExportImportAssignments(node); + emitTrailingComments(node); + } + } + function emitExportDeclaration(node) { + ts.Debug.assert(modulekind !== 4); + if (modulekind !== 5) { + if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { + emitStart(node); + var generatedName = getGeneratedNameForNode(node); + if (node.exportClause) { + if (modulekind !== 2) { + write("var "); + write(generatedName); + write(" = "); + emitRequire(ts.getExternalModuleName(node)); + write(";"); + } + for (var _a = 0, _b = node.exportClause.elements; _a < _b.length; _a++) { + var specifier = _b[_a]; + if (resolver.isValueAliasDeclaration(specifier)) { + writeLine(); + emitStart(specifier); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write(" = "); + write(generatedName); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); + write(";"); + emitEnd(specifier); + } + } + } + else { + writeLine(); + write("__export("); + if (modulekind !== 2) { + emitRequire(ts.getExternalModuleName(node)); + } + else { + write(generatedName); + } + write(");"); + } + emitEnd(node); + } + } + else { + if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { + write("export "); + if (node.exportClause) { + write("{ "); + emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); + write(" }"); + } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + emit(node.moduleSpecifier); + } + write(";"); + } + } + } + function emitExportOrImportSpecifierList(specifiers, shouldEmit) { + ts.Debug.assert(modulekind === 5); + var needsComma = false; + for (var _a = 0; _a < specifiers.length; _a++) { + var specifier = specifiers[_a]; + if (shouldEmit(specifier)) { + if (needsComma) { + write(", "); + } + if (specifier.propertyName) { + emit(specifier.propertyName); + write(" as "); + } + emit(specifier.name); + needsComma = true; + } + } + } + function emitExportAssignment(node) { + if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { + if (modulekind === 5) { + writeLine(); + emitStart(node); + write("export default "); + var expression = node.expression; + emit(expression); + if (expression.kind !== 213 && + expression.kind !== 214) { + write(";"); + } + emitEnd(node); + } + else { + writeLine(); + emitStart(node); + if (modulekind === 4) { + write(exportFunctionForFile + "(\"default\","); + emit(node.expression); + write(")"); + } + else { + emitEs6ExportDefaultCompat(node); + emitContainingModuleName(node); + if (languageVersion === 0) { + write("[\"default\"] = "); + } + else { + write(".default = "); + } + emit(node.expression); + } + write(";"); + emitEnd(node); + } + } + } + function collectExternalModuleInfo(sourceFile) { + externalImports = []; + exportSpecifiers = {}; + exportEquals = undefined; + hasExportStars = false; + for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { + var node = _b[_a]; + switch (node.kind) { + case 222: + if (!node.importClause || + resolver.isReferencedAliasDeclaration(node.importClause, true)) { + externalImports.push(node); + } + break; + case 221: + if (node.moduleReference.kind === 232 && resolver.isReferencedAliasDeclaration(node)) { + externalImports.push(node); + } + break; + case 228: + if (node.moduleSpecifier) { + if (!node.exportClause) { + externalImports.push(node); + hasExportStars = true; + } + else if (resolver.isValueAliasDeclaration(node)) { + externalImports.push(node); + } + } + else { + for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { + var specifier = _d[_c]; + var name_25 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_25] || (exportSpecifiers[name_25] = [])).push(specifier); + } + } + break; + case 227: + if (node.isExportEquals && !exportEquals) { + exportEquals = node; + } + break; + } + } + } + function emitExportStarHelper() { + if (hasExportStars) { + writeLine(); + write("function __export(m) {"); + increaseIndent(); + writeLine(); + write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function getLocalNameForExternalImport(node) { + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (namespaceDeclaration && !isDefaultImport(node)) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); + } + if (node.kind === 222 && node.importClause) { + return getGeneratedNameForNode(node); + } + if (node.kind === 228 && node.moduleSpecifier) { + return getGeneratedNameForNode(node); + } + } + function getExternalModuleNameText(importNode) { + var moduleName = ts.getExternalModuleName(importNode); + if (moduleName.kind === 9) { + return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); + } + return undefined; + } + function emitVariableDeclarationsForImports() { + if (externalImports.length === 0) { + return; + } + writeLine(); + var started = false; + for (var _a = 0; _a < externalImports.length; _a++) { + var importNode = externalImports[_a]; + var skipNode = importNode.kind === 228 || + (importNode.kind === 222 && !importNode.importClause); + if (skipNode) { + continue; + } + if (!started) { + write("var "); + started = true; + } + else { + write(", "); + } + write(getLocalNameForExternalImport(importNode)); + } + if (started) { + write(";"); + } + } + function emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) { + if (!hasExportStars) { + return undefined; + } + if (!exportedDeclarations && ts.isEmpty(exportSpecifiers)) { + var hasExportDeclarationWithExportClause = false; + for (var _a = 0; _a < externalImports.length; _a++) { + var externalImport = externalImports[_a]; + if (externalImport.kind === 228 && externalImport.exportClause) { + hasExportDeclarationWithExportClause = true; + break; + } + } + if (!hasExportDeclarationWithExportClause) { + return emitExportStarFunction(undefined); + } + } + var exportedNamesStorageRef = makeUniqueName("exportedNames"); + writeLine(); + write("var " + exportedNamesStorageRef + " = {"); + increaseIndent(); + var started = false; + if (exportedDeclarations) { + for (var i = 0; i < exportedDeclarations.length; ++i) { + writeExportedName(exportedDeclarations[i]); + } + } + if (exportSpecifiers) { + for (var n in exportSpecifiers) { + for (var _b = 0, _c = exportSpecifiers[n]; _b < _c.length; _b++) { + var specifier = _c[_b]; + writeExportedName(specifier.name); + } + } + } + for (var _d = 0; _d < externalImports.length; _d++) { + var externalImport = externalImports[_d]; + if (externalImport.kind !== 228) { + continue; + } + var exportDecl = externalImport; + if (!exportDecl.exportClause) { + continue; + } + for (var _e = 0, _f = exportDecl.exportClause.elements; _e < _f.length; _e++) { + var element = _f[_e]; + writeExportedName(element.name || element.propertyName); + } + } + decreaseIndent(); + writeLine(); + write("};"); + return emitExportStarFunction(exportedNamesStorageRef); + function emitExportStarFunction(localNames) { + var exportStarFunction = makeUniqueName("exportStar"); + writeLine(); + write("function " + exportStarFunction + "(m) {"); + increaseIndent(); + writeLine(); + write("var exports = {};"); + writeLine(); + write("for(var n in m) {"); + increaseIndent(); + writeLine(); + write("if (n !== \"default\""); + if (localNames) { + write("&& !" + localNames + ".hasOwnProperty(n)"); + } + write(") exports[n] = m[n];"); + decreaseIndent(); + writeLine(); + write("}"); + writeLine(); + write(exportFunctionForFile + "(exports);"); + decreaseIndent(); + writeLine(); + write("}"); + return exportStarFunction; + } + function writeExportedName(node) { + if (node.kind !== 69 && node.flags & 1024) { + return; + } + if (started) { + write(","); + } + else { + started = true; + } + writeLine(); + write("'"); + if (node.kind === 69) { + emitNodeWithCommentsAndWithoutSourcemap(node); + } + else { + emitDeclarationName(node); + } + write("': true"); + } + } + function processTopLevelVariableAndFunctionDeclarations(node) { + var hoistedVars; + var hoistedFunctionDeclarations; + var exportedDeclarations; + visit(node); + if (hoistedVars) { + writeLine(); + write("var "); + var seen = {}; + for (var i = 0; i < hoistedVars.length; ++i) { + var local = hoistedVars[i]; + var name_26 = local.kind === 69 + ? local + : local.name; + if (name_26) { + var text = ts.unescapeIdentifier(name_26.text); + if (ts.hasProperty(seen, text)) { + continue; + } + else { + seen[text] = text; + } + } + if (i !== 0) { + write(", "); + } + if (local.kind === 214 || local.kind === 218 || local.kind === 217) { + emitDeclarationName(local); + } + else { + emit(local); + } + var flags = ts.getCombinedNodeFlags(local.kind === 69 ? local.parent : local); + if (flags & 1) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(local); + } + } + write(";"); + } + if (hoistedFunctionDeclarations) { + for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { + var f = hoistedFunctionDeclarations[_a]; + writeLine(); + emit(f); + if (f.flags & 1) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(f); + } + } + } + return exportedDeclarations; + function visit(node) { + if (node.flags & 2) { + return; + } + if (node.kind === 213) { + if (!hoistedFunctionDeclarations) { + hoistedFunctionDeclarations = []; + } + hoistedFunctionDeclarations.push(node); + return; + } + if (node.kind === 214) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + return; + } + if (node.kind === 217) { + if (shouldEmitEnumDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + } + return; + } + if (node.kind === 218) { + if (shouldEmitModuleDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + } + return; + } + if (node.kind === 211 || node.kind === 163) { + if (shouldHoistVariable(node, false)) { + var name_27 = node.name; + if (name_27.kind === 69) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(name_27); + } + else { + ts.forEachChild(name_27, visit); + } + } + return; + } + if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node.name); + return; + } + if (ts.isBindingPattern(node)) { + ts.forEach(node.elements, visit); + return; + } + if (!ts.isDeclaration(node)) { + ts.forEachChild(node, visit); + } + } + } + function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { + if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { + return false; + } + return (ts.getCombinedNodeFlags(node) & 49152) === 0 || + ts.getEnclosingBlockScopeContainer(node).kind === 248; + } + function isCurrentFileSystemExternalModule() { + return modulekind === 4 && ts.isExternalModule(currentSourceFile); + } + function emitSystemModuleBody(node, dependencyGroups, startIndex) { + emitVariableDeclarationsForImports(); + writeLine(); + var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); + var exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); + writeLine(); + write("return {"); + increaseIndent(); + writeLine(); + emitSetters(exportStarFunction, dependencyGroups); + writeLine(); + emitExecute(node, startIndex); + decreaseIndent(); + writeLine(); + write("}"); + emitTempDeclarations(true); + } + function emitSetters(exportStarFunction, dependencyGroups) { + write("setters:["); + for (var i = 0; i < dependencyGroups.length; ++i) { + if (i !== 0) { + write(","); + } + writeLine(); + increaseIndent(); + var group = dependencyGroups[i]; + var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); + write("function (" + parameterName + ") {"); + increaseIndent(); + for (var _a = 0; _a < group.length; _a++) { + var entry = group[_a]; + var importVariableName = getLocalNameForExternalImport(entry) || ""; + switch (entry.kind) { + case 222: + if (!entry.importClause) { + break; + } + case 221: + ts.Debug.assert(importVariableName !== ""); + writeLine(); + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + break; + case 228: + ts.Debug.assert(importVariableName !== ""); + if (entry.exportClause) { + writeLine(); + write(exportFunctionForFile + "({"); + writeLine(); + increaseIndent(); + for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { + if (i_2 !== 0) { + write(","); + writeLine(); + } + var e = entry.exportClause.elements[i_2]; + write("\""); + emitNodeWithCommentsAndWithoutSourcemap(e.name); + write("\": " + parameterName + "[\""); + emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); + write("\"]"); + } + decreaseIndent(); + writeLine(); + write("});"); + } + else { + writeLine(); + write(exportStarFunction + "(" + parameterName + ");"); + } + writeLine(); + break; + } + } + decreaseIndent(); + write("}"); + decreaseIndent(); + } + write("],"); + } + function emitExecute(node, startIndex) { + write("execute: function() {"); + increaseIndent(); + writeLine(); + for (var i = startIndex; i < node.statements.length; ++i) { + var statement = node.statements[i]; + switch (statement.kind) { + case 213: + case 222: + continue; + case 228: + if (!statement.moduleSpecifier) { + for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { + var element = _b[_a]; + emitExportSpecifierInSystemModule(element); + } + } + continue; + case 221: + if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { + continue; + } + default: + writeLine(); + emit(statement); + } + } + decreaseIndent(); + writeLine(); + write("}"); + } + function emitSystemModule(node) { + collectExternalModuleInfo(node); + ts.Debug.assert(!exportFunctionForFile); + exportFunctionForFile = makeUniqueName("exports"); + writeLine(); + write("System.register("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + write("["); + var groupIndices = {}; + var dependencyGroups = []; + for (var i = 0; i < externalImports.length; ++i) { + var text = getExternalModuleNameText(externalImports[i]); + if (ts.hasProperty(groupIndices, text)) { + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].push(externalImports[i]); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push([externalImports[i]]); + } + if (i !== 0) { + write(", "); + } + write(text); + } + write("], function(" + exportFunctionForFile + ") {"); + writeLine(); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, true); + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitSystemModuleBody(node, dependencyGroups, startIndex); + decreaseIndent(); + writeLine(); + write("});"); + } + function getAMDDependencyNames(node, includeNonAmdDependencies) { + var aliasedModuleNames = []; + var unaliasedModuleNames = []; + var importAliasNames = []; + for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { + var amdDependency = _b[_a]; + if (amdDependency.name) { + aliasedModuleNames.push("\"" + amdDependency.path + "\""); + importAliasNames.push(amdDependency.name); + } + else { + unaliasedModuleNames.push("\"" + amdDependency.path + "\""); + } + } + for (var _c = 0; _c < externalImports.length; _c++) { + var importNode = externalImports[_c]; + var externalModuleName = getExternalModuleNameText(importNode); + var importAliasName = getLocalNameForExternalImport(importNode); + if (includeNonAmdDependencies && importAliasName) { + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(importAliasName); + } + else { + unaliasedModuleNames.push(externalModuleName); + } + } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + } + function emitAMDDependencies(node, includeNonAmdDependencies) { + var dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies); + emitAMDDependencyList(dependencyNames); + write(", "); + emitAMDFactoryHeader(dependencyNames); + } + function emitAMDDependencyList(_a) { + var aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames; + write("[\"require\", \"exports\""); + if (aliasedModuleNames.length) { + write(", "); + write(aliasedModuleNames.join(", ")); + } + if (unaliasedModuleNames.length) { + write(", "); + write(unaliasedModuleNames.join(", ")); + } + write("]"); + } + function emitAMDFactoryHeader(_a) { + var importAliasNames = _a.importAliasNames; + write("function (require, exports"); + if (importAliasNames.length) { + write(", "); + write(importAliasNames.join(", ")); + } + write(") {"); + } + function emitAMDModule(node) { + emitEmitHelpers(node); + collectExternalModuleInfo(node); + writeLine(); + write("define("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + emitAMDDependencies(node, true); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, true); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + emitExportEquals(true); + decreaseIndent(); + writeLine(); + write("});"); + } + function emitCommonJSModule(node) { + var startIndex = emitDirectivePrologues(node.statements, false); + emitEmitHelpers(node); + collectExternalModuleInfo(node); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + emitExportEquals(false); + } + function emitUMDModule(node) { + emitEmitHelpers(node); + collectExternalModuleInfo(node); + var dependencyNames = getAMDDependencyNames(node, false); + writeLines("(function (factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define("); + emitAMDDependencyList(dependencyNames); + write(", factory);"); + writeLines(" }\n})("); + emitAMDFactoryHeader(dependencyNames); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, true); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + emitExportEquals(true); + decreaseIndent(); + writeLine(); + write("});"); + } + function emitES6Module(node) { + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + var startIndex = emitDirectivePrologues(node.statements, false); + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + } + function emitExportEquals(emitAsReturn) { + if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { + writeLine(); + emitStart(exportEquals); + write(emitAsReturn ? "return " : "module.exports = "); + emit(exportEquals.expression); + write(";"); + emitEnd(exportEquals); + } + } + function emitJsxElement(node) { + switch (compilerOptions.jsx) { + case 2: + jsxEmitReact(node); + break; + case 1: + default: + jsxEmitPreserve(node); + break; + } + } + function trimReactWhitespaceAndApplyEntities(node) { + var result = undefined; + var text = ts.getTextOfNode(node, true); + var firstNonWhitespace = 0; + var lastNonWhitespace = -1; + for (var i = 0; i < text.length; i++) { + var c = text.charCodeAt(i); + if (ts.isLineBreak(c)) { + if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { + var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); + } + firstNonWhitespace = -1; + } + else if (!ts.isWhiteSpace(c)) { + lastNonWhitespace = i; + if (firstNonWhitespace === -1) { + firstNonWhitespace = i; + } + } + } + if (firstNonWhitespace !== -1) { + var part = text.substr(firstNonWhitespace); + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); + } + if (result) { + result = result.replace(/&(\w+);/g, function (s, m) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); + } + return result; + } + function getTextToEmit(node) { + switch (compilerOptions.jsx) { + case 2: + var text = trimReactWhitespaceAndApplyEntities(node); + if (text === undefined || text.length === 0) { + return undefined; + } + else { + return text; + } + case 1: + default: + return ts.getTextOfNode(node, true); + } + } + function emitJsxText(node) { + switch (compilerOptions.jsx) { + case 2: + write("\""); + write(trimReactWhitespaceAndApplyEntities(node)); + write("\""); + break; + case 1: + default: + writer.writeLiteral(ts.getTextOfNode(node, true)); + break; + } + } + function emitJsxExpression(node) { + if (node.expression) { + switch (compilerOptions.jsx) { + case 1: + default: + write("{"); + emit(node.expression); + write("}"); + break; + case 2: + emit(node.expression); + break; + } + } + } + function emitDirectivePrologues(statements, startWithNewLine) { + for (var i = 0; i < statements.length; ++i) { + if (ts.isPrologueDirective(statements[i])) { + if (startWithNewLine || i > 0) { + writeLine(); + } + emit(statements[i]); + } + else { + return i; + } + } + return statements.length; + } + function writeLines(text) { + var lines = text.split(/\r\n|\r|\n/g); + for (var i = 0; i < lines.length; ++i) { + var line = lines[i]; + if (line.length) { + writeLine(); + write(line); + } + } + } + function emitEmitHelpers(node) { + if (!compilerOptions.noEmitHelpers) { + if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { + writeLines(extendsHelper); + extendsEmitted = true; + } + if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16) { + writeLines(decorateHelper); + if (compilerOptions.emitDecoratorMetadata) { + writeLines(metadataHelper); + } + decorateEmitted = true; + } + if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32) { + writeLines(paramHelper); + paramEmitted = true; + } + if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64) { + writeLines(awaiterHelper); + awaiterEmitted = true; + } + } + } + function emitSourceFileNode(node) { + writeLine(); + emitShebang(); + emitDetachedComments(node); + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1]; + emitModule(node); + } + else { + var startIndex = emitDirectivePrologues(node.statements, false); + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + } + emitLeadingComments(node.endOfFileToken); + } + function emitNodeWithCommentsAndWithoutSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); + } + function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { + if (node) { + if (node.flags & 2) { + return emitCommentsOnNotEmittedNode(node); + } + if (isSpecializedCommentHandling(node)) { + return emitNodeWithoutSourceMap(node); + } + var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); + if (emitComments_1) { + emitLeadingComments(node); + } + emitNodeConsideringSourcemap(node); + if (emitComments_1) { + emitTrailingComments(node); + } + } + } + function emitNodeWithoutSourceMap(node) { + if (node) { + emitJavaScriptWorker(node); + } + } + function isSpecializedCommentHandling(node) { + switch (node.kind) { + case 215: + case 213: + case 222: + case 221: + case 216: + case 227: + return true; + } + } + function shouldEmitLeadingAndTrailingComments(node) { + switch (node.kind) { + case 193: + return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); + case 218: + return shouldEmitModuleDeclaration(node); + case 217: + return shouldEmitEnumDeclaration(node); + } + ts.Debug.assert(!isSpecializedCommentHandling(node)); + if (node.kind !== 192 && + node.parent && + node.parent.kind === 174 && + node.parent.body === node && + compilerOptions.target <= 1) { + return false; + } + return true; + } + function emitJavaScriptWorker(node) { + switch (node.kind) { + case 69: + return emitIdentifier(node); + case 138: + return emitParameter(node); + case 143: + case 142: + return emitMethod(node); + case 145: + case 146: + return emitAccessor(node); + case 97: + return emitThis(node); + case 95: + return emitSuper(node); + case 93: + return write("null"); + case 99: + return write("true"); + case 84: + return write("false"); + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + return emitLiteral(node); + case 183: + return emitTemplateExpression(node); + case 190: + return emitTemplateSpan(node); + case 233: + case 234: + return emitJsxElement(node); + case 236: + return emitJsxText(node); + case 240: + return emitJsxExpression(node); + case 135: + return emitQualifiedName(node); + case 161: + return emitObjectBindingPattern(node); + case 162: + return emitArrayBindingPattern(node); + case 163: + return emitBindingElement(node); + case 164: + return emitArrayLiteral(node); + case 165: + return emitObjectLiteral(node); + case 245: + return emitPropertyAssignment(node); + case 246: + return emitShorthandPropertyAssignment(node); + case 136: + return emitComputedPropertyName(node); + case 166: + return emitPropertyAccess(node); + case 167: + return emitIndexedAccess(node); + case 168: + return emitCallExpression(node); + case 169: + return emitNewExpression(node); + case 170: + return emitTaggedTemplateExpression(node); + case 171: + return emit(node.expression); + case 189: + return emit(node.expression); + case 172: + return emitParenExpression(node); + case 213: + case 173: + case 174: + return emitFunctionDeclaration(node); + case 175: + return emitDeleteExpression(node); + case 176: + return emitTypeOfExpression(node); + case 177: + return emitVoidExpression(node); + case 178: + return emitAwaitExpression(node); + case 179: + return emitPrefixUnaryExpression(node); + case 180: + return emitPostfixUnaryExpression(node); + case 181: + return emitBinaryExpression(node); + case 182: + return emitConditionalExpression(node); + case 185: + return emitSpreadElementExpression(node); + case 184: + return emitYieldExpression(node); + case 187: + return; + case 192: + case 219: + return emitBlock(node); + case 193: + return emitVariableStatement(node); + case 194: + return write(";"); + case 195: + return emitExpressionStatement(node); + case 196: + return emitIfStatement(node); + case 197: + return emitDoStatement(node); + case 198: + return emitWhileStatement(node); + case 199: + return emitForStatement(node); + case 201: + case 200: + return emitForInOrForOfStatement(node); + case 202: + case 203: + return emitBreakOrContinueStatement(node); + case 204: + return emitReturnStatement(node); + case 205: + return emitWithStatement(node); + case 206: + return emitSwitchStatement(node); + case 241: + case 242: + return emitCaseOrDefaultClause(node); + case 207: + return emitLabelledStatement(node); + case 208: + return emitThrowStatement(node); + case 209: + return emitTryStatement(node); + case 244: + return emitCatchClause(node); + case 210: + return emitDebuggerStatement(node); + case 211: + return emitVariableDeclaration(node); + case 186: + return emitClassExpression(node); + case 214: + return emitClassDeclaration(node); + case 215: + return emitInterfaceDeclaration(node); + case 217: + return emitEnumDeclaration(node); + case 247: + return emitEnumMember(node); + case 218: + return emitModuleDeclaration(node); + case 222: + return emitImportDeclaration(node); + case 221: + return emitImportEqualsDeclaration(node); + case 228: + return emitExportDeclaration(node); + case 227: + return emitExportAssignment(node); + case 248: + return emitSourceFileNode(node); + } + } + function hasDetachedComments(pos) { + return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; + } + function getLeadingCommentsWithoutDetachedComments() { + var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); + if (detachedCommentsInfo.length - 1) { + detachedCommentsInfo.pop(); + } + else { + detachedCommentsInfo = undefined; + } + return leadingComments; + } + function isPinnedComments(comment) { + return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; + } + function isTripleSlashComment(comment) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && + comment.pos + 2 < comment.end && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 47) { + var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); + return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || + textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? + true : false; + } + return false; + } + function getLeadingCommentsToEmit(node) { + if (node.parent) { + if (node.parent.kind === 248 || node.pos !== node.parent.pos) { + if (hasDetachedComments(node.pos)) { + return getLeadingCommentsWithoutDetachedComments(); + } + else { + return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); + } + } + } + } + function getTrailingCommentsToEmit(node) { + if (node.parent) { + if (node.parent.kind === 248 || node.end !== node.parent.end) { + return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); + } + } + } + function emitCommentsOnNotEmittedNode(node) { + emitLeadingCommentsWorker(node, false); + } + function emitLeadingComments(node) { + return emitLeadingCommentsWorker(node, true); + } + function emitLeadingCommentsWorker(node, isEmittedNode) { + if (compilerOptions.removeComments) { + return; + } + var leadingComments; + if (isEmittedNode) { + leadingComments = getLeadingCommentsToEmit(node); + } + else { + if (node.pos === 0) { + leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); + } + } + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + } + function emitTrailingComments(node) { + if (compilerOptions.removeComments) { + return; + } + var trailingComments = getTrailingCommentsToEmit(node); + ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); + } + function emitTrailingCommentsOfPosition(pos) { + if (compilerOptions.removeComments) { + return; + } + var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos); + ts.emitComments(currentSourceFile, writer, trailingComments, true, newLine, writeComment); + } + function emitLeadingCommentsOfPositionWorker(pos) { + if (compilerOptions.removeComments) { + return; + } + var leadingComments; + if (hasDetachedComments(pos)) { + leadingComments = getLeadingCommentsWithoutDetachedComments(); + } + else { + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); + } + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); + ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + } + function emitDetachedComments(node) { + var leadingComments; + if (compilerOptions.removeComments) { + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + } + } + else { + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + } + if (leadingComments) { + var detachedComments = []; + var lastComment; + ts.forEach(leadingComments, function (comment) { + if (lastComment) { + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); + if (commentLine >= lastCommentLine + 2) { + return detachedComments; + } + } + detachedComments.push(comment); + lastComment = comment; + }); + if (detachedComments.length) { + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); + var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); + var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); + } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; + } + } + } + } + } + function emitShebang() { + var shebang = ts.getShebang(currentSourceFile.text); + if (shebang) { + write(shebang); + } + } + var _a; + } + function emitFile(jsFilePath, sourceFile) { + emitJavaScript(jsFilePath, sourceFile); + if (compilerOptions.declaration) { + ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); + } + } + } + ts.emitFiles = emitFiles; })(ts || (ts = {})); -/// -/// -/// var ts; (function (ts) { ts.programTime = 0; @@ -29354,7 +29834,7 @@ var ts; ts.ioReadTime = 0; ts.ioWriteTime = 0; var emptyArray = []; - ts.version = "1.6.2"; + ts.version = "1.7.2"; function findConfigFile(searchPath) { var fileName = "tsconfig.json"; while (true) { @@ -29392,11 +29872,11 @@ var ts; if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { var failedLookupLocations = []; var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolvedFileName = loadNodeModuleFromFile(candidate, false, failedLookupLocations, host); + var resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host); if (resolvedFileName) { return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; } - resolvedFileName = loadNodeModuleFromDirectory(candidate, false, failedLookupLocations, host); + resolvedFileName = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); return resolvedFileName ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; @@ -29406,13 +29886,8 @@ var ts; } } ts.nodeModuleNameResolver = nodeModuleNameResolver; - function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) { - if (loadOnlyDts) { - return tryLoad(".d.ts"); - } - else { - return ts.forEach(ts.supportedExtensions, tryLoad); - } + function loadNodeModuleFromFile(candidate, failedLookupLocation, host) { + return ts.forEach(ts.moduleFileExtensions, tryLoad); function tryLoad(ext) { var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; if (host.fileExists(fileName)) { @@ -29424,7 +29899,7 @@ var ts; } } } - function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) { + function loadNodeModuleFromDirectory(candidate, failedLookupLocation, host) { var packageJsonPath = ts.combinePaths(candidate, "package.json"); if (host.fileExists(packageJsonPath)) { var jsonContent; @@ -29436,7 +29911,7 @@ var ts; jsonContent = { typings: undefined }; } if (jsonContent.typings) { - var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host); + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host); if (result) { return result; } @@ -29445,7 +29920,7 @@ var ts; else { failedLookupLocation.push(packageJsonPath); } - return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), failedLookupLocation, host); } function loadModuleFromNodeModules(moduleName, directory, host) { var failedLookupLocations = []; @@ -29455,11 +29930,11 @@ var ts; if (baseName !== "node_modules") { var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var result = loadNodeModuleFromFile(candidate, true, failedLookupLocations, host); + var result = loadNodeModuleFromFile(candidate, failedLookupLocations, host); if (result) { return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; } - result = loadNodeModuleFromDirectory(candidate, true, failedLookupLocations, host); + result = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); if (result) { return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; } @@ -29477,7 +29952,7 @@ var ts; return i === 0 || (i === 1 && name.charCodeAt(0) === 46); } function classicNameResolver(moduleName, containingFile, compilerOptions, host) { - if (moduleName.indexOf('!') != -1) { + if (moduleName.indexOf("!") != -1) { return { resolvedModule: undefined, failedLookupLocations: [] }; } var searchPath = ts.getDirectoryPath(containingFile); @@ -29786,7 +30261,7 @@ var ts; return emitResult; } function getSourceFile(fileName) { - return filesByName.get(fileName); + return filesByName.get(fileName) || filesByName.get(ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory())); } function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { if (sourceFile) { @@ -29875,10 +30350,14 @@ var ts; var imports; for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var node = _a[_i]; + collect(node, true); + } + file.imports = imports || emptyArray; + function collect(node, allowRelativeModuleNames) { switch (node.kind) { - case 220: - case 219: - case 226: + case 222: + case 221: + case 228: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -29886,24 +30365,19 @@ var ts; if (!moduleNameExpr.text) { break; } - (imports || (imports = [])).push(moduleNameExpr); + if (allowRelativeModuleNames || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { + (imports || (imports = [])).push(moduleNameExpr); + } break; - case 216: + case 218: if (node.name.kind === 9 && (node.flags & 2 || ts.isDeclarationFile(file))) { ts.forEachChild(node.body, function (node) { - if (ts.isExternalModuleImportEqualsDeclaration(node) && - ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 9) { - var moduleName = ts.getExternalModuleImportEqualsDeclarationExpression(node); - if (moduleName) { - (imports || (imports = [])).push(moduleName); - } - } + collect(node, false); }); } break; } } - file.imports = imports || emptyArray; } function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var diagnosticArgument; @@ -29946,48 +30420,46 @@ var ts; } } function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - if (filesByName.contains(canonicalName)) { - return getSourceFileFromCache(fileName, canonicalName, false); + if (filesByName.contains(fileName)) { + return getSourceFileFromCache(fileName, false); } - else { - var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); - var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); - if (filesByName.contains(canonicalAbsolutePath)) { - return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); + var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); + if (filesByName.contains(normalizedAbsolutePath)) { + var file_1 = getSourceFileFromCache(normalizedAbsolutePath, true); + filesByName.set(fileName, file_1); + return file_1; + } + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }); - filesByName.set(canonicalName, file); - if (file) { - skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - filesByName.set(canonicalAbsolutePath, file); - var basePath = ts.getDirectoryPath(fileName); - if (!options.noResolve) { - processReferencedFiles(file, basePath); - } - processImportedModules(file, basePath); - if (isDefaultLib) { - file.isDefaultLib = true; - files.unshift(file); - } - else { - files.push(file); - } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + } + }); + filesByName.set(fileName, file); + if (file) { + skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; + filesByName.set(normalizedAbsolutePath, file); + var basePath = ts.getDirectoryPath(fileName); + if (!options.noResolve) { + processReferencedFiles(file, basePath); + } + processImportedModules(file, basePath); + if (isDefaultLib) { + file.isDefaultLib = true; + files.unshift(file); + } + else { + files.push(file); } - return file; } - function getSourceFileFromCache(fileName, canonicalName, useAbsolutePath) { - var file = filesByName.get(canonicalName); + return file; + function getSourceFileFromCache(fileName, useAbsolutePath) { + var file = filesByName.get(fileName); if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; - if (canonicalName !== sourceFileName) { + if (ts.normalizeSlashes(fileName) !== ts.normalizeSlashes(sourceFileName)) { if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); } @@ -30019,7 +30491,7 @@ var ts; if (importedFile && resolution.isExternalLibraryImport) { if (!ts.isExternalModule(importedFile)) { var start_2 = ts.getTokenPosOfNode(file.imports[i], file); - fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.File_0_is_not_a_module, importedFile.fileName)); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName)); } else if (!ts.fileExtensionIs(importedFile.fileName, ".d.ts")) { var start_3 = ts.getTokenPosOfNode(file.imports[i], file); @@ -30148,8 +30620,8 @@ var ts; var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } - if (options.module && languageVersion >= 2) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); + if (options.module === 5 && languageVersion < 2) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower)); } if (options.outDir || options.sourceRoot || @@ -30183,18 +30655,10 @@ var ts; !options.experimentalDecorators) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } - if (options.experimentalAsyncFunctions && - options.target !== 2) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); - } } } ts.createProgram = createProgram; })(ts || (ts = {})); -/// -/// -/// -/// var ts; (function (ts) { ts.optionDeclarations = [ @@ -30267,11 +30731,13 @@ var ts; "commonjs": 1, "amd": 2, "system": 4, - "umd": 3 + "umd": 3, + "es6": 5, + "es2015": 5 }, - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_or_umd, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6, paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6 }, { name: "newLine", @@ -30395,7 +30861,12 @@ var ts; { name: "target", shortName: "t", - type: { "es3": 0, "es5": 1, "es6": 2 }, + type: { + "es3": 0, + "es5": 1, + "es6": 2, + "es2015": 2 + }, description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental, paramType: ts.Diagnostics.VERSION, error: ts.Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES6 @@ -30412,11 +30883,6 @@ var ts; type: "boolean", description: ts.Diagnostics.Watch_input_files }, - { - name: "experimentalAsyncFunctions", - type: "boolean", - description: ts.Diagnostics.Enables_experimental_support_for_ES7_async_functions - }, { name: "experimentalDecorators", type: "boolean", @@ -30549,18 +31015,18 @@ var ts; } } ts.parseCommandLine = parseCommandLine; - function readConfigFile(fileName) { + function readConfigFile(fileName, readFile) { var text = ""; try { - text = ts.sys.readFile(fileName); + text = readFile(fileName); } catch (e) { return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; } - return parseConfigFileText(fileName, text); + return parseConfigFileTextToJson(fileName, text); } ts.readConfigFile = readConfigFile; - function parseConfigFileText(fileName, jsonText) { + function parseConfigFileTextToJson(fileName, jsonText) { try { return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} }; } @@ -30568,8 +31034,8 @@ var ts; return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; } } - ts.parseConfigFileText = parseConfigFileText; - function parseConfigFile(json, host, basePath) { + ts.parseConfigFileTextToJson = parseConfigFileTextToJson; + function parseJsonConfigFileContent(json, host, basePath) { var errors = []; return { options: getCompilerOptions(), @@ -30603,6 +31069,9 @@ var ts; } if (opt.isFilePath) { value = ts.normalizePath(ts.combinePaths(basePath, value)); + if (value === "") { + value = "."; + } } options[opt.name] = value; } @@ -30631,30 +31100,28 @@ var ts; var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; var sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); for (var i = 0; i < sysFiles.length; i++) { - var name_27 = sysFiles[i]; - if (ts.fileExtensionIs(name_27, ".d.ts")) { - var baseName = name_27.substr(0, name_27.length - ".d.ts".length); + var name_28 = sysFiles[i]; + if (ts.fileExtensionIs(name_28, ".d.ts")) { + var baseName = name_28.substr(0, name_28.length - ".d.ts".length); if (!ts.contains(sysFiles, baseName + ".tsx") && !ts.contains(sysFiles, baseName + ".ts")) { - fileNames.push(name_27); + fileNames.push(name_28); } } - else if (ts.fileExtensionIs(name_27, ".ts")) { - if (!ts.contains(sysFiles, name_27 + "x")) { - fileNames.push(name_27); + else if (ts.fileExtensionIs(name_28, ".ts")) { + if (!ts.contains(sysFiles, name_28 + "x")) { + fileNames.push(name_28); } } else { - fileNames.push(name_27); + fileNames.push(name_28); } } } return fileNames; } } - ts.parseConfigFile = parseConfigFile; + ts.parseJsonConfigFileContent = parseJsonConfigFileContent; })(ts || (ts = {})); -/// -/// var ts; (function (ts) { function validateLocaleAndSetLanguage(locale, errors) { @@ -30730,6 +31197,15 @@ var ts; reportDiagnostic(diagnostics[i]); } } + function reportWatchDiagnostic(diagnostic) { + var output = new Date().toLocaleTimeString() + " - "; + if (diagnostic.file) { + var loc = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); + output += diagnostic.file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + "): "; + } + output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine) + ts.sys.newLine; + ts.sys.write(output); + } function padLeft(s, length) { while (s.length < length) { s = " " + s; @@ -30757,13 +31233,16 @@ var ts; function executeCommandLine(args) { var commandLine = ts.parseCommandLine(args); var configFileName; + var cachedConfigFileText; var configFileWatcher; + var directoryWatcher; var cachedProgram; var rootFileNames; var compilerOptions; var compilerHost; var hostGetSourceFile; - var timerHandle; + var timerHandleForRecompilation; + var timerHandleForDirectoryChanges; if (commandLine.options.locale) { if (!isJSONSupported()) { reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--locale")); @@ -30816,22 +31295,38 @@ var ts; if (configFileName) { configFileWatcher = ts.sys.watchFile(configFileName, configFileChanged); } + if (ts.sys.watchDirectory && configFileName) { + var directory = ts.getDirectoryPath(configFileName); + directoryWatcher = ts.sys.watchDirectory(directory == "" ? "." : directory, watchedDirectoryChanged, true); + } } performCompilation(); + function parseConfigFile() { + if (!cachedConfigFileText) { + try { + cachedConfigFileText = ts.sys.readFile(configFileName); + } + catch (e) { + var error = ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, configFileName, e.message); + reportWatchDiagnostic(error); + ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); + return; + } + } + var result = ts.parseConfigFileTextToJson(configFileName, cachedConfigFileText); + var configObject = result.config; + var configParseResult = ts.parseJsonConfigFileContent(configObject, ts.sys, ts.getDirectoryPath(configFileName)); + if (configParseResult.errors.length > 0) { + reportDiagnostics(configParseResult.errors); + ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); + return; + } + return configParseResult; + } function performCompilation() { if (!cachedProgram) { if (configFileName) { - var result = ts.readConfigFile(configFileName); - if (result.error) { - reportDiagnostic(result.error); - return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); - } - var configObject = result.config; - var configParseResult = ts.parseConfigFile(configObject, ts.sys, ts.getDirectoryPath(configFileName)); - if (configParseResult.errors.length > 0) { - reportDiagnostics(configParseResult.errors); - return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); - } + var configParseResult = parseConfigFile(); rootFileNames = configParseResult.fileNames; compilerOptions = ts.extend(commandLine.options, configParseResult.options); } @@ -30848,7 +31343,7 @@ var ts; return ts.sys.exit(compileResult.exitStatus); } setCachedProgram(compileResult.program); - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Compilation_complete_Watching_for_file_changes)); + reportWatchDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Compilation_complete_Watching_for_file_changes)); } function getSourceFile(fileName, languageVersion, onError) { if (cachedProgram) { @@ -30859,7 +31354,7 @@ var ts; } var sourceFile = hostGetSourceFile(fileName, languageVersion, onError); if (sourceFile && compilerOptions.watch) { - sourceFile.fileWatcher = ts.sys.watchFile(sourceFile.fileName, function () { return sourceFileChanged(sourceFile); }); + sourceFile.fileWatcher = ts.sys.watchFile(sourceFile.fileName, function (fileName, removed) { return sourceFileChanged(sourceFile, removed); }); } return sourceFile; } @@ -30877,24 +31372,52 @@ var ts; } cachedProgram = program; } - function sourceFileChanged(sourceFile) { + function sourceFileChanged(sourceFile, removed) { sourceFile.fileWatcher.close(); sourceFile.fileWatcher = undefined; - startTimer(); + if (removed) { + var index = rootFileNames.indexOf(sourceFile.fileName); + if (index >= 0) { + rootFileNames.splice(index, 1); + } + } + startTimerForRecompilation(); } function configFileChanged() { setCachedProgram(undefined); - startTimer(); + cachedConfigFileText = undefined; + startTimerForRecompilation(); + } + function watchedDirectoryChanged(fileName) { + if (fileName && !ts.isSupportedSourceFileName(fileName)) { + return; + } + startTimerForHandlingDirectoryChanges(); + } + function startTimerForHandlingDirectoryChanges() { + if (timerHandleForDirectoryChanges) { + clearTimeout(timerHandleForDirectoryChanges); + } + timerHandleForDirectoryChanges = setTimeout(directoryChangeHandler, 250); + } + function directoryChangeHandler() { + var parsedCommandLine = parseConfigFile(); + var newFileNames = ts.map(parsedCommandLine.fileNames, compilerHost.getCanonicalFileName); + var canonicalRootFileNames = ts.map(rootFileNames, compilerHost.getCanonicalFileName); + if (!ts.arrayIsEqualTo(newFileNames && newFileNames.sort(), canonicalRootFileNames && canonicalRootFileNames.sort())) { + setCachedProgram(undefined); + startTimerForRecompilation(); + } } - function startTimer() { - if (timerHandle) { - clearTimeout(timerHandle); + function startTimerForRecompilation() { + if (timerHandleForRecompilation) { + clearTimeout(timerHandleForRecompilation); } - timerHandle = setTimeout(recompile, 250); + timerHandleForRecompilation = setTimeout(recompile, 250); } function recompile() { - timerHandle = undefined; - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation)); + timerHandleForRecompilation = undefined; + reportWatchDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation)); performCompilation(); } } @@ -31022,7 +31545,7 @@ var ts; } function writeConfigFile(options, fileNames) { var currentDirectory = ts.sys.getCurrentDirectory(); - var file = ts.combinePaths(currentDirectory, 'tsconfig.json'); + var file = ts.combinePaths(currentDirectory, "tsconfig.json"); if (ts.sys.fileExists(file)) { reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file)); } @@ -31042,10 +31565,10 @@ var ts; function serializeCompilerOptions(options) { var result = {}; var optionsNameMap = ts.getOptionNameMap().optionNameMap; - for (var name_28 in options) { - if (ts.hasProperty(options, name_28)) { - var value = options[name_28]; - switch (name_28) { + for (var name_29 in options) { + if (ts.hasProperty(options, name_29)) { + var value = options[name_29]; + switch (name_29) { case "init": case "watch": case "version": @@ -31053,17 +31576,17 @@ var ts; case "project": break; default: - var optionDefinition = optionsNameMap[name_28.toLowerCase()]; + var optionDefinition = optionsNameMap[name_29.toLowerCase()]; if (optionDefinition) { if (typeof optionDefinition.type === "string") { - result[name_28] = value; + result[name_29] = value; } else { var typeMap = optionDefinition.type; for (var key in typeMap) { if (ts.hasProperty(typeMap, key)) { if (typeMap[key] === value) - result[name_28] = key; + result[name_29] = key; } } } diff --git a/tsserver/tsserver.js b/tsserver/tsserver.js index ce095409..2fbd84e5 100644 --- a/tsserver/tsserver.js +++ b/tsserver/tsserver.js @@ -47,7 +47,6 @@ var ts; })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); var DiagnosticCategory = ts.DiagnosticCategory; })(ts || (ts = {})); -/// var ts; (function (ts) { function createFileMap(getCanonicalFileName) { @@ -411,8 +410,11 @@ var ts; } ts.chainDiagnosticMessages = chainDiagnosticMessages; function concatenateDiagnosticMessageChains(headChain, tailChain) { - Debug.assert(!headChain.next); - headChain.next = tailChain; + var lastChain = headChain; + while (lastChain.next) { + lastChain = lastChain.next; + } + lastChain.next = tailChain; return headChain; } ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; @@ -569,9 +571,6 @@ var ts; } ts.getNormalizedPathFromPathComponents = getNormalizedPathFromPathComponents; function getNormalizedPathComponentsOfUrl(url) { - // Get root length of http://www.website.com/folder1/foler2/ - // In this example the root is: http://www.website.com/ - // normalized path components should be ["http://www.website.com/", "folder1", "folder2"] var urlLength = url.length; var rootLength = url.indexOf("://") + "://".length; while (rootLength < urlLength) { @@ -631,6 +630,9 @@ var ts; } ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; function getBaseFileName(path) { + if (!path) { + return undefined; + } var i = path.lastIndexOf(ts.directorySeparator); return i < 0 ? path : path.substring(i + 1); } @@ -654,6 +656,20 @@ var ts; } ts.fileExtensionIs = fileExtensionIs; ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; + ts.moduleFileExtensions = ts.supportedExtensions; + function isSupportedSourceFileName(fileName) { + if (!fileName) { + return false; + } + for (var _i = 0; _i < ts.supportedExtensions.length; _i++) { + var extension = ts.supportedExtensions[_i]; + if (fileExtensionIs(fileName, extension)) { + return true; + } + } + return false; + } + ts.isSupportedSourceFileName = isSupportedSourceFileName; var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { @@ -730,8 +746,18 @@ var ts; } Debug.fail = fail; })(Debug = ts.Debug || (ts.Debug = {})); + function copyListRemovingItem(item, list) { + var copiedList = []; + for (var _i = 0; _i < list.length; _i++) { + var e = list[_i]; + if (e !== item) { + copiedList.push(e); + } + } + return copiedList; + } + ts.copyListRemovingItem = copyListRemovingItem; })(ts || (ts = {})); -/// var ts; (function (ts) { ts.sys = (function () { @@ -869,6 +895,76 @@ var ts; var _fs = require("fs"); var _path = require("path"); var _os = require("os"); + function createWatchedFileSet(interval, chunkSize) { + if (interval === void 0) { interval = 2500; } + if (chunkSize === void 0) { chunkSize = 30; } + var watchedFiles = []; + var nextFileToCheck = 0; + var watchTimer; + function getModifiedTime(fileName) { + return _fs.statSync(fileName).mtime; + } + function poll(checkedIndex) { + var watchedFile = watchedFiles[checkedIndex]; + if (!watchedFile) { + return; + } + _fs.stat(watchedFile.fileName, function (err, stats) { + if (err) { + watchedFile.callback(watchedFile.fileName); + } + else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { + watchedFile.mtime = getModifiedTime(watchedFile.fileName); + watchedFile.callback(watchedFile.fileName, watchedFile.mtime.getTime() === 0); + } + }); + } + function startWatchTimer() { + watchTimer = setInterval(function () { + var count = 0; + var nextToCheck = nextFileToCheck; + var firstCheck = -1; + while ((count < chunkSize) && (nextToCheck !== firstCheck)) { + poll(nextToCheck); + if (firstCheck < 0) { + firstCheck = nextToCheck; + } + nextToCheck++; + if (nextToCheck === watchedFiles.length) { + nextToCheck = 0; + } + count++; + } + nextFileToCheck = nextToCheck; + }, interval); + } + function addFile(fileName, callback) { + var file = { + fileName: fileName, + callback: callback, + mtime: getModifiedTime(fileName) + }; + watchedFiles.push(file); + if (watchedFiles.length === 1) { + startWatchTimer(); + } + return file; + } + function removeFile(file) { + watchedFiles = ts.copyListRemovingItem(file, watchedFiles); + } + return { + getModifiedTime: getModifiedTime, + poll: poll, + startWatchTimer: startWatchTimer, + addFile: addFile, + removeFile: removeFile + }; + } + var watchedFileSet = createWatchedFileSet(); + function isNode4OrLater() { + return parseInt(process.version.charAt(1)) >= 4; + } var platform = _os.platform(); var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; function readFile(fileName, encoding) { @@ -949,16 +1045,21 @@ var ts; readFile: readFile, writeFile: writeFile, watchFile: function (fileName, callback) { - _fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged); + if (isNode4OrLater()) { + return _fs.watch(fileName, function (eventName, relativeFileName) { return callback(fileName); }); + } + var watchedFile = watchedFileSet.addFile(fileName, callback); return { - close: function () { _fs.unwatchFile(fileName, fileChanged); } + close: function () { return watchedFileSet.removeFile(watchedFile); } }; - function fileChanged(curr, prev) { - if (+curr.mtime <= +prev.mtime) { - return; + }, + watchDirectory: function (path, callback, recursive) { + return _fs.watch(path, { persistent: true, recursive: !!recursive }, function (eventName, relativeFileName) { + if (eventName === "rename") { + callback(!relativeFileName ? relativeFileName : ts.normalizePath(ts.combinePaths(path, relativeFileName))); } - callback(fileName); - } + ; + }); }, resolvePath: function (path) { return _path.resolve(path); @@ -1003,7 +1104,6 @@ var ts; } })(); })(ts || (ts = {})); -/// var ts; (function (ts) { ts.Diagnostics = { @@ -1056,7 +1156,7 @@ var ts; Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum member must have initializer." }, _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." }, - Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: ts.DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers." }, + In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { code: 1066, category: ts.DiagnosticCategory.Error, key: "In ambient enum declarations member initializer must be constant expression." }, Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." }, @@ -1144,7 +1244,7 @@ var ts; Property_destructuring_pattern_expected: { code: 1180, category: ts.DiagnosticCategory.Error, key: "Property destructuring pattern expected." }, Array_element_destructuring_pattern_expected: { code: 1181, category: ts.DiagnosticCategory.Error, key: "Array element destructuring pattern expected." }, A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: ts.DiagnosticCategory.Error, key: "A destructuring declaration must have an initializer." }, - An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: ts.DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, + An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1183, category: ts.DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, Modifiers_cannot_appear_here: { code: 1184, category: ts.DiagnosticCategory.Error, key: "Modifiers cannot appear here." }, Merge_conflict_marker_encountered: { code: 1185, category: ts.DiagnosticCategory.Error, key: "Merge conflict marker encountered." }, A_rest_element_cannot_have_an_initializer: { code: 1186, category: ts.DiagnosticCategory.Error, key: "A rest element cannot have an initializer." }, @@ -1162,10 +1262,9 @@ var ts; An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: ts.DiagnosticCategory.Error, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, Unterminated_Unicode_escape_sequence: { code: 1199, category: ts.DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." }, Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." }, - Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." }, - Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." }, - Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher." }, - Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: ts.DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." }, + Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead." }, + Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead." }, + Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'es6' when targeting 'ES5' or lower." }, Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." }, Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, @@ -1194,10 +1293,6 @@ var ts; 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." }, - Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning: { code: 1236, category: ts.DiagnosticCategory.Error, key: "Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning." }, - with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, - await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, - Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: ts.DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." }, The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: ts.DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." }, Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." }, @@ -1208,6 +1303,10 @@ var ts; _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with '{1}' modifier." }, Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: ts.DiagnosticCategory.Error, key: "Abstract methods can only appear within an abstract class." }, Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: ts.DiagnosticCategory.Error, key: "Method '{0}' cannot have an implementation because it is marked abstract." }, + with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, + await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, + Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, + can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "'=' can only be used in an object literal property inside a destructuring assignment." }, 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." }, @@ -1248,7 +1347,7 @@ var ts; Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." }, Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: ts.DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword." }, Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." }, - An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." }, + An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." }, Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." }, Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." }, Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." }, @@ -1332,7 +1431,7 @@ var ts; In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, - Ambient_modules_cannot_be_nested_in_other_modules: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules." }, + Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules or namespaces." }, Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient module declaration cannot specify relative module name." }, Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module '{0}' is hidden by a local declaration with the same name" }, Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import name cannot be '{0}'" }, @@ -1413,12 +1512,15 @@ var ts; Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: ts.DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." }, Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, - Only_an_ambient_class_can_be_merged_with_an_interface: { code: 2518, category: ts.DiagnosticCategory.Error, key: "Only an ambient class can be merged with an interface." }, Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." }, await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." }, + Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." }, + A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { code: 2526, category: ts.DiagnosticCategory.Error, key: "A 'this' type is available only in a non-static member of a class or interface." }, + The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { code: 2527, category: ts.DiagnosticCategory.Error, key: "The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary." }, + A_module_cannot_have_multiple_default_exports: { code: 2528, category: ts.DiagnosticCategory.Error, key: "A module cannot have multiple default exports." }, JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -1431,8 +1533,10 @@ var ts; Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, + Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." }, Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." }, Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition: { code: 2655, category: ts.DiagnosticCategory.Error, key: "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition." }, + Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." }, 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}'." }, @@ -1517,7 +1621,7 @@ var ts; Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, - A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, @@ -1529,7 +1633,7 @@ var ts; Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." }, Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." }, Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, - Specify_module_code_generation_Colon_commonjs_amd_system_or_umd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system' or 'umd'" }, + Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es6'" }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print the compiler's version." }, Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile the project in the given directory." }, @@ -1550,7 +1654,7 @@ var ts; Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_amd_system_or_umd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system' or 'umd'." }, + Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es6'." }, Argument_for_target_option_must_be_ES3_ES5_or_ES6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES6'." }, Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, @@ -1571,7 +1675,6 @@ var ts; Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, - Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." }, Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, @@ -1618,79 +1721,83 @@ var ts; Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" } + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" }, + An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17006, category: ts.DiagnosticCategory.Error, key: "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, + A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17007, category: ts.DiagnosticCategory.Error, key: "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." } }; })(ts || (ts = {})); -/// -/// var ts; (function (ts) { + function tokenIsIdentifierOrKeyword(token) { + return token >= 69; + } + ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = { - "abstract": 113, - "any": 115, - "as": 114, - "boolean": 118, - "break": 68, - "case": 69, - "catch": 70, - "class": 71, - "continue": 73, - "const": 72, - "constructor": 119, - "debugger": 74, - "declare": 120, - "default": 75, - "delete": 76, - "do": 77, - "else": 78, - "enum": 79, - "export": 80, - "extends": 81, - "false": 82, - "finally": 83, - "for": 84, - "from": 131, - "function": 85, - "get": 121, - "if": 86, - "implements": 104, - "import": 87, - "in": 88, - "instanceof": 89, - "interface": 105, - "is": 122, - "let": 106, - "module": 123, - "namespace": 124, - "new": 90, - "null": 91, - "number": 126, - "package": 107, - "private": 108, - "protected": 109, - "public": 110, - "require": 125, - "return": 92, - "set": 127, - "static": 111, - "string": 128, - "super": 93, - "switch": 94, - "symbol": 129, - "this": 95, - "throw": 96, - "true": 97, - "try": 98, - "type": 130, - "typeof": 99, - "var": 100, - "void": 101, - "while": 102, - "with": 103, - "yield": 112, - "async": 116, - "await": 117, - "of": 132, + "abstract": 115, + "any": 117, + "as": 116, + "boolean": 120, + "break": 70, + "case": 71, + "catch": 72, + "class": 73, + "continue": 75, + "const": 74, + "constructor": 121, + "debugger": 76, + "declare": 122, + "default": 77, + "delete": 78, + "do": 79, + "else": 80, + "enum": 81, + "export": 82, + "extends": 83, + "false": 84, + "finally": 85, + "for": 86, + "from": 133, + "function": 87, + "get": 123, + "if": 88, + "implements": 106, + "import": 89, + "in": 90, + "instanceof": 91, + "interface": 107, + "is": 124, + "let": 108, + "module": 125, + "namespace": 126, + "new": 92, + "null": 93, + "number": 128, + "package": 109, + "private": 110, + "protected": 111, + "public": 112, + "require": 127, + "return": 94, + "set": 129, + "static": 113, + "string": 130, + "super": 95, + "switch": 96, + "symbol": 131, + "this": 97, + "throw": 98, + "true": 99, + "try": 100, + "type": 132, + "typeof": 101, + "var": 102, + "void": 103, + "while": 104, + "with": 105, + "yield": 114, + "async": 118, + "await": 119, + "of": 134, "{": 15, "}": 16, "(": 17, @@ -1712,37 +1819,39 @@ var ts; "=>": 34, "+": 35, "-": 36, + "**": 38, "*": 37, - "/": 38, - "%": 39, - "++": 40, - "--": 41, - "<<": 42, + "/": 39, + "%": 40, + "++": 41, + "--": 42, + "<<": 43, ">": 43, - ">>>": 44, - "&": 45, - "|": 46, - "^": 47, - "!": 48, - "~": 49, - "&&": 50, - "||": 51, - "?": 52, - ":": 53, - "=": 55, - "+=": 56, - "-=": 57, - "*=": 58, - "/=": 59, - "%=": 60, - "<<=": 61, - ">>=": 62, - ">>>=": 63, - "&=": 64, - "|=": 65, - "^=": 66, - "@": 54 + ">>": 44, + ">>>": 45, + "&": 46, + "|": 47, + "^": 48, + "!": 49, + "~": 50, + "&&": 51, + "||": 52, + "?": 53, + ":": 54, + "=": 56, + "+=": 57, + "-=": 58, + "*=": 59, + "**=": 60, + "/=": 61, + "%=": 62, + "<<=": 63, + ">>=": 64, + ">>>=": 65, + "&=": 66, + "|=": 67, + "^=": 68, + "@": 55 }; var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; @@ -1872,16 +1981,6 @@ var ts; } ts.isWhiteSpace = isWhiteSpace; function isLineBreak(ch) { - // ES5 7.3: - // The ECMAScript line terminator characters are listed in Table 3. - // Table 3: Line Terminator Characters - // Code Unit Value Name Formal Name - // \u000A Line Feed - // \u000D Carriage Return - // \u2028 Line separator - // \u2029 Paragraph separator - // Only the characters in Table 3 are treated as line terminators. Other new line or line - // breaking characters are treated as white space but not as line terminators. return ch === 10 || ch === 13 || ch === 8232 || @@ -2154,8 +2253,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 67 || token > 103; }, - isReservedWord: function () { return token >= 68 && token <= 103; }, + isIdentifier: function () { return token === 69 || token > 105; }, + isReservedWord: function () { return token >= 70 && token <= 105; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -2177,16 +2276,6 @@ var ts; onError(message, length || 0); } } - function isIdentifierStart(ch) { - return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || - ch === 36 || ch === 95 || - ch > 127 && isUnicodeIdentifierStart(ch, languageVersion); - } - function isIdentifierPart(ch) { - return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || - ch >= 48 && ch <= 57 || ch === 36 || ch === 95 || - ch > 127 && isUnicodeIdentifierPart(ch, languageVersion); - } function scanNumber() { var start = pos; while (isDigit(text.charCodeAt(pos))) @@ -2441,12 +2530,12 @@ var ts; var start = pos; while (pos < end) { var ch = text.charCodeAt(pos); - if (isIdentifierPart(ch)) { + if (isIdentifierPart(ch, languageVersion)) { pos++; } else if (ch === 92) { ch = peekUnicodeEscape(); - if (!(ch >= 0 && isIdentifierPart(ch))) { + if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } result += text.substring(start, pos); @@ -2469,7 +2558,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 67; + return token = 69; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -2548,7 +2637,7 @@ var ts; } return pos += 2, token = 31; } - return pos++, token = 48; + return pos++, token = 49; case 34: case 39: tokenValue = scanString(); @@ -2557,42 +2646,48 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 60; + return pos += 2, token = 62; } - return pos++, token = 39; + return pos++, token = 40; case 38: if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 50; + return pos += 2, token = 51; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 64; + return pos += 2, token = 66; } - return pos++, token = 45; + return pos++, token = 46; case 40: return pos++, token = 17; case 41: return pos++, token = 18; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; + return pos += 2, token = 59; + } + if (text.charCodeAt(pos + 1) === 42) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 60; + } + return pos += 2, token = 38; } return pos++, token = 37; case 43: if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 40; + return pos += 2, token = 41; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 56; + return pos += 2, token = 57; } return pos++, token = 35; case 44: return pos++, token = 24; case 45: if (text.charCodeAt(pos + 1) === 45) { - return pos += 2, token = 41; + return pos += 2, token = 42; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; + return pos += 2, token = 58; } return pos++, token = 36; case 46: @@ -2647,9 +2742,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 59; + return pos += 2, token = 61; } - return pos++, token = 38; + return pos++, token = 39; case 48: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { pos += 2; @@ -2697,7 +2792,7 @@ var ts; tokenValue = "" + scanNumber(); return token = 8; case 58: - return pos++, token = 53; + return pos++, token = 54; case 59: return pos++, token = 23; case 60: @@ -2712,14 +2807,16 @@ var ts; } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 61; + return pos += 3, token = 63; } - return pos += 2, token = 42; + return pos += 2, token = 43; } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 28; } - if (text.charCodeAt(pos + 1) === 47 && languageVariant === 1) { + if (languageVariant === 1 && + text.charCodeAt(pos + 1) === 47 && + text.charCodeAt(pos + 2) !== 42) { return pos += 2, token = 26; } return pos++, token = 25; @@ -2742,7 +2839,7 @@ var ts; if (text.charCodeAt(pos + 1) === 62) { return pos += 2, token = 34; } - return pos++, token = 55; + return pos++, token = 56; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2755,35 +2852,35 @@ var ts; } return pos++, token = 27; case 63: - return pos++, token = 52; + return pos++, token = 53; case 91: return pos++, token = 19; case 93: return pos++, token = 20; case 94: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 66; + return pos += 2, token = 68; } - return pos++, token = 47; + return pos++, token = 48; case 123: return pos++, token = 15; case 124: if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 51; + return pos += 2, token = 52; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 65; + return pos += 2, token = 67; } - return pos++, token = 46; + return pos++, token = 47; case 125: return pos++, token = 16; case 126: - return pos++, token = 49; + return pos++, token = 50; case 64: - return pos++, token = 54; + return pos++, token = 55; case 92: var cookedChar = peekUnicodeEscape(); - if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); @@ -2791,9 +2888,9 @@ var ts; error(ts.Diagnostics.Invalid_character); return pos++, token = 0; default: - if (isIdentifierStart(ch)) { + if (isIdentifierStart(ch, languageVersion)) { pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos))) + while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) pos++; tokenValue = text.substring(tokenPos, pos); if (ch === 92) { @@ -2820,14 +2917,14 @@ var ts; if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 63; + return pos += 3, token = 65; } - return pos += 2, token = 44; + return pos += 2, token = 45; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; + return pos += 2, token = 64; } - return pos++, token = 43; + return pos++, token = 44; } if (text.charCodeAt(pos) === 61) { return pos++, token = 29; @@ -2836,7 +2933,7 @@ var ts; return token; } function reScanSlashToken() { - if (token === 38 || token === 59) { + if (token === 39 || token === 61) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -2870,7 +2967,7 @@ var ts; } p++; } - while (p < end && isIdentifierPart(text.charCodeAt(p))) { + while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) { p++; } pos = p; @@ -2913,14 +3010,14 @@ var ts; break; } } - return token = 234; + return token = 236; } function scanJsxIdentifier() { - if (token === 67) { + if (tokenIsIdentifierOrKeyword(token)) { var firstCharPosition = pos; while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 || ((firstCharPosition === pos) ? isIdentifierStart(ch) : isIdentifierPart(ch))) { + if (ch === 45 || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { pos++; } else { @@ -2983,10 +3080,6 @@ var ts; } ts.createScanner = createScanner; })(ts || (ts = {})); -/// -/// -/// -/// var ts; (function (ts) { ts.optionDeclarations = [ @@ -3059,11 +3152,13 @@ var ts; "commonjs": 1, "amd": 2, "system": 4, - "umd": 3 + "umd": 3, + "es6": 5, + "es2015": 5 }, - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_or_umd, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6, paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6 }, { name: "newLine", @@ -3187,7 +3282,12 @@ var ts; { name: "target", shortName: "t", - type: { "es3": 0, "es5": 1, "es6": 2 }, + type: { + "es3": 0, + "es5": 1, + "es6": 2, + "es2015": 2 + }, description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental, paramType: ts.Diagnostics.VERSION, error: ts.Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES6 @@ -3204,11 +3304,6 @@ var ts; type: "boolean", description: ts.Diagnostics.Watch_input_files }, - { - name: "experimentalAsyncFunctions", - type: "boolean", - description: ts.Diagnostics.Enables_experimental_support_for_ES7_async_functions - }, { name: "experimentalDecorators", type: "boolean", @@ -3341,18 +3436,18 @@ var ts; } } ts.parseCommandLine = parseCommandLine; - function readConfigFile(fileName) { + function readConfigFile(fileName, readFile) { var text = ""; try { - text = ts.sys.readFile(fileName); + text = readFile(fileName); } catch (e) { return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; } - return parseConfigFileText(fileName, text); + return parseConfigFileTextToJson(fileName, text); } ts.readConfigFile = readConfigFile; - function parseConfigFileText(fileName, jsonText) { + function parseConfigFileTextToJson(fileName, jsonText) { try { return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} }; } @@ -3360,8 +3455,8 @@ var ts; return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; } } - ts.parseConfigFileText = parseConfigFileText; - function parseConfigFile(json, host, basePath) { + ts.parseConfigFileTextToJson = parseConfigFileTextToJson; + function parseJsonConfigFileContent(json, host, basePath) { var errors = []; return { options: getCompilerOptions(), @@ -3395,6 +3490,9 @@ var ts; } if (opt.isFilePath) { value = ts.normalizePath(ts.combinePaths(basePath, value)); + if (value === "") { + value = "."; + } } options[opt.name] = value; } @@ -3443,9 +3541,8 @@ var ts; return fileNames; } } - ts.parseConfigFile = parseConfigFile; + ts.parseJsonConfigFileContent = parseJsonConfigFileContent; })(ts || (ts = {})); -/// var ts; (function (ts) { function getDeclarationOfKind(symbol, kind) { @@ -3479,7 +3576,8 @@ var ts; increaseIndent: function () { }, decreaseIndent: function () { }, clear: function () { return str = ""; }, - trackSymbol: function () { } + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } }; } return stringWriters.pop(); @@ -3494,15 +3592,15 @@ var ts; return node.end - node.pos; } ts.getFullWidth = getFullWidth; - function arrayIsEqualTo(arr1, arr2, comparer) { - if (!arr1 || !arr2) { - return arr1 === arr2; + function arrayIsEqualTo(array1, array2, equaler) { + if (!array1 || !array2) { + return array1 === array2; } - if (arr1.length !== arr2.length) { + if (array1.length !== array2.length) { return false; } - for (var i = 0; i < arr1.length; ++i) { - var equals = comparer ? comparer(arr1[i], arr2[i]) : arr1[i] === arr2[i]; + for (var i = 0; i < array1.length; ++i) { + var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; if (!equals) { return false; } @@ -3541,7 +3639,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 246) { + while (node && node.kind !== 248) { node = node.parent; } return node; @@ -3632,15 +3730,15 @@ var ts; return current; } switch (current.kind) { - case 246: + case 248: + case 220: + case 244: case 218: - case 242: - case 216: - case 197: - case 198: case 199: + case 200: + case 201: return current; - case 190: + case 192: if (!isFunctionLike(current.parent)) { return current; } @@ -3651,9 +3749,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 209 && + declaration.kind === 211 && declaration.parent && - declaration.parent.kind === 242; + declaration.parent.kind === 244; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3689,22 +3787,22 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 246: + case 248: 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 209: - case 161: - case 212: - case 184: - case 213: - case 216: - case 215: - case 245: case 211: - case 171: + case 163: + case 214: + case 186: + case 215: + case 218: + case 217: + case 247: + case 213: + case 173: errorNode = node.name; break; } @@ -3726,11 +3824,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 215 && isConst(node); + return node.kind === 217 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 161 || isBindingPattern(node))) { + while (node && (node.kind === 163 || isBindingPattern(node))) { node = node.parent; } return node; @@ -3738,14 +3836,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 209) { + if (node.kind === 211) { node = node.parent; } - if (node && node.kind === 210) { + if (node && node.kind === 212) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 191) { + if (node && node.kind === 193) { flags |= node.flags; } return flags; @@ -3760,7 +3858,7 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 193 && node.expression.kind === 9; + return node.kind === 195 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -3768,7 +3866,7 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - var commentRanges = (node.kind === 136 || node.kind === 135) ? + var commentRanges = (node.kind === 138 || node.kind === 137) ? ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : getLeadingCommentRangesOfNode(node, sourceFileOfNode); return ts.filter(commentRanges, isJsDocComment); @@ -3780,69 +3878,71 @@ var ts; } ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (149 <= node.kind && node.kind <= 158) { + if (151 <= node.kind && node.kind <= 160) { return true; } switch (node.kind) { - case 115: - case 126: + case 117: case 128: - case 118: - case 129: + case 130: + case 120: + case 131: return true; - case 101: - return node.parent.kind !== 175; + case 103: + return node.parent.kind !== 177; case 9: - return node.parent.kind === 136; - case 186: + return node.parent.kind === 138; + case 188: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 67: - if (node.parent.kind === 133 && node.parent.right === node) { + case 69: + if (node.parent.kind === 135 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 164 && node.parent.name === node) { + else if (node.parent.kind === 166 && node.parent.name === node) { node = node.parent; } - case 133: - case 164: - ts.Debug.assert(node.kind === 67 || node.kind === 133 || node.kind === 164, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + ts.Debug.assert(node.kind === 69 || node.kind === 135 || node.kind === 166, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 135: + case 166: + case 97: var parent_1 = node.parent; - if (parent_1.kind === 152) { + if (parent_1.kind === 154) { return false; } - if (149 <= parent_1.kind && parent_1.kind <= 158) { + if (151 <= parent_1.kind && parent_1.kind <= 160) { return true; } switch (parent_1.kind) { - case 186: + case 188: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 135: + case 137: return node === parent_1.constraint; - case 139: - case 138: - case 136: - case 209: - return node === parent_1.type; - case 211: - case 171: - case 172: - case 142: case 141: case 140: - case 143: - case 144: + case 138: + case 211: return node === parent_1.type; + case 213: + case 173: + case 174: + case 144: + case 143: + case 142: case 145: case 146: + return node === parent_1.type; case 147: + case 148: + case 149: return node === parent_1.type; - case 169: + case 171: return node === parent_1.type; - case 166: - case 167: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 168: + case 169: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 170: return false; } } @@ -3853,23 +3953,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 202: + case 204: return visitor(node); - case 218: - case 190: - case 194: - case 195: + case 220: + case 192: case 196: case 197: case 198: case 199: - case 203: - case 204: - case 239: - case 240: + case 200: + case 201: case 205: - case 207: + case 206: + case 241: case 242: + case 207: + case 209: + case 244: return ts.forEachChild(node, traverse); } } @@ -3879,23 +3979,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 182: + case 184: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } + case 217: case 215: - case 213: + case 218: case 216: case 214: - case 212: - case 184: + case 186: return; default: if (isFunctionLike(node)) { var name_6 = node.name; - if (name_6 && name_6.kind === 134) { + if (name_6 && name_6.kind === 136) { traverse(name_6.expression); return; } @@ -3910,14 +4010,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 161: - case 245: - case 136: - case 243: - case 139: + case 163: + case 247: case 138: - case 244: - case 209: + case 245: + case 141: + case 140: + case 246: + case 211: return true; } } @@ -3925,29 +4025,29 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 143 || node.kind === 144); + return node && (node.kind === 145 || node.kind === 146); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 212 || node.kind === 184); + return node && (node.kind === 214 || node.kind === 186); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 142: - case 171: - case 211: - case 172: - case 141: - case 140: - case 143: case 144: + case 173: + case 213: + case 174: + case 143: + case 142: case 145: case 146: case 147: - case 150: - case 151: + case 148: + case 149: + case 152: + case 153: return true; } } @@ -3956,24 +4056,24 @@ var ts; ts.isFunctionLike = isFunctionLike; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 141: - case 140: - case 142: case 143: + case 142: case 144: - case 211: - case 171: + case 145: + case 146: + case 213: + case 173: return true; } return false; } ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isFunctionBlock(node) { - return node && node.kind === 190 && isFunctionLike(node.parent); + return node && node.kind === 192 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 141 && node.parent.kind === 163; + return node && node.kind === 143 && node.parent.kind === 165; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -4001,36 +4101,39 @@ var ts; return undefined; } switch (node.kind) { - case 134: + case 136: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 137: - if (node.parent.kind === 136 && isClassElement(node.parent.parent)) { + case 139: + if (node.parent.kind === 138 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 172: + case 174: if (!includeArrowFunctions) { continue; } - case 211: - case 171: - case 216: - case 139: - case 138: + case 213: + case 173: + case 218: case 141: case 140: - case 142: case 143: + case 142: case 144: - case 215: - case 246: + case 145: + case 146: + case 147: + case 148: + case 149: + case 217: + case 248: return node; } } @@ -4042,33 +4145,33 @@ var ts; if (!node) return node; switch (node.kind) { - case 134: + case 136: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 137: - if (node.parent.kind === 136 && isClassElement(node.parent.parent)) { + case 139: + if (node.parent.kind === 138 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 211: - case 171: - case 172: + case 213: + case 173: + case 174: if (!includeFunctions) { continue; } - case 139: - case 138: case 141: case 140: - case 142: case 143: + case 142: case 144: + case 145: + case 146: return node; } } @@ -4077,12 +4180,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 149: + case 151: return node.typeName; - case 186: + case 188: return node.expression; - case 67: - case 133: + case 69: + case 135: return node; } } @@ -4090,7 +4193,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 168) { + if (node.kind === 170) { return node.tag; } return node.expression; @@ -4098,40 +4201,40 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 212: + case 214: return true; - case 139: - return node.parent.kind === 212; - case 136: - return node.parent.body && node.parent.parent.kind === 212; - case 143: - case 144: case 141: - return node.body && node.parent.kind === 212; + return node.parent.kind === 214; + case 138: + return node.parent.body && node.parent.parent.kind === 214; + case 145: + case 146: + case 143: + return node.body && node.parent.kind === 214; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 212: + case 214: if (node.decorators) { return true; } return false; - case 139: - case 136: + case 141: + case 138: if (node.decorators) { return true; } return false; - case 143: + case 145: if (node.body && node.decorators) { return true; } return false; - case 141: - case 144: + case 143: + case 146: if (node.body && node.decorators) { return true; } @@ -4142,10 +4245,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 212: + case 214: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 141: - case 144: + case 143: + case 146: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -4155,95 +4258,105 @@ var ts; return nodeIsDecorated(node) || childIsDecorated(node); } ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; + function isPropertyAccessExpression(node) { + return node.kind === 166; + } + ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isElementAccessExpression(node) { + return node.kind === 167; + } + ts.isElementAccessExpression = isElementAccessExpression; function isExpression(node) { switch (node.kind) { case 95: case 93: - case 91: - case 97: - case 82: + case 99: + case 84: case 10: - case 162: - case 163: case 164: case 165: case 166: case 167: case 168: - case 187: case 169: case 170: + case 189: case 171: - case 184: case 172: - case 175: case 173: + case 186: case 174: case 177: - case 178: + case 175: + case 176: case 179: case 180: - case 183: case 181: - case 11: - case 185: - case 231: - case 232: case 182: + case 185: + case 183: + case 11: + case 187: + case 233: + case 234: + case 184: + case 178: return true; - case 133: - while (node.parent.kind === 133) { + case 135: + while (node.parent.kind === 135) { node = node.parent; } - return node.parent.kind === 152; - case 67: - if (node.parent.kind === 152) { + return node.parent.kind === 154; + case 69: + if (node.parent.kind === 154) { return true; } case 8: case 9: + case 97: var parent_2 = node.parent; switch (parent_2.kind) { - case 209: - case 136: - case 139: + case 211: case 138: + case 141: + case 140: + case 247: case 245: - case 243: - case 161: + case 163: return parent_2.initializer === node; - case 193: - case 194: case 195: case 196: - case 202: - case 203: + case 197: + case 198: case 204: - case 239: + case 205: + case 206: + case 241: + case 208: case 206: - case 204: return parent_2.expression === node; - case 197: + case 199: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 210) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 212) || forStatement.condition === node || forStatement.incrementor === node; - case 198: - case 199: + case 200: + case 201: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 210) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 212) || forInStatement.expression === node; - case 169: - case 187: + case 171: + case 189: return node === parent_2.expression; - case 188: + case 190: return node === parent_2.expression; - case 134: + case 136: return node === parent_2.expression; - case 137: - case 238: + case 139: + case 240: + case 239: return true; - case 186: + case 188: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -4254,6 +4367,10 @@ var ts; return false; } ts.isExpression = isExpression; + function isExternalModuleNameRelative(moduleName) { + return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; + } + ts.isExternalModuleNameRelative = isExternalModuleNameRelative; function isInstantiatedModule(node, preserveConstEnums) { var moduleState = ts.getModuleInstanceState(node); return moduleState === 1 || @@ -4261,7 +4378,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 219 && node.moduleReference.kind === 230; + return node.kind === 221 && node.moduleReference.kind === 232; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -4270,20 +4387,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 219 && node.moduleReference.kind !== 230; + return node.kind === 221 && node.moduleReference.kind !== 232; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 220) { + if (node.kind === 222) { return node.moduleSpecifier; } - if (node.kind === 219) { + if (node.kind === 221) { var reference = node.moduleReference; - if (reference.kind === 230) { + if (reference.kind === 232) { return reference.expression; } } - if (node.kind === 226) { + if (node.kind === 228) { return node.moduleSpecifier; } } @@ -4291,13 +4408,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 136: + case 138: + case 143: + case 142: + case 246: + case 245: case 141: case 140: - case 244: - case 243: - case 139: - case 138: return node.questionToken !== undefined; } } @@ -4305,9 +4422,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 259 && + return node.kind === 261 && node.parameters.length > 0 && - node.parameters[0].type.kind === 261; + node.parameters[0].type.kind === 263; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -4321,24 +4438,24 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 267); + return getJSDocTag(node, 269); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 266); + return getJSDocTag(node, 268); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 268); + return getJSDocTag(node, 270); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 67) { + if (parameter.name && parameter.name.kind === 69) { var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 265) { + if (t.kind === 267) { var parameterTag = t; var name_7 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_7.text === parameterName) { @@ -4357,12 +4474,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32) { - if (node.type && node.type.kind === 260) { + if (node.type && node.type.kind === 262) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 260; + return paramTag.typeExpression.type.kind === 262; } } return node.dotDotDotToken !== undefined; @@ -4383,7 +4500,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 160 || node.kind === 159); + return !!node && (node.kind === 162 || node.kind === 161); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -4398,34 +4515,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 172: - case 161: - case 212: - case 184: - case 142: + case 174: + case 163: + case 214: + case 186: + case 144: + case 217: + case 247: + case 230: + case 213: + case 173: + case 145: + case 223: + case 221: + case 226: case 215: - case 245: - case 228: - case 211: - case 171: case 143: - case 221: - case 219: + case 142: + case 218: case 224: - case 213: + case 138: + case 245: case 141: case 140: + case 146: + case 246: case 216: - case 222: - case 136: - case 243: - case 139: - case 138: - case 144: - case 244: - case 214: - case 135: - case 209: + case 137: + case 211: return true; } return false; @@ -4433,25 +4550,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 201: - case 200: - case 208: + case 203: + case 202: + case 210: + case 197: case 195: + case 194: + case 200: + case 201: + case 199: + case 196: + case 207: + case 204: + case 206: + case 98: + case 209: case 193: - case 192: case 198: - case 199: - case 197: - case 194: case 205: - case 202: - case 204: - case 96: - case 207: - case 191: - case 196: - case 203: - case 225: + case 227: return true; default: return false; @@ -4460,13 +4577,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 142: - case 139: + case 144: case 141: case 143: - case 144: - case 140: - case 147: + case 145: + case 146: + case 142: + case 149: return true; default: return false; @@ -4474,11 +4591,11 @@ var ts; } ts.isClassElement = isClassElement; function isDeclarationName(name) { - if (name.kind !== 67 && name.kind !== 9 && name.kind !== 8) { + if (name.kind !== 69 && name.kind !== 9 && name.kind !== 8) { return false; } var parent = name.parent; - if (parent.kind === 224 || parent.kind === 228) { + if (parent.kind === 226 || parent.kind === 230) { if (parent.propertyName) { return true; } @@ -4492,54 +4609,54 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 139: - case 138: case 141: case 140: case 143: - case 144: + case 142: + case 145: + case 146: + case 247: case 245: - case 243: - case 164: + case 166: return parent.name === node; - case 133: + case 135: if (parent.right === node) { - while (parent.kind === 133) { + while (parent.kind === 135) { parent = parent.parent; } - return parent.kind === 152; + return parent.kind === 154; } return false; - case 161: - case 224: + case 163: + case 226: return parent.propertyName === node; - case 228: + case 230: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 219 || - node.kind === 221 && !!node.name || - node.kind === 222 || + return node.kind === 221 || + node.kind === 223 && !!node.name || node.kind === 224 || - node.kind === 228 || - node.kind === 225 && node.expression.kind === 67; + node.kind === 226 || + node.kind === 230 || + node.kind === 227 && node.expression.kind === 69; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 81); + var heritageClause = getHeritageClause(node.heritageClauses, 83); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 104); + var heritageClause = getHeritageClause(node.heritageClauses, 106); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 81); + var heritageClause = getHeritageClause(node.heritageClauses, 83); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -4608,7 +4725,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 68 <= token && token <= 132; + return 70 <= token && token <= 134; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -4621,19 +4738,19 @@ var ts; ts.isAsyncFunctionLike = isAsyncFunctionLike; function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 134 && + declaration.name.kind === 136 && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; function isWellKnownSymbolSyntactically(node) { - return node.kind === 164 && isESSymbolIdentifier(node.expression); + return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 67 || name.kind === 9 || name.kind === 8) { + if (name.kind === 69 || name.kind === 9 || name.kind === 8) { return name.text; } - if (name.kind === 134) { + if (name.kind === 136) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -4648,21 +4765,21 @@ var ts; } ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function isESSymbolIdentifier(node) { - return node.kind === 67 && node.text === "Symbol"; + return node.kind === 69 && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 113: - case 116: - case 72: - case 120: - case 75: - case 80: + case 115: + case 118: + case 74: + case 122: + case 77: + case 82: + case 112: case 110: - case 108: - case 109: case 111: + case 113: return true; } return false; @@ -4670,28 +4787,28 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 136; + return root.kind === 138; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 161) { + while (node.kind === 163) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 216 || n.kind === 246; + return isFunctionLike(n) || n.kind === 218 || n.kind === 248; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function cloneEntityName(node) { - if (node.kind === 67) { - var clone_1 = createSynthesizedNode(67); + if (node.kind === 69) { + var clone_1 = createSynthesizedNode(69); clone_1.text = node.text; return clone_1; } else { - var clone_2 = createSynthesizedNode(133); + var clone_2 = createSynthesizedNode(135); clone_2.left = cloneEntityName(node.left); clone_2.left.parent = clone_2; clone_2.right = cloneEntityName(node.right); @@ -4934,7 +5051,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 142 && nodeIsPresent(member.body)) { + if (member.kind === 144 && nodeIsPresent(member.body)) { return member; } }); @@ -4961,10 +5078,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 143) { + if (accessor.kind === 145) { getAccessor = accessor; } - else if (accessor.kind === 144) { + else if (accessor.kind === 146) { setAccessor = accessor; } else { @@ -4973,7 +5090,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 143 || member.kind === 144) + if ((member.kind === 145 || member.kind === 146) && (member.flags & 128) === (accessor.flags & 128)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -4984,10 +5101,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 143 && !getAccessor) { + if (member.kind === 145 && !getAccessor) { getAccessor = member; } - if (member.kind === 144 && !setAccessor) { + if (member.kind === 146 && !setAccessor) { setAccessor = member; } } @@ -5093,16 +5210,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 111: return 128; - case 110: return 16; - case 109: return 64; - case 108: return 32; - case 113: return 256; - case 80: return 1; - case 120: return 2; - case 72: return 32768; - case 75: return 1024; - case 116: return 512; + case 113: return 128; + case 112: return 16; + case 111: return 64; + case 110: return 32; + case 115: return 256; + case 82: return 1; + case 122: return 2; + case 74: return 32768; + case 77: return 1024; + case 118: return 512; } return 0; } @@ -5110,29 +5227,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 164: - case 165: - case 167: case 166: - case 231: - case 232: + case 167: + case 169: case 168: - case 162: + case 233: + case 234: case 170: - case 163: - case 184: - case 171: - case 67: + case 164: + case 172: + case 165: + case 186: + case 173: + case 69: case 10: case 8: case 9: case 11: - case 181: - case 82: - case 91: - case 95: - case 97: + case 183: + case 84: case 93: + case 97: + case 99: + case 95: return true; } } @@ -5140,12 +5257,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 55 && token <= 66; + return token >= 56 && token <= 68; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 186 && - node.parent.token === 81 && + return node.kind === 188 && + node.parent.token === 83 && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -5154,10 +5271,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 67) { + if (node.kind === 69) { return true; } - else if (node.kind === 164) { + else if (isPropertyAccessExpression(node)) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -5165,16 +5282,16 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 133 && node.parent.right === node) || - (node.parent.kind === 164 && node.parent.name === node); + return (node.parent.kind === 135 && node.parent.right === node) || + (node.parent.kind === 166 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 163) { + if (kind === 165) { return expression.properties.length === 0; } - if (kind === 162) { + if (kind === 164) { return expression.elements.length === 0; } return false; @@ -5383,9 +5500,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 135) { + if (d && d.kind === 137) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 213) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 215) { return current; } } @@ -5393,11 +5510,9 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; })(ts || (ts = {})); -/// -/// var ts; (function (ts) { - var nodeConstructors = new Array(270); + var nodeConstructors = new Array(272); ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -5435,20 +5550,26 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 133: + case 135: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 135: + case 137: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 136: - case 139: + case 246: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.equalsToken) || + visitNode(cbNode, node.objectAssignmentInitializer); case 138: - case 243: - case 244: - case 209: - case 161: + case 141: + case 140: + case 245: + case 211: + case 163: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -5457,24 +5578,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 150: - case 151: - case 145: - case 146: + case 152: + case 153: case 147: + case 148: + case 149: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 141: - case 140: - case 142: case 143: + case 142: case 144: - case 171: - case 211: - case 172: + case 145: + case 146: + case 173: + case 213: + case 174: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -5485,290 +5606,290 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 149: + case 151: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 148: + case 150: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 152: - return visitNode(cbNode, node.exprName); - case 153: - return visitNodes(cbNodes, node.members); case 154: - return visitNode(cbNode, node.elementType); + return visitNode(cbNode, node.exprName); case 155: - return visitNodes(cbNodes, node.elementTypes); + return visitNodes(cbNodes, node.members); case 156: + return visitNode(cbNode, node.elementType); case 157: - return visitNodes(cbNodes, node.types); + return visitNodes(cbNodes, node.elementTypes); case 158: - return visitNode(cbNode, node.type); case 159: + return visitNodes(cbNodes, node.types); case 160: - return visitNodes(cbNodes, node.elements); + return visitNode(cbNode, node.type); + case 161: case 162: return visitNodes(cbNodes, node.elements); - case 163: - return visitNodes(cbNodes, node.properties); case 164: + return visitNodes(cbNodes, node.elements); + case 165: + return visitNodes(cbNodes, node.properties); + case 166: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 165: + case 167: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 166: - case 167: + case 168: + case 169: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 168: + case 170: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 169: + case 171: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 170: - return visitNode(cbNode, node.expression); - case 173: - return visitNode(cbNode, node.expression); - case 174: + case 172: return visitNode(cbNode, node.expression); case 175: return visitNode(cbNode, node.expression); + case 176: + return visitNode(cbNode, node.expression); case 177: + return visitNode(cbNode, node.expression); + case 179: return visitNode(cbNode, node.operand); - case 182: + case 184: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 176: - return visitNode(cbNode, node.expression); case 178: + return visitNode(cbNode, node.expression); + case 180: return visitNode(cbNode, node.operand); - case 179: + case 181: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 187: + case 189: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 180: + case 182: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 183: + case 185: return visitNode(cbNode, node.expression); - case 190: - case 217: + case 192: + case 219: return visitNodes(cbNodes, node.statements); - case 246: + case 248: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 191: + case 193: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 210: + case 212: return visitNodes(cbNodes, node.declarations); - case 193: + case 195: return visitNode(cbNode, node.expression); - case 194: + case 196: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 195: + case 197: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 196: + case 198: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 197: + case 199: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 198: + case 200: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 199: + case 201: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 200: - case 201: - return visitNode(cbNode, node.label); case 202: - return visitNode(cbNode, node.expression); case 203: + return visitNode(cbNode, node.label); + case 204: + return visitNode(cbNode, node.expression); + case 205: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 204: + case 206: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 218: + case 220: return visitNodes(cbNodes, node.clauses); - case 239: + case 241: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 240: + case 242: return visitNodes(cbNodes, node.statements); - case 205: + case 207: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 206: + case 208: return visitNode(cbNode, node.expression); - case 207: + case 209: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 242: + case 244: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 137: + case 139: return visitNode(cbNode, node.expression); - case 212: - case 184: + case 214: + case 186: 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 213: + case 215: 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 214: + case 216: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 215: + case 217: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 245: + case 247: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 216: + case 218: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 219: + case 221: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 220: + case 222: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 221: + case 223: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 222: + case 224: return visitNode(cbNode, node.name); - case 223: - case 227: + case 225: + case 229: return visitNodes(cbNodes, node.elements); - case 226: + case 228: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 224: - case 228: + case 226: + case 230: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 225: + case 227: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 181: + case 183: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 188: + case 190: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 134: + case 136: return visitNode(cbNode, node.expression); - case 241: + case 243: return visitNodes(cbNodes, node.types); - case 186: + case 188: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 230: + case 232: return visitNode(cbNode, node.expression); - case 229: - return visitNodes(cbNodes, node.decorators); case 231: + return visitNodes(cbNodes, node.decorators); + case 233: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 232: - case 233: + case 234: + case 235: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 236: + case 238: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 237: + case 239: return visitNode(cbNode, node.expression); - case 238: + case 240: return visitNode(cbNode, node.expression); - case 235: + case 237: return visitNode(cbNode, node.tagName); - case 247: + case 249: return visitNode(cbNode, node.type); - case 251: + case 253: return visitNodes(cbNodes, node.types); - case 252: + case 254: return visitNodes(cbNodes, node.types); - case 250: + case 252: return visitNode(cbNode, node.elementType); - case 254: - return visitNode(cbNode, node.type); - case 253: + case 256: return visitNode(cbNode, node.type); case 255: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.type); case 257: + return visitNodes(cbNodes, node.members); + case 259: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 258: + case 260: return visitNode(cbNode, node.type); - case 259: + case 261: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 260: + case 262: return visitNode(cbNode, node.type); - case 261: + case 263: return visitNode(cbNode, node.type); - case 262: + case 264: return visitNode(cbNode, node.type); - case 256: + case 258: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 263: - return visitNodes(cbNodes, node.tags); case 265: + return visitNodes(cbNodes, node.tags); + case 267: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 266: + case 268: return visitNode(cbNode, node.typeExpression); - case 267: + case 269: return visitNode(cbNode, node.typeExpression); - case 268: + case 270: return visitNodes(cbNodes, node.typeParameters); } } @@ -5864,9 +5985,9 @@ var ts; return; function visit(node) { switch (node.kind) { - case 191: - case 211: - case 136: + case 193: + case 213: + case 138: addJSDocComment(node); } forEachChild(node, visit); @@ -5885,10 +6006,6 @@ var ts; } } function fixupParentReferences(sourceFile) { - // normally parent references are set during binding. However, for clients that only need - // a syntax tree, and no semantic features, then the binding process is an unnecessary - // overhead. This functions allows us to set all the parents, without all the expense of - // binding. var parent = sourceFile; forEachChild(sourceFile, visitNode); return; @@ -5904,7 +6021,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(246, 0); + var sourceFile = createNode(248, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -6063,16 +6180,16 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token === 67) { + if (token === 69) { return true; } - if (token === 112 && inYieldContext()) { + if (token === 114 && inYieldContext()) { return false; } - if (token === 117 && inAwaitContext()) { + if (token === 119 && inAwaitContext()) { return false; } - return token > 103; + return token > 105; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -6168,24 +6285,24 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(67); - if (token !== 67) { + var node = createNode(69); + if (token !== 69) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(67, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(69, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); } function parseIdentifierName() { - return createIdentifier(isIdentifierOrKeyword()); + return createIdentifier(ts.tokenIsIdentifierOrKeyword(token)); } function isLiteralPropertyName() { - return isIdentifierOrKeyword() || + return ts.tokenIsIdentifierOrKeyword(token) || token === 9 || token === 8; } @@ -6205,10 +6322,10 @@ var ts; return parsePropertyNameWorker(false); } function isSimplePropertyName() { - return token === 9 || token === 8 || isIdentifierOrKeyword(); + return token === 9 || token === 8 || ts.tokenIsIdentifierOrKeyword(token); } function parseComputedPropertyName() { - var node = createNode(134); + var node = createNode(136); parseExpected(19); node.expression = allowInAnd(parseExpression); parseExpected(20); @@ -6218,20 +6335,27 @@ var ts; return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 72) { - return nextToken() === 79; + if (token === 74) { + return nextToken() === 81; } - if (token === 80) { + if (token === 82) { nextToken(); - if (token === 75) { + if (token === 77) { return lookAhead(nextTokenIsClassOrFunction); } return token !== 37 && token !== 15 && canFollowModifier(); } - if (token === 75) { + if (token === 77) { return nextTokenIsClassOrFunction(); } + if (token === 113) { + nextToken(); + return canFollowModifier(); + } nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return false; + } return canFollowModifier(); } function parseAnyContextualModifier() { @@ -6245,7 +6369,7 @@ var ts; } function nextTokenIsClassOrFunction() { nextToken(); - return token === 71 || token === 85; + return token === 73 || token === 87; } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -6258,7 +6382,7 @@ var ts; case 3: return !(token === 23 && inErrorRecovery) && isStartOfStatement(); case 2: - return token === 69 || token === 75; + return token === 71 || token === 77; case 4: return isStartOfTypeMember(); case 5: @@ -6296,9 +6420,9 @@ var ts; case 20: return isHeritageClause(); case 21: - return isIdentifierOrKeyword(); + return ts.tokenIsIdentifierOrKeyword(token); case 13: - return isIdentifierOrKeyword() || token === 15; + return ts.tokenIsIdentifierOrKeyword(token) || token === 15; case 14: return true; case 22: @@ -6314,7 +6438,7 @@ var ts; ts.Debug.assert(token === 15); if (nextToken() === 16) { var next = nextToken(); - return next === 24 || next === 15 || next === 81 || next === 104; + return next === 24 || next === 15 || next === 83 || next === 106; } return true; } @@ -6324,11 +6448,11 @@ var ts; } function nextTokenIsIdentifierOrKeyword() { nextToken(); - return isIdentifierOrKeyword(); + return ts.tokenIsIdentifierOrKeyword(token); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 104 || - token === 81) { + if (token === 106 || + token === 83) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -6352,13 +6476,13 @@ var ts; case 21: return token === 16; case 3: - return token === 16 || token === 69 || token === 75; + return token === 16 || token === 71 || token === 77; case 7: - return token === 15 || token === 81 || token === 104; + return token === 15 || token === 83 || token === 106; case 8: return isVariableDeclaratorListTerminator(); case 17: - return token === 27 || token === 17 || token === 15 || token === 81 || token === 104; + return token === 27 || token === 17 || token === 15 || token === 83 || token === 106; case 11: return token === 18 || token === 23; case 15: @@ -6372,11 +6496,11 @@ var ts; case 20: return token === 15 || token === 16; case 13: - return token === 27 || token === 38; + return token === 27 || token === 39; case 14: return token === 25 && lookAhead(nextTokenIsSlash); case 22: - return token === 18 || token === 53 || token === 16; + return token === 18 || token === 54 || token === 16; case 23: return token === 27 || token === 16; case 25: @@ -6497,17 +6621,17 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 142: - case 147: - case 143: case 144: - case 139: - case 189: - return true; + case 149: + case 145: + case 146: case 141: + case 191: + return true; + case 143: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 67 && - methodDeclaration.name.originalKeywordKind === 119; + var nameIsConstructor = methodDeclaration.name.kind === 69 && + methodDeclaration.name.originalKeywordKind === 121; return !nameIsConstructor; } } @@ -6516,8 +6640,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 239: - case 240: + case 241: + case 242: return true; } } @@ -6526,65 +6650,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 211: - case 191: - case 190: - case 194: + case 213: case 193: + case 192: + case 196: + case 195: + case 208: + case 204: case 206: + case 203: case 202: - case 204: - case 201: case 200: - case 198: + case 201: case 199: - case 197: - case 196: - case 203: - case 192: - case 207: + case 198: case 205: - case 195: - case 208: - case 220: - case 219: - case 226: - case 225: - case 216: - case 212: - case 213: - case 215: + case 194: + case 209: + case 207: + case 197: + case 210: + case 222: + case 221: + case 228: + case 227: + case 218: case 214: + case 215: + case 217: + case 216: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 245; + return node.kind === 247; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 146: + case 148: + case 142: + case 149: case 140: case 147: - case 138: - case 145: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 209) { + if (node.kind !== 211) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 136) { + if (node.kind !== 138) { return false; } var parameter = node; @@ -6684,7 +6808,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(21)) { - var node = createNode(133, entity.pos); + var node = createNode(135, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -6692,16 +6816,16 @@ var ts; return entity; } function parseRightSideOfDot(allowIdentifierNames) { - if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) { + if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(67, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(69, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(181); + var template = createNode(183); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); var templateSpans = []; @@ -6714,7 +6838,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(188); + var span = createNode(190); span.expression = allowInAnd(parseExpression); var literal; if (token === 16) { @@ -6749,14 +6873,14 @@ var ts; } function parseTypeReferenceOrTypePredicate() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 67 && token === 122 && !scanner.hasPrecedingLineBreak()) { + if (typeName.kind === 69 && token === 124 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(148, typeName.pos); + var node_1 = createNode(150, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(149, typeName.pos); + var node = createNode(151, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 25) { node.typeArguments = parseBracketedList(18, parseType, 25, 27); @@ -6764,15 +6888,15 @@ var ts; return finishNode(node); } function parseTypeQuery() { - var node = createNode(152); - parseExpected(99); + var node = createNode(154); + parseExpected(101); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(135); + var node = createNode(137); node.name = parseIdentifier(); - if (parseOptional(81)) { + if (parseOptional(83)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -6788,7 +6912,7 @@ var ts; } } function parseParameterType() { - if (parseOptional(53)) { + if (parseOptional(54)) { return token === 9 ? parseLiteralNode(true) : parseType(); @@ -6796,7 +6920,7 @@ var ts; return undefined; } function isStartOfParameter() { - return token === 22 || isIdentifierOrPattern() || ts.isModifier(token) || token === 54; + return token === 22 || isIdentifierOrPattern() || ts.isModifier(token) || token === 55; } function setModifiers(node, modifiers) { if (modifiers) { @@ -6805,7 +6929,7 @@ var ts; } } function parseParameter() { - var node = createNode(136); + var node = createNode(138); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(22); @@ -6813,7 +6937,7 @@ var ts; if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { nextToken(); } - node.questionToken = parseOptionalToken(52); + node.questionToken = parseOptionalToken(53); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(true); return finishNode(node); @@ -6860,10 +6984,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 146) { - parseExpected(90); + if (kind === 148) { + parseExpected(92); } - fillSignature(53, false, false, false, node); + fillSignature(54, false, false, false, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -6890,17 +7014,17 @@ var ts; else { nextToken(); } - if (token === 53 || token === 24) { + if (token === 54 || token === 24) { return true; } - if (token !== 52) { + if (token !== 53) { return false; } nextToken(); - return token === 53 || token === 24 || token === 20; + return token === 54 || token === 24 || token === 20; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(147, fullStart); + var node = createNode(149, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(16, parseParameter, 19, 20); @@ -6911,17 +7035,17 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(52); + var questionToken = parseOptionalToken(53); if (token === 17 || token === 25) { - var method = createNode(140, fullStart); + var method = createNode(142, fullStart); method.name = name; method.questionToken = questionToken; - fillSignature(53, false, false, false, method); + fillSignature(54, false, false, false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(138, fullStart); + var property = createNode(140, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -6955,22 +7079,22 @@ var ts; nextToken(); return token === 17 || token === 25 || - token === 52 || token === 53 || + token === 54 || canParseSemicolon(); } function parseTypeMember() { switch (token) { case 17: case 25: - return parseSignatureMember(145); + return parseSignatureMember(147); case 19: return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); - case 90: + case 92: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(146); + return parseSignatureMember(148); } case 9: case 8: @@ -6982,7 +7106,7 @@ var ts; return result; } } - if (isIdentifierOrKeyword()) { + if (ts.tokenIsIdentifierOrKeyword(token)) { return parsePropertyOrMethodSignature(); } } @@ -7000,7 +7124,7 @@ var ts; return token === 17 || token === 25; } function parseTypeLiteral() { - var node = createNode(153); + var node = createNode(155); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -7016,12 +7140,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(155); + var node = createNode(157); node.elementTypes = parseBracketedList(19, parseType, 19, 20); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(158); + var node = createNode(160); parseExpected(17); node.type = parseType(); parseExpected(18); @@ -7029,8 +7153,8 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 151) { - parseExpected(90); + if (kind === 153) { + parseExpected(92); } fillSignature(34, false, false, false, node); return finishNode(node); @@ -7041,16 +7165,17 @@ var ts; } function parseNonArrayType() { switch (token) { - case 115: + case 117: + case 130: case 128: - case 126: - case 118: - case 129: + case 120: + case 131: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 101: + case 103: + case 97: return parseTokenNode(); - case 99: + case 101: return parseTypeQuery(); case 15: return parseTypeLiteral(); @@ -7064,17 +7189,18 @@ var ts; } function isStartOfType() { switch (token) { - case 115: + case 117: + case 130: case 128: - case 126: - case 118: - case 129: + case 120: + case 131: + case 103: + case 97: case 101: - case 99: case 15: case 19: case 25: - case 90: + case 92: return true; case 17: return lookAhead(isStartOfParenthesizedOrFunctionType); @@ -7090,7 +7216,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { parseExpected(20); - var node = createNode(154, type.pos); + var node = createNode(156, type.pos); node.elementType = type; type = finishNode(node); } @@ -7112,10 +7238,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(157, parseArrayTypeOrHigher, 45); + return parseUnionOrIntersectionType(159, parseArrayTypeOrHigher, 46); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(156, parseIntersectionTypeOrHigher, 46); + return parseUnionOrIntersectionType(158, parseIntersectionTypeOrHigher, 47); } function isStartOfFunctionType() { if (token === 25) { @@ -7130,8 +7256,8 @@ var ts; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 53 || token === 24 || - token === 52 || token === 55 || + if (token === 54 || token === 24 || + token === 53 || token === 56 || isIdentifier() || ts.isModifier(token)) { return true; } @@ -7149,23 +7275,23 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(150); + return parseFunctionOrConstructorType(152); } - if (token === 90) { - return parseFunctionOrConstructorType(151); + if (token === 92) { + return parseFunctionOrConstructorType(153); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(53) ? parseType() : undefined; + return parseOptional(54) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token) { + case 97: case 95: case 93: - case 91: - case 97: - case 82: + case 99: + case 84: case 8: case 9: case 11: @@ -7173,12 +7299,12 @@ var ts; case 17: case 19: case 15: - case 85: - case 71: - case 90: - case 38: - case 59: - case 67: + case 87: + case 73: + case 92: + case 39: + case 61: + case 69: return true; default: return isIdentifier(); @@ -7191,16 +7317,16 @@ var ts; switch (token) { case 35: case 36: + case 50: case 49: - case 48: - case 76: - case 99: + case 78: case 101: - case 40: + case 103: case 41: + case 42: case 25: - case 117: - case 112: + case 119: + case 114: return true; default: if (isBinaryOperator()) { @@ -7211,18 +7337,15 @@ var ts; } function isStartOfExpressionStatement() { return token !== 15 && - token !== 85 && - token !== 71 && - token !== 54 && + token !== 87 && + token !== 73 && + token !== 55 && isStartOfExpression(); } function allowInAndParseExpression() { return allowInAnd(parseExpression); } function parseExpression() { - // Expression[in]: - // AssignmentExpression[in] - // Expression[in] , AssignmentExpression[in] var saveDecoratorContext = inDecoratorContext(); if (saveDecoratorContext) { setDecoratorContext(false); @@ -7238,24 +7361,15 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 55) { + if (token !== 56) { if (scanner.hasPrecedingLineBreak() || (inParameter && token === 15) || !isStartOfExpression()) { return undefined; } } - parseExpected(55); + parseExpected(56); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { - // AssignmentExpression[in,yield]: - // 1) ConditionalExpression[?in,?yield] - // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield] - // 3) LeftHandSideExpression AssignmentOperator AssignmentExpression[?in,?yield] - // 4) ArrowFunctionExpression[?in,?yield] - // 5) [+Yield] YieldExpression[?In] - // - // Note: for ease of implementation we treat productions '2' and '3' as the same thing. - // (i.e. they're both BinaryExpressions with an assignment operator in it). if (isYieldExpression()) { return parseYieldExpression(); } @@ -7264,7 +7378,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 67 && token === 34) { + if (expr.kind === 69 && token === 34) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -7273,7 +7387,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 112) { + if (token === 114) { if (inYieldContext()) { return true; } @@ -7286,7 +7400,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(182); + var node = createNode(184); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token === 37 || isStartOfExpression())) { @@ -7300,8 +7414,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(172, identifier.pos); - var parameter = createNode(136, identifier.pos); + var node = createNode(174, identifier.pos); + var parameter = createNode(138, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -7331,7 +7445,7 @@ var ts; return finishNode(arrowFunction); } function isParenthesizedArrowFunctionExpression() { - if (token === 17 || token === 25 || token === 116) { + if (token === 17 || token === 25 || token === 118) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } if (token === 34) { @@ -7340,7 +7454,7 @@ var ts; return 0; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 116) { + if (token === 118) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0; @@ -7356,7 +7470,7 @@ var ts; var third = nextToken(); switch (third) { case 34: - case 53: + case 54: case 15: return 1; default: @@ -7372,7 +7486,7 @@ var ts; if (!isIdentifier()) { return 0; } - if (nextToken() === 53) { + if (nextToken() === 54) { return 1; } return 2; @@ -7385,10 +7499,10 @@ var ts; if (sourceFile.languageVariant === 1) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 81) { + if (third === 83) { var fourth = nextToken(); switch (fourth) { - case 55: + case 56: case 27: return false; default: @@ -7412,10 +7526,10 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(172); + var node = createNode(174); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 512); - fillSignature(53, false, isAsync, !allowAmbiguity, node); + fillSignature(54, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; } @@ -7429,8 +7543,8 @@ var ts; return parseFunctionBlock(false, isAsync, false); } if (token !== 23 && - token !== 85 && - token !== 71 && + token !== 87 && + token !== 73 && isStartOfStatement() && !isStartOfExpressionStatement()) { return parseFunctionBlock(false, isAsync, true); @@ -7440,15 +7554,15 @@ var ts; : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(52); + var questionToken = parseOptionalToken(53); if (!questionToken) { return leftOperand; } - var node = createNode(180, leftOperand.pos); + var node = createNode(182, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(53, false, ts.Diagnostics._0_expected, ts.tokenToString(53)); + node.colonToken = parseExpectedToken(54, false, ts.Diagnostics._0_expected, ts.tokenToString(54)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -7457,19 +7571,22 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 88 || t === 132; + return t === 90 || t === 134; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { reScanGreaterToken(); var newPrecedence = getBinaryOperatorPrecedence(); - if (newPrecedence <= precedence) { + var consumeCurrentOperator = token === 38 ? + newPrecedence >= precedence : + newPrecedence > precedence; + if (!consumeCurrentOperator) { break; } - if (token === 88 && inDisallowInContext()) { + if (token === 90 && inDisallowInContext()) { break; } - if (token === 114) { + if (token === 116) { if (scanner.hasPrecedingLineBreak()) { break; } @@ -7485,22 +7602,22 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 88) { + if (inDisallowInContext() && token === 90) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 51: + case 52: return 1; - case 50: + case 51: return 2; - case 46: - return 3; case 47: + return 3; + case 48: return 4; - case 45: + case 46: return 5; case 30: case 31: @@ -7511,64 +7628,66 @@ var ts; case 27: case 28: case 29: - case 89: - case 88: - case 114: + case 91: + case 90: + case 116: return 7; - case 42: case 43: case 44: + case 45: return 8; case 35: case 36: return 9; case 37: - case 38: case 39: + case 40: return 10; + case 38: + return 11; } return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(179, left.pos); + var node = createNode(181, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(187, left.pos); + var node = createNode(189, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(177); + var node = createNode(179); node.operator = token; nextToken(); - node.operand = parseUnaryExpressionOrHigher(); + node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(173); + var node = createNode(175); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(174); + var node = createNode(176); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(175); + var node = createNode(177); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token === 117) { + if (token === 119) { if (inAwaitContext()) { return true; } @@ -7577,45 +7696,87 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(176); + var node = createNode(178); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseUnaryExpressionOrHigher() { if (isAwaitExpression()) { return parseAwaitExpression(); } + if (isIncrementExpression()) { + var incrementExpression = parseIncrementExpression(); + return token === 38 ? + parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : + incrementExpression; + } + var unaryOperator = token; + var simpleUnaryExpression = parseSimpleUnaryExpression(); + if (token === 38) { + var diagnostic; + var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); + if (simpleUnaryExpression.kind === 171) { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); + } + else { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses, ts.tokenToString(unaryOperator)); + } + } + return simpleUnaryExpression; + } + function parseSimpleUnaryExpression() { switch (token) { case 35: case 36: + case 50: case 49: - case 48: - case 40: - case 41: return parsePrefixUnaryExpression(); - case 76: + case 78: return parseDeleteExpression(); - case 99: - return parseTypeOfExpression(); case 101: + return parseTypeOfExpression(); + case 103: return parseVoidExpression(); + case 25: + return parseTypeAssertion(); + default: + return parseIncrementExpression(); + } + } + function isIncrementExpression() { + switch (token) { + case 35: + case 36: + case 50: + case 49: + case 78: + case 101: + case 103: + return false; case 25: if (sourceFile.languageVariant !== 1) { - return parseTypeAssertion(); - } - if (lookAhead(nextTokenIsIdentifierOrKeyword)) { - return parseJsxElementOrSelfClosingElement(true); + return false; } default: - return parsePostfixExpressionOrHigher(); + return true; } } - function parsePostfixExpressionOrHigher() { + function parseIncrementExpression() { + if (token === 41 || token === 42) { + var node = createNode(179); + node.operator = token; + nextToken(); + node.operand = parseLeftHandSideExpressionOrHigher(); + return finishNode(node); + } + else if (sourceFile.languageVariant === 1 && token === 25 && lookAhead(nextTokenIsIdentifierOrKeyword)) { + return parseJsxElementOrSelfClosingElement(true); + } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 40 || token === 41) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(178, expression.pos); + if ((token === 41 || token === 42) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(180, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -7624,7 +7785,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token === 93 + var expression = token === 95 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -7638,7 +7799,7 @@ var ts; if (token === 17 || token === 21 || token === 19) { return expression; } - var node = createNode(164, expression.pos); + var node = createNode(166, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); @@ -7646,26 +7807,26 @@ var ts; } function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); - if (opening.kind === 233) { - var node = createNode(231, opening.pos); + if (opening.kind === 235) { + var node = createNode(233, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); return finishNode(node); } else { - ts.Debug.assert(opening.kind === 232); + ts.Debug.assert(opening.kind === 234); return opening; } } function parseJsxText() { - var node = createNode(234, scanner.getStartPos()); + var node = createNode(236, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 234: + case 236: return parseJsxText(); case 15: return parseJsxExpression(false); @@ -7701,11 +7862,11 @@ var ts; var attributes = parseList(13, parseJsxAttribute); var node; if (token === 27) { - node = createNode(233, fullStart); + node = createNode(235, fullStart); scanJsxText(); } else { - parseExpected(38); + parseExpected(39); if (inExpressionContext) { parseExpected(27); } @@ -7713,7 +7874,7 @@ var ts; parseExpected(27, undefined, false); scanJsxText(); } - node = createNode(232, fullStart); + node = createNode(234, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -7724,7 +7885,7 @@ var ts; var elementName = parseIdentifierName(); while (parseOptional(21)) { scanJsxIdentifier(); - var node = createNode(133, elementName.pos); + var node = createNode(135, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); @@ -7732,7 +7893,7 @@ var ts; return elementName; } function parseJsxExpression(inExpressionContext) { - var node = createNode(238); + var node = createNode(240); parseExpected(15); if (token !== 16) { node.expression = parseExpression(); @@ -7751,9 +7912,9 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(236); + var node = createNode(238); node.name = parseIdentifierName(); - if (parseOptional(55)) { + if (parseOptional(56)) { switch (token) { case 9: node.initializer = parseLiteralNode(); @@ -7766,7 +7927,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(237); + var node = createNode(239); parseExpected(15); parseExpected(22); node.expression = parseExpression(); @@ -7774,7 +7935,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(235); + var node = createNode(237); parseExpected(26); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -7787,18 +7948,18 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(169); + var node = createNode(171); parseExpected(25); node.type = parseType(); parseExpected(27); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { var dotToken = parseOptionalToken(21); if (dotToken) { - var propertyAccess = createNode(164, expression.pos); + var propertyAccess = createNode(166, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); @@ -7806,7 +7967,7 @@ var ts; continue; } if (!inDecoratorContext() && parseOptional(19)) { - var indexedAccess = createNode(165, expression.pos); + var indexedAccess = createNode(167, expression.pos); indexedAccess.expression = expression; if (token !== 20) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -7820,7 +7981,7 @@ var ts; continue; } if (token === 11 || token === 12) { - var tagExpression = createNode(168, expression.pos); + var tagExpression = createNode(170, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 11 ? parseLiteralNode() @@ -7839,7 +8000,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(166, expression.pos); + var callExpr = createNode(168, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -7847,7 +8008,7 @@ var ts; continue; } else if (token === 17) { - var callExpr = createNode(166, expression.pos); + var callExpr = createNode(168, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -7880,18 +8041,18 @@ var ts; case 21: case 18: case 20: - case 53: + case 54: case 23: - case 52: + case 53: case 30: case 32: case 31: case 33: - case 50: case 51: - case 47: - case 45: + case 52: + case 48: case 46: + case 47: case 16: case 1: return true; @@ -7907,11 +8068,11 @@ var ts; case 9: case 11: return parseLiteralNode(); + case 97: case 95: case 93: - case 91: - case 97: - case 82: + case 99: + case 84: return parseTokenNode(); case 17: return parseParenthesizedExpression(); @@ -7919,19 +8080,19 @@ var ts; return parseArrayLiteralExpression(); case 15: return parseObjectLiteralExpression(); - case 116: + case 118: if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } return parseFunctionExpression(); - case 71: + case 73: return parseClassExpression(); - case 85: + case 87: return parseFunctionExpression(); - case 90: + case 92: return parseNewExpression(); - case 38: - case 59: + case 39: + case 61: if (reScanSlashToken() === 10) { return parseLiteralNode(); } @@ -7942,28 +8103,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(170); + var node = createNode(172); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); return finishNode(node); } function parseSpreadElement() { - var node = createNode(183); + var node = createNode(185); parseExpected(22); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 22 ? parseSpreadElement() : - token === 24 ? createNode(185) : + token === 24 ? createNode(187) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(162); + var node = createNode(164); parseExpected(19); if (scanner.hasPrecedingLineBreak()) node.flags |= 2048; @@ -7972,11 +8133,11 @@ var ts; return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(121)) { - return parseAccessorDeclaration(143, fullStart, decorators, modifiers); + if (parseContextualModifier(123)) { + return parseAccessorDeclaration(145, fullStart, decorators, modifiers); } - else if (parseContextualModifier(127)) { - return parseAccessorDeclaration(144, fullStart, decorators, modifiers); + else if (parseContextualModifier(129)) { + return parseAccessorDeclaration(146, fullStart, decorators, modifiers); } return undefined; } @@ -7992,27 +8153,33 @@ var ts; var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); - var questionToken = parseOptionalToken(52); + var questionToken = parseOptionalToken(53); if (asteriskToken || token === 17 || token === 25) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } - if ((token === 24 || token === 16) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(244, fullStart); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 || token === 16 || token === 56); + if (isShorthandPropertyAssignment) { + var shorthandDeclaration = createNode(246, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; + var equalsToken = parseOptionalToken(56); + if (equalsToken) { + shorthandDeclaration.equalsToken = equalsToken; + shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); + } return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(243, fullStart); + var propertyAssignment = createNode(245, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(53); + parseExpected(54); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(163); + var node = createNode(165); parseExpected(15); if (scanner.hasPrecedingLineBreak()) { node.flags |= 2048; @@ -8026,9 +8193,9 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(171); + var node = createNode(173); setModifiers(node, parseModifiers()); - parseExpected(85); + parseExpected(87); node.asteriskToken = parseOptionalToken(37); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512); @@ -8037,7 +8204,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(53, isGenerator, isAsync, false, node); + fillSignature(54, isGenerator, isAsync, false, node); node.body = parseFunctionBlock(isGenerator, isAsync, false); if (saveDecoratorContext) { setDecoratorContext(true); @@ -8048,8 +8215,8 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(167); - parseExpected(90); + var node = createNode(169); + parseExpected(92); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token === 17) { @@ -8058,7 +8225,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(190); + var node = createNode(192); if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1, parseStatement); parseExpected(16); @@ -8086,25 +8253,25 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(192); + var node = createNode(194); parseExpected(23); return finishNode(node); } function parseIfStatement() { - var node = createNode(194); - parseExpected(86); + var node = createNode(196); + parseExpected(88); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(78) ? parseStatement() : undefined; + node.elseStatement = parseOptional(80) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(195); - parseExpected(77); + var node = createNode(197); + parseExpected(79); node.statement = parseStatement(); - parseExpected(102); + parseExpected(104); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); @@ -8112,8 +8279,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(196); - parseExpected(102); + var node = createNode(198); + parseExpected(104); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); @@ -8122,11 +8289,11 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(84); + parseExpected(86); parseExpected(17); var initializer = undefined; if (token !== 23) { - if (token === 100 || token === 106 || token === 72) { + if (token === 102 || token === 108 || token === 74) { initializer = parseVariableDeclarationList(true); } else { @@ -8134,22 +8301,22 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(88)) { - var forInStatement = createNode(198, pos); + if (parseOptional(90)) { + var forInStatement = createNode(200, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(18); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(132)) { - var forOfStatement = createNode(199, pos); + else if (parseOptional(134)) { + var forOfStatement = createNode(201, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(18); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(197, pos); + var forStatement = createNode(199, pos); forStatement.initializer = initializer; parseExpected(23); if (token !== 23 && token !== 18) { @@ -8167,7 +8334,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 201 ? 68 : 73); + parseExpected(kind === 203 ? 70 : 75); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -8175,8 +8342,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(202); - parseExpected(92); + var node = createNode(204); + parseExpected(94); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -8184,8 +8351,8 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(203); - parseExpected(103); + var node = createNode(205); + parseExpected(105); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); @@ -8193,30 +8360,30 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(239); - parseExpected(69); + var node = createNode(241); + parseExpected(71); node.expression = allowInAnd(parseExpression); - parseExpected(53); + parseExpected(54); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(240); - parseExpected(75); - parseExpected(53); + var node = createNode(242); + parseExpected(77); + parseExpected(54); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 69 ? parseCaseClause() : parseDefaultClause(); + return token === 71 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(204); - parseExpected(94); + var node = createNode(206); + parseExpected(96); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); - var caseBlock = createNode(218, scanner.getStartPos()); + var caseBlock = createNode(220, scanner.getStartPos()); parseExpected(15); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(16); @@ -8224,28 +8391,26 @@ var ts; return finishNode(node); } function parseThrowStatement() { - // ThrowStatement[Yield] : - // throw [no LineTerminator here]Expression[In, ?Yield]; - var node = createNode(206); - parseExpected(96); + var node = createNode(208); + parseExpected(98); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(207); - parseExpected(98); + var node = createNode(209); + parseExpected(100); node.tryBlock = parseBlock(false); - node.catchClause = token === 70 ? parseCatchClause() : undefined; - if (!node.catchClause || token === 83) { - parseExpected(83); + node.catchClause = token === 72 ? parseCatchClause() : undefined; + if (!node.catchClause || token === 85) { + parseExpected(85); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(242); - parseExpected(70); + var result = createNode(244); + parseExpected(72); if (parseExpected(17)) { result.variableDeclaration = parseVariableDeclaration(); } @@ -8254,80 +8419,77 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(208); - parseExpected(74); + var node = createNode(210); + parseExpected(76); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 67 && parseOptional(53)) { - var labeledStatement = createNode(205, fullStart); + if (expression.kind === 69 && parseOptional(54)) { + var labeledStatement = createNode(207, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(193, fullStart); + var expressionStatement = createNode(195, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); } } - function isIdentifierOrKeyword() { - return token >= 67; - } function nextTokenIsIdentifierOrKeywordOnSameLine() { nextToken(); - return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); + return ts.tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token === 85 && !scanner.hasPrecedingLineBreak(); + return token === 87 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); - return (isIdentifierOrKeyword() || token === 8) && !scanner.hasPrecedingLineBreak(); + return (ts.tokenIsIdentifierOrKeyword(token) || token === 8) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token) { - case 100: - case 106: - case 72: - case 85: - case 71: - case 79: + case 102: + case 108: + case 74: + case 87: + case 73: + case 81: return true; - case 105: - case 130: + case 107: + case 132: return nextTokenIsIdentifierOnSameLine(); - case 123: - case 124: + case 125: + case 126: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 116: - case 120: + case 115: + case 118: + case 122: + case 110: + case 111: + case 112: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 87: + case 89: nextToken(); return token === 9 || token === 37 || - token === 15 || isIdentifierOrKeyword(); - case 80: + token === 15 || ts.tokenIsIdentifierOrKeyword(token); + case 82: nextToken(); - if (token === 55 || token === 37 || - token === 15 || token === 75) { + if (token === 56 || token === 37 || + token === 15 || token === 77) { return true; } continue; - case 110: - case 108: - case 109: - case 111: case 113: nextToken(); continue; @@ -8341,44 +8503,44 @@ var ts; } function isStartOfStatement() { switch (token) { - case 54: + case 55: case 23: case 15: - case 100: - case 106: - case 85: - case 71: - case 79: - case 86: - case 77: case 102: - case 84: + case 108: + case 87: case 73: - case 68: - case 92: - case 103: + case 81: + case 88: + case 79: + case 104: + case 86: + case 75: + case 70: case 94: + case 105: case 96: case 98: - case 74: - case 70: - case 83: - return true; + case 100: + case 76: case 72: - case 80: - case 87: + case 85: + return true; + case 74: + case 82: + case 89: return isStartOfDeclaration(); - case 116: - case 120: - case 105: - case 123: - case 124: - case 130: + case 118: + case 122: + case 107: + case 125: + case 126: + case 132: return true; + case 112: case 110: - case 108: - case 109: case 111: + case 113: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -8397,60 +8559,60 @@ var ts; return parseEmptyStatement(); case 15: return parseBlock(false); - case 100: + case 102: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 106: + case 108: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } break; - case 85: + case 87: return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 71: + case 73: return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); - case 86: + case 88: return parseIfStatement(); - case 77: + case 79: return parseDoStatement(); - case 102: + case 104: return parseWhileStatement(); - case 84: + case 86: return parseForOrForInOrForOfStatement(); - case 73: - return parseBreakOrContinueStatement(200); - case 68: - return parseBreakOrContinueStatement(201); - case 92: + case 75: + return parseBreakOrContinueStatement(202); + case 70: + return parseBreakOrContinueStatement(203); + case 94: return parseReturnStatement(); - case 103: + case 105: return parseWithStatement(); - case 94: - return parseSwitchStatement(); case 96: - return parseThrowStatement(); + return parseSwitchStatement(); case 98: - case 70: - case 83: + return parseThrowStatement(); + case 100: + case 72: + case 85: return parseTryStatement(); - case 74: + case 76: return parseDebuggerStatement(); - case 54: + case 55: return parseDeclaration(); - case 116: - case 105: - case 130: - case 123: - case 124: - case 120: - case 72: - case 79: - case 80: - case 87: - case 108: - case 109: + case 118: + case 107: + case 132: + case 125: + case 126: + case 122: + case 74: + case 81: + case 82: + case 89: case 110: - case 113: case 111: + case 112: + case 115: + case 113: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -8463,33 +8625,33 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 100: - case 106: - case 72: + case 102: + case 108: + case 74: return parseVariableStatement(fullStart, decorators, modifiers); - case 85: + case 87: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 71: + case 73: return parseClassDeclaration(fullStart, decorators, modifiers); - case 105: + case 107: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 130: + case 132: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 79: + case 81: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 123: - case 124: + case 125: + case 126: return parseModuleDeclaration(fullStart, decorators, modifiers); - case 87: + case 89: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 80: + case 82: nextToken(); - return token === 75 || token === 55 ? + return token === 77 || token === 56 ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { - var node = createMissingNode(229, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(231, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -8510,23 +8672,23 @@ var ts; } function parseArrayBindingElement() { if (token === 24) { - return createNode(185); + return createNode(187); } - var node = createNode(161); + var node = createNode(163); node.dotDotDotToken = parseOptionalToken(22); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(161); + var node = createNode(163); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 53) { + if (tokenIsIdentifier && token !== 54) { node.name = propertyName; } else { - parseExpected(53); + parseExpected(54); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -8534,14 +8696,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(159); + var node = createNode(161); parseExpected(15); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(16); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(160); + var node = createNode(162); parseExpected(19); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(20); @@ -8560,7 +8722,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(209); + var node = createNode(211); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -8569,21 +8731,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(210); + var node = createNode(212); switch (token) { - case 100: + case 102: break; - case 106: + case 108: node.flags |= 16384; break; - case 72: + case 74: node.flags |= 32768; break; default: ts.Debug.fail(); } nextToken(); - if (token === 132 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 134 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -8598,7 +8760,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 18; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(191, fullStart); + var node = createNode(193, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -8606,29 +8768,29 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(211, fullStart); + var node = createNode(213, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(85); + parseExpected(87); node.asteriskToken = parseOptionalToken(37); node.name = node.flags & 1024 ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512); - fillSignature(53, isGenerator, isAsync, false, node); + fillSignature(54, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(142, pos); + var node = createNode(144, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(119); - fillSignature(53, false, false, false, node); + parseExpected(121); + fillSignature(54, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(141, fullStart); + var method = createNode(143, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -8636,12 +8798,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = !!(method.flags & 512); - fillSignature(53, isGenerator, isAsync, false, method); + fillSignature(54, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(139, fullStart); + var property = createNode(141, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -8656,7 +8818,7 @@ var ts; function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { var asteriskToken = parseOptionalToken(37); var name = parsePropertyName(); - var questionToken = parseOptionalToken(52); + var questionToken = parseOptionalToken(53); if (asteriskToken || token === 17 || token === 25) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } @@ -8672,16 +8834,16 @@ var ts; node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(53, false, false, false, node); + fillSignature(54, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { + case 112: case 110: - case 108: - case 109: case 111: + case 113: return true; default: return false; @@ -8689,7 +8851,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 54) { + if (token === 55) { return true; } while (ts.isModifier(token)) { @@ -8710,15 +8872,15 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 127 || idToken === 121) { + if (!ts.isKeyword(idToken) || idToken === 129 || idToken === 123) { return true; } switch (token) { case 17: case 25: + case 54: + case 56: case 53: - case 55: - case 52: return true; default: return canParseSemicolon(); @@ -8730,14 +8892,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(54)) { + if (!parseOptional(55)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(137, decoratorStart); + var decorator = createNode(139, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -8771,7 +8933,7 @@ var ts; function parseModifiersForArrowFunction() { var flags = 0; var modifiers; - if (token === 116) { + if (token === 118) { var modifierStart = scanner.getStartPos(); var modifierKind = token; nextToken(); @@ -8786,7 +8948,7 @@ var ts; } function parseClassElement() { if (token === 23) { - var result = createNode(189); + var result = createNode(191); nextToken(); return finishNode(result); } @@ -8797,13 +8959,13 @@ var ts; if (accessor) { return accessor; } - if (token === 119) { + if (token === 121) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { return parseIndexSignatureDeclaration(fullStart, decorators, modifiers); } - if (isIdentifierOrKeyword() || + if (ts.tokenIsIdentifierOrKeyword(token) || token === 9 || token === 8 || token === 37 || @@ -8811,23 +8973,23 @@ var ts; return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_8 = createMissingNode(67, true, ts.Diagnostics.Declaration_expected); + var name_8 = createMissingNode(69, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_8, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 184); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 186); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 212); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 214); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(71); - node.name = parseOptionalIdentifier(); + parseExpected(73); + node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(true); if (parseExpected(15)) { @@ -8839,9 +9001,15 @@ var ts; } return finishNode(node); } + function parseNameOfClassDeclarationOrExpression() { + return isIdentifier() && !isImplementsClause() + ? parseIdentifier() + : undefined; + } + function isImplementsClause() { + return token === 106 && lookAhead(nextTokenIsIdentifierOrKeyword); + } function parseHeritageClauses(isClassHeritageClause) { - // ClassTail[Yield,Await] : (Modified) See 14.5 - // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { return parseList(20, parseHeritageClause); } @@ -8851,8 +9019,8 @@ var ts; return parseList(20, parseHeritageClause); } function parseHeritageClause() { - if (token === 81 || token === 104) { - var node = createNode(241); + if (token === 83 || token === 106) { + var node = createNode(243); node.token = token; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -8861,7 +9029,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(186); + var node = createNode(188); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 25) { node.typeArguments = parseBracketedList(18, parseType, 25, 27); @@ -8869,16 +9037,16 @@ var ts; return finishNode(node); } function isHeritageClause() { - return token === 81 || token === 104; + return token === 83 || token === 106; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213, fullStart); + var node = createNode(215, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(105); + parseExpected(107); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(false); @@ -8886,28 +9054,28 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(214, fullStart); + var node = createNode(216, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(130); + parseExpected(132); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(55); + parseExpected(56); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNode(245, scanner.getStartPos()); + var node = createNode(247, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215, fullStart); + var node = createNode(217, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(79); + parseExpected(81); node.name = parseIdentifier(); if (parseExpected(15)) { node.members = parseDelimitedList(6, parseEnumMember); @@ -8919,7 +9087,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(217, scanner.getStartPos()); + var node = createNode(219, scanner.getStartPos()); if (parseExpected(15)) { node.statements = parseList(1, parseStatement); parseExpected(16); @@ -8930,18 +9098,19 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(216, fullStart); + var node = createNode(218, fullStart); + var namespaceFlag = flags & 131072; node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(21) - ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1) + ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 | namespaceFlag) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216, fullStart); + var node = createNode(218, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -8950,11 +9119,11 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(124)) { + if (parseOptional(126)) { flags |= 131072; } else { - parseExpected(123); + parseExpected(125); if (token === 9) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -8962,64 +9131,58 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 125 && + return token === 127 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 17; } function nextTokenIsSlash() { - return nextToken() === 38; + return nextToken() === 39; } function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 24 || - token === 131; + token === 133; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(87); + parseExpected(89); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 24 && token !== 131) { - var importEqualsDeclaration = createNode(219, fullStart); + if (token !== 24 && token !== 133) { + var importEqualsDeclaration = createNode(221, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(55); + parseExpected(56); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(220, fullStart); + var importDeclaration = createNode(222, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || token === 37 || token === 15) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(131); + parseExpected(133); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - // ImportClause: - // ImportedDefaultBinding - // NameSpaceImport - // NamedImports - // ImportedDefaultBinding, NameSpaceImport - // ImportedDefaultBinding, NamedImports - var importClause = createNode(221, fullStart); + var importClause = createNode(223, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(24)) { - importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(223); + importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(225); } return finishNode(importClause); } @@ -9029,8 +9192,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(230); - parseExpected(125); + var node = createNode(232); + parseExpected(127); parseExpected(17); node.expression = parseModuleSpecifier(); parseExpected(18); @@ -9044,22 +9207,22 @@ var ts; return result; } function parseNamespaceImport() { - var namespaceImport = createNode(222); + var namespaceImport = createNode(224); parseExpected(37); - parseExpected(114); + parseExpected(116); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 223 ? parseImportSpecifier : parseExportSpecifier, 15, 16); + node.elements = parseBracketedList(21, kind === 225 ? parseImportSpecifier : parseExportSpecifier, 15, 16); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(228); + return parseImportOrExportSpecifier(230); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(224); + return parseImportOrExportSpecifier(226); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -9067,9 +9230,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 114) { + if (token === 116) { node.propertyName = identifierName; - parseExpected(114); + parseExpected(116); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -9078,23 +9241,23 @@ var ts; else { node.name = identifierName; } - if (kind === 224 && checkIdentifierIsKeyword) { + if (kind === 226 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(226, fullStart); + var node = createNode(228, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(37)) { - parseExpected(131); + parseExpected(133); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(227); - if (token === 131 || (token === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(131); + node.exportClause = parseNamedImportsOrExports(229); + if (token === 133 || (token === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(133); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -9102,14 +9265,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(227, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(55)) { + if (parseOptional(56)) { node.isExportEquals = true; } else { - parseExpected(75); + parseExpected(77); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -9172,10 +9335,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 - || node.kind === 219 && node.moduleReference.kind === 230 - || node.kind === 220 - || node.kind === 225 - || node.kind === 226 + || node.kind === 221 && node.moduleReference.kind === 232 + || node.kind === 222 + || node.kind === 227 + || node.kind === 228 ? node : undefined; }); @@ -9185,18 +9348,18 @@ var ts; function isJSDocType() { switch (token) { case 37: - case 52: + case 53: case 17: case 19: - case 48: + case 49: case 15: - case 85: + case 87: case 22: - case 90: - case 95: + case 92: + case 97: return true; } - return isIdentifierOrKeyword(); + return ts.tokenIsIdentifierOrKeyword(token); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { @@ -9210,7 +9373,7 @@ var ts; function parseJSDocTypeExpression(start, length) { scanner.setText(sourceText, start, length); token = nextToken(); - var result = createNode(247); + var result = createNode(249); parseExpected(15); result.type = parseJSDocTopLevelType(); parseExpected(16); @@ -9220,13 +9383,13 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 46) { - var unionType = createNode(251, type.pos); + if (token === 47) { + var unionType = createNode(253, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 55) { - var optionalType = createNode(258, type.pos); + if (token === 56) { + var optionalType = createNode(260, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -9237,20 +9400,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 19) { - var arrayType = createNode(250, type.pos); + var arrayType = createNode(252, type.pos); arrayType.elementType = type; nextToken(); parseExpected(20); type = finishNode(arrayType); } - else if (token === 52) { - var nullableType = createNode(253, type.pos); + else if (token === 53) { + var nullableType = createNode(255, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 48) { - var nonNullableType = createNode(254, type.pos); + else if (token === 49) { + var nonNullableType = createNode(256, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -9265,80 +9428,80 @@ var ts; switch (token) { case 37: return parseJSDocAllType(); - case 52: + case 53: return parseJSDocUnknownOrNullableType(); case 17: return parseJSDocUnionType(); case 19: return parseJSDocTupleType(); - case 48: + case 49: return parseJSDocNonNullableType(); case 15: return parseJSDocRecordType(); - case 85: + case 87: return parseJSDocFunctionType(); case 22: return parseJSDocVariadicType(); - case 90: + case 92: return parseJSDocConstructorType(); - case 95: + case 97: return parseJSDocThisType(); - case 115: + case 117: + case 130: case 128: - case 126: - case 118: - case 129: - case 101: + case 120: + case 131: + case 103: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(262); + var result = createNode(264); nextToken(); - parseExpected(53); + parseExpected(54); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(261); + var result = createNode(263); nextToken(); - parseExpected(53); + parseExpected(54); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(260); + var result = createNode(262); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(259); + var result = createNode(261); nextToken(); parseExpected(17); result.parameters = parseDelimitedList(22, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(18); - if (token === 53) { + if (token === 54) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(136); + var parameter = createNode(138); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(258, type.pos); + var result = createNode(260, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(257); + var result = createNode(259); result.name = parseSimplePropertyName(); while (parseOptional(21)) { if (token === 25) { @@ -9367,13 +9530,13 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(133, left.pos); + var result = createNode(135, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(255); + var result = createNode(257); nextToken(); result.members = parseDelimitedList(24, parseJSDocRecordMember); checkForTrailingComma(result.members); @@ -9381,22 +9544,22 @@ var ts; return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(256); + var result = createNode(258); result.name = parseSimplePropertyName(); - if (token === 53) { + if (token === 54) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(254); + var result = createNode(256); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(252); + var result = createNode(254); nextToken(); result.types = parseDelimitedList(25, parseJSDocType); checkForTrailingComma(result.types); @@ -9410,7 +9573,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(251); + var result = createNode(253); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(18); @@ -9421,14 +9584,14 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(46)) { + while (parseOptional(47)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(248); + var result = createNode(250); nextToken(); return finishNode(result); } @@ -9439,13 +9602,13 @@ var ts; token === 16 || token === 18 || token === 27 || - token === 55 || - token === 46) { - var result = createNode(249, pos); + token === 56 || + token === 47) { + var result = createNode(251, pos); return finishNode(result); } else { - var result = createNode(253, pos); + var result = createNode(255, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -9516,7 +9679,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(263, start); + var result = createNode(265, start); result.tags = tags; return finishNode(result, end); } @@ -9527,7 +9690,7 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64); - var atToken = createNode(54, pos - 1); + var atToken = createNode(55, pos - 1); atToken.end = pos; var tagName = scanIdentifier(); if (!tagName) { @@ -9553,7 +9716,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(264, atToken.pos); + var result = createNode(266, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -9604,7 +9767,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(265, atToken.pos); + var result = createNode(267, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -9614,27 +9777,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 266; })) { + if (ts.forEach(tags, function (t) { return t.kind === 268; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(266, atToken.pos); + var result = createNode(268, 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 === 267; })) { + if (ts.forEach(tags, function (t) { return t.kind === 269; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(267, atToken.pos); + var result = createNode(269, 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 === 268; })) { + if (ts.forEach(tags, function (t) { return t.kind === 270; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -9647,7 +9810,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(135, name_9.pos); + var typeParameter = createNode(137, name_9.pos); typeParameter.name = name_9; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -9658,7 +9821,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(268, atToken.pos); + var result = createNode(270, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -9679,7 +9842,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(67, startPos); + var result = createNode(69, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -9755,7 +9918,7 @@ var ts; switch (node.kind) { case 9: case 8: - case 67: + case 69: return true; } return false; @@ -9969,21 +10132,20 @@ var ts; } })(IncrementalParser || (IncrementalParser = {})); })(ts || (ts = {})); -/// var ts; (function (ts) { ts.bindTime = 0; function getModuleInstanceState(node) { - if (node.kind === 213 || node.kind === 214) { + if (node.kind === 215 || node.kind === 216) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 220 || node.kind === 219) && !(node.flags & 1)) { + else if ((node.kind === 222 || node.kind === 221) && !(node.flags & 1)) { return 0; } - else if (node.kind === 217) { + else if (node.kind === 219) { var state = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -9999,7 +10161,7 @@ var ts; }); return state; } - else if (node.kind === 216) { + else if (node.kind === 218) { return getModuleInstanceState(node.body); } else { @@ -10018,6 +10180,7 @@ var ts; var container; var blockScopeContainer; var lastContainer; + var seenThisKeyword; var inStrictMode = !!file.externalModuleIndicator; var symbolCount = 0; var Symbol = ts.objectAllocator.getSymbolConstructor(); @@ -10051,10 +10214,10 @@ var ts; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 216 && node.name.kind === 9) { + if (node.kind === 218 && node.name.kind === 9) { return "\"" + node.name.text + "\""; } - if (node.name.kind === 134) { + if (node.name.kind === 136) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -10062,22 +10225,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 142: + case 144: return "__constructor"; - case 150: - case 145: + case 152: + case 147: return "__call"; - case 151: - case 146: + case 153: + case 148: return "__new"; - case 147: + case 149: return "__index"; - case 226: + case 228: return "__export"; - case 225: + case 227: return node.isExportEquals ? "export=" : "default"; - case 211: - case 212: + case 213: + case 214: return node.flags & 1024 ? "default" : undefined; } } @@ -10086,7 +10249,8 @@ var ts; } function declareSymbol(symbolTable, parent, node, includes, excludes) { ts.Debug.assert(!ts.hasDynamicName(node)); - var name = node.flags & 1024 && parent ? "default" : getDeclarationName(node); + var isDefaultExport = node.flags & 1024; + var name = isDefaultExport && parent ? "default" : getDeclarationName(node); var symbol; if (name !== undefined) { symbol = ts.hasProperty(symbolTable, name) @@ -10102,6 +10266,11 @@ var ts; var message = symbol.flags & 2 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; + ts.forEach(symbol.declarations, function (declaration) { + if (declaration.flags & 1024) { + message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; + } + }); ts.forEach(symbol.declarations, function (declaration) { file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); }); @@ -10119,7 +10288,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 228 || (node.kind === 219 && hasExportModifier)) { + if (node.kind === 230 || (node.kind === 221 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -10158,44 +10327,51 @@ var ts; blockScopeContainer = node; blockScopeContainer.locals = undefined; } - ts.forEachChild(node, bind); + if (node.kind === 215) { + seenThisKeyword = false; + ts.forEachChild(node, bind); + node.flags = seenThisKeyword ? node.flags | 524288 : node.flags & ~524288; + } + else { + ts.forEachChild(node, bind); + } container = saveContainer; parent = saveParent; blockScopeContainer = savedBlockScopeContainer; } function getContainerFlags(node) { switch (node.kind) { - case 184: - case 212: - case 213: + case 186: + case 214: case 215: - case 153: - case 163: + case 217: + case 155: + case 165: return 1; - case 145: - case 146: case 147: - case 141: - case 140: - case 211: - case 142: + case 148: + case 149: case 143: + case 142: + case 213: case 144: - case 150: - case 151: - case 171: - case 172: + case 145: + case 146: + case 152: + case 153: + case 173: + case 174: + case 218: + case 248: case 216: - case 246: - case 214: return 5; - case 242: - case 197: - case 198: + case 244: case 199: - case 218: + case 200: + case 201: + case 220: return 2; - case 190: + case 192: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -10211,33 +10387,33 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 216: + case 218: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 246: + case 248: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 184: - case 212: + case 186: + case 214: return declareClassMember(node, symbolFlags, symbolExcludes); - case 215: + case 217: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 153: - case 163: - case 213: + case 155: + case 165: + case 215: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 150: - case 151: - case 145: - case 146: + case 152: + case 153: case 147: - case 141: - case 140: - case 142: + case 148: + case 149: case 143: + case 142: case 144: - case 211: - case 171: - case 172: - case 214: + case 145: + case 146: + case 213: + case 173: + case 174: + case 216: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -10261,11 +10437,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 246 ? node : node.body; - if (body.kind === 246 || body.kind === 217) { + var body = node.kind === 248 ? node : node.body; + if (body.kind === 248 || body.kind === 219) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 226 || stat.kind === 225) { + if (stat.kind === 228 || stat.kind === 227) { return true; } } @@ -10320,11 +10496,11 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 67) { + if (prop.name.kind !== 69) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 243 || prop.kind === 244 || prop.kind === 141 + var currentKind = prop.kind === 245 || prop.kind === 246 || prop.kind === 143 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -10346,10 +10522,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 216: + case 218: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 246: + case 248: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -10367,8 +10543,8 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 104 && - node.originalKeywordKind <= 112 && + node.originalKeywordKind >= 106 && + node.originalKeywordKind <= 114 && !ts.isIdentifierName(node)) { if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -10395,17 +10571,17 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 67) { + if (inStrictMode && node.expression.kind === 69) { 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 === 67 && + return node.kind === 69 && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 67) { + if (name && name.kind === 69) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span = ts.getErrorSpanForNode(file, name); @@ -10439,7 +10615,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 40 || node.operator === 41) { + if (node.operator === 41 || node.operator === 42) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -10468,17 +10644,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 246: - case 217: + case 248: + case 219: updateStrictModeStatementList(node.statements); return; - case 190: + case 192: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 212: - case 184: + case 214: + case 186: inStrictMode = true; return; } @@ -10501,88 +10677,91 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 67: + case 69: return checkStrictModeIdentifier(node); - case 179: + case 181: return checkStrictModeBinaryExpression(node); - case 242: + case 244: return checkStrictModeCatchClause(node); - case 173: + case 175: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 178: + case 180: return checkStrictModePostfixUnaryExpression(node); - case 177: + case 179: return checkStrictModePrefixUnaryExpression(node); - case 203: + case 205: return checkStrictModeWithStatement(node); - case 135: + case 97: + seenThisKeyword = true; + return; + case 137: return declareSymbolAndAddToSymbolTable(node, 262144, 530912); - case 136: + case 138: return bindParameter(node); - case 209: - case 161: + case 211: + case 163: return bindVariableDeclarationOrBindingElement(node); - case 139: - case 138: + case 141: + case 140: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); - case 243: - case 244: - return bindPropertyOrMethodOrAccessor(node, 4, 107455); case 245: + case 246: + return bindPropertyOrMethodOrAccessor(node, 4, 107455); + case 247: return bindPropertyOrMethodOrAccessor(node, 8, 107455); - case 145: - case 146: case 147: + case 148: + case 149: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 141: - case 140: + case 143: + case 142: return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); - case 211: + case 213: checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16, 106927); - case 142: + case 144: return declareSymbolAndAddToSymbolTable(node, 16384, 0); - case 143: + case 145: return bindPropertyOrMethodOrAccessor(node, 32768, 41919); - case 144: + case 146: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 150: - case 151: - return bindFunctionOrConstructorType(node); + case 152: case 153: + return bindFunctionOrConstructorType(node); + case 155: return bindAnonymousDeclaration(node, 2048, "__type"); - case 163: + case 165: return bindObjectLiteralExpression(node); - case 171: - case 172: + case 173: + case 174: checkStrictModeFunctionName(node); var bindingName = node.name ? node.name.text : "__function"; return bindAnonymousDeclaration(node, 16, bindingName); - case 184: - case 212: + case 186: + case 214: return bindClassLikeDeclaration(node); - case 213: + case 215: return bindBlockScopedDeclaration(node, 64, 792960); - case 214: + case 216: return bindBlockScopedDeclaration(node, 524288, 793056); - case 215: + case 217: return bindEnumDeclaration(node); - case 216: + case 218: return bindModuleDeclaration(node); - case 219: - case 222: + case 221: case 224: - case 228: + case 226: + case 230: return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 221: + case 223: return bindImportClause(node); - case 226: + case 228: return bindExportDeclaration(node); - case 225: + case 227: return bindExportAssignment(node); - case 246: + case 248: return bindSourceFileIfExternalModule(); } } @@ -10596,7 +10775,7 @@ var ts; if (!container.symbol || !container.symbol.exports) { bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } - else if (node.expression.kind === 67) { + else if (node.expression.kind === 69) { declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); } else { @@ -10617,7 +10796,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 212) { + if (node.kind === 214) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -10670,7 +10849,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 1, 107455); } if (node.flags & 112 && - node.parent.kind === 142 && + node.parent.kind === 144 && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); @@ -10683,7 +10862,6 @@ var ts; } } })(ts || (ts = {})); -/// var ts; (function (ts) { var nextSymbolId = 1; @@ -10709,17 +10887,19 @@ var ts; var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); var typeCount = 0; + var symbolCount = 0; var emptyArray = []; var emptySymbols = {}; var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 ? 5 : 0; var emitResolver = createResolver(); var undefinedSymbol = createSymbol(4 | 67108864, "undefined"); var argumentsSymbol = createSymbol(4 | 67108864, "arguments"); var checker = { getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, - getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount"); }, + getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, getTypeCount: function () { return typeCount; }, isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, @@ -10865,6 +11045,7 @@ var ts; diagnostics.add(diagnostic); } function createSymbol(flags, name) { + symbolCount++; return new Symbol(flags, name); } function getExcludedSymbolFlags(flags) { @@ -10993,10 +11174,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 246); + return ts.getAncestor(node, 248); } function isGlobalSourceFile(node) { - return node.kind === 246 && !ts.isExternalModule(node); + return node.kind === 248 && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -11013,17 +11194,54 @@ var ts; } } } - function isDefinedBefore(node1, node2) { - var file1 = ts.getSourceFileOfNode(node1); - var file2 = ts.getSourceFileOfNode(node2); - if (file1 === file2) { - return node1.pos <= node2.pos; + function isBlockScopedNameDeclaredBeforeUse(declaration, usage) { + var declarationFile = ts.getSourceFileOfNode(declaration); + var useFile = ts.getSourceFileOfNode(usage); + if (declarationFile !== useFile) { + if (modulekind || (!compilerOptions.outFile && !compilerOptions.out)) { + return true; + } + var sourceFiles = host.getSourceFiles(); + return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } - if (!compilerOptions.outFile && !compilerOptions.out) { - return true; + if (declaration.pos <= usage.pos) { + return declaration.kind !== 211 || + !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + return isUsedInFunctionOrNonStaticProperty(declaration, usage); + function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + if (declaration.parent.parent.kind === 193 || + declaration.parent.parent.kind === 199) { + return isSameScopeDescendentOf(usage, declaration, container); + } + else if (declaration.parent.parent.kind === 201 || + declaration.parent.parent.kind === 200) { + var expression = declaration.parent.parent.expression; + return isSameScopeDescendentOf(usage, expression, container); + } + } + function isUsedInFunctionOrNonStaticProperty(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + var current = usage; + while (current) { + if (current === container) { + return false; + } + if (ts.isFunctionLike(current)) { + return true; + } + var initializerOfNonStaticProperty = current.parent && + current.parent.kind === 141 && + (current.parent.flags & 128) === 0 && + current.parent.initializer === current; + if (initializerOfNonStaticProperty) { + return true; + } + current = current.parent; + } + return false; } - var sourceFiles = host.getSourceFiles(); - return sourceFiles.indexOf(file1) <= sourceFiles.indexOf(file2); } function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { var result; @@ -11044,16 +11262,16 @@ var ts; } } switch (location.kind) { - case 246: + case 248: if (!ts.isExternalModule(location)) break; - case 216: + case 218: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 246 || - (location.kind === 216 && location.name.kind === 9)) { + if (location.kind === 248 || + (location.kind === 218 && location.name.kind === 9)) { if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 228)) { + ts.getDeclarationOfKind(moduleExports[name], 230)) { break; } result = moduleExports["default"]; @@ -11067,13 +11285,13 @@ var ts; break loop; } break; - case 215: + case 217: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; - case 139: - case 138: + case 141: + case 140: if (ts.isClassLike(location.parent) && !(location.flags & 128)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -11083,9 +11301,9 @@ var ts; } } break; - case 212: - case 184: - case 213: + case 214: + case 186: + case 215: 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); @@ -11093,7 +11311,7 @@ var ts; } break loop; } - if (location.kind === 184 && meaning & 32) { + if (location.kind === 186 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -11101,28 +11319,28 @@ var ts; } } break; - case 134: + case 136: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 213) { + if (ts.isClassLike(grandparent) || grandparent.kind === 215) { 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 141: - case 140: - case 142: case 143: + case 142: case 144: - case 211: - case 172: + case 145: + case 146: + case 213: + case 174: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 171: + case 173: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -11135,8 +11353,8 @@ var ts; } } break; - case 137: - if (location.parent && location.parent.kind === 136) { + case 139: + if (location.parent && location.parent.kind === 138) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -11162,8 +11380,11 @@ var ts; error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); return undefined; } - if (meaning & 2 && result.flags & 2) { - checkResolvedBlockScopedVariable(result, errorLocation); + if (meaning & 2) { + var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); + if (exportOrLocalSymbol.flags & 2) { + checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); + } } } return result; @@ -11172,21 +11393,7 @@ var ts; ts.Debug.assert((result.flags & 2) !== 0); var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); - if (!isUsedBeforeDeclaration) { - var variableDeclaration = ts.getAncestor(declaration, 209); - var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 191 || - variableDeclaration.parent.parent.kind === 197) { - isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); - } - else if (variableDeclaration.parent.parent.kind === 199 || - variableDeclaration.parent.parent.kind === 198) { - var expression = variableDeclaration.parent.parent.expression; - isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); - } - } - if (isUsedBeforeDeclaration) { + if (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 211), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -11203,10 +11410,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 219) { + if (node.kind === 221) { return node; } - while (node && node.kind !== 220) { + while (node && node.kind !== 222) { node = node.parent; } return node; @@ -11216,7 +11423,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 230) { + if (node.moduleReference.kind === 232) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -11305,17 +11512,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 219: - return getTargetOfImportEqualsDeclaration(node); case 221: + return getTargetOfImportEqualsDeclaration(node); + case 223: return getTargetOfImportClause(node); - case 222: - return getTargetOfNamespaceImport(node); case 224: + return getTargetOfNamespaceImport(node); + case 226: return getTargetOfImportSpecifier(node); - case 228: + case 230: return getTargetOfExportSpecifier(node); - case 225: + case 227: return getTargetOfExportAssignment(node); } } @@ -11357,10 +11564,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 225) { + if (node.kind === 227) { checkExpressionCached(node.expression); } - else if (node.kind === 228) { + else if (node.kind === 230) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -11370,17 +11577,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 219); + importDeclaration = ts.getAncestor(entityName, 221); ts.Debug.assert(importDeclaration !== undefined); } - if (entityName.kind === 67 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 69 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 67 || entityName.parent.kind === 133) { + if (entityName.kind === 69 || entityName.parent.kind === 135) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 219); + ts.Debug.assert(entityName.parent.kind === 221); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -11392,16 +11599,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 67) { + if (name.kind === 69) { var message = meaning === 1536 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 133 || name.kind === 164) { - var left = name.kind === 133 ? name.left : name.expression; - var right = name.kind === 133 ? name.right : name.name; + else if (name.kind === 135 || name.kind === 166) { + var left = name.kind === 135 ? name.left : name.expression; + var right = name.kind === 135 ? name.right : name.name; var namespace = resolveEntityName(left, 1536, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -11420,9 +11627,6 @@ var ts; ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); return symbol.flags & meaning ? symbol : resolveAlias(symbol); } - function isExternalModuleNameRelative(moduleName) { - return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; - } function resolveExternalModuleName(location, moduleReferenceExpression) { if (moduleReferenceExpression.kind !== 9) { return; @@ -11430,10 +11634,10 @@ var ts; var moduleReferenceLiteral = moduleReferenceExpression; var searchPath = ts.getDirectoryPath(getSourceFile(location).fileName); var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); - if (!moduleName) { + if (moduleName === undefined) { return; } - var isRelative = isExternalModuleNameRelative(moduleName); + var isRelative = ts.isExternalModuleNameRelative(moduleName); if (!isRelative) { var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512); if (symbol) { @@ -11537,7 +11741,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 142 && ts.nodeIsPresent(member.body)) { + if (member.kind === 144 && ts.nodeIsPresent(member.body)) { return member; } } @@ -11602,17 +11806,17 @@ var ts; } } switch (location_1.kind) { - case 246: + case 248: if (!ts.isExternalModule(location_1)) { break; } - case 216: + case 218: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 212: - case 213: + case 214: + case 215: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -11645,7 +11849,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -11674,7 +11878,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -11729,8 +11933,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 216 && declaration.name.kind === 9) || - (declaration.kind === 246 && ts.isExternalModule(declaration)); + return (declaration.kind === 218 && declaration.name.kind === 9) || + (declaration.kind === 248 && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -11762,11 +11966,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 152) { + if (entityName.parent.kind === 154) { meaning = 107455 | 1048576; } - else if (entityName.kind === 133 || entityName.kind === 164 || - entityName.parent.kind === 219) { + else if (entityName.kind === 135 || entityName.kind === 166 || + entityName.parent.kind === 221) { meaning = 1536; } else { @@ -11817,10 +12021,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 158) { + while (node.kind === 160) { node = node.parent; } - if (node.kind === 214) { + if (node.kind === 216) { return getSymbolOfNode(node); } } @@ -11834,10 +12038,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 184: + case 186: return "(Anonymous class)"; - case 171: - case 172: + case 173: + case 174: return "(Anonymous function)"; } } @@ -11898,6 +12102,7 @@ var ts; } function buildTypeDisplay(type, writer, enclosingDeclaration, globalFlags, symbolStack) { var globalFlagsToPass = globalFlags & 16; + var inObjectTypeLiteral = false; return writeType(type, globalFlags); function writeType(type, flags) { if (type.flags & 16777343) { @@ -11905,6 +12110,12 @@ var ts; ? "any" : type.intrinsicName); } + else if (type.flags & 33554432) { + if (inObjectTypeLiteral) { + writer.reportInaccessibleThisError(); + } + writer.writeKeyword("this"); + } else if (type.flags & 4096) { writeTypeReference(type, flags); } @@ -11943,9 +12154,9 @@ var ts; writeType(types[i], delimiter === 24 ? 0 : 64); } } - function writeSymbolTypeReference(symbol, typeArguments, pos, end) { - if (!isReservedMemberName(symbol.name)) { - buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056); + function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { + if (symbol.flags & 32 || !isReservedMemberName(symbol.name)) { + buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056, 0, flags); } if (pos < end) { writePunctuation(writer, 25); @@ -11959,7 +12170,7 @@ var ts; } } function writeTypeReference(type, flags) { - var typeArguments = type.typeArguments; + var typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & 1)) { writeType(typeArguments[0], 64); writePunctuation(writer, 19); @@ -11977,12 +12188,13 @@ var ts; i++; } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_3); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_3, typeArguments, start, i); + writeSymbolTypeReference(parent_3, typeArguments, start, i, flags); writePunctuation(writer, 21); } } } - writeSymbolTypeReference(type.symbol, typeArguments, i, typeArguments.length); + var typeParameterCount = (type.target.typeParameters || emptyArray).length; + writeSymbolTypeReference(type.symbol, typeArguments, i, typeParameterCount, flags); } } function writeTupleType(type) { @@ -11994,7 +12206,7 @@ var ts; if (flags & 64) { writePunctuation(writer, 17); } - writeTypeList(type.types, type.flags & 16384 ? 46 : 45); + writeTypeList(type.types, type.flags & 16384 ? 47 : 46); if (flags & 64) { writePunctuation(writer, 18); } @@ -12014,7 +12226,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056, 0, flags); } else { - writeKeyword(writer, 115); + writeKeyword(writer, 117); } } else { @@ -12035,7 +12247,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 246 || declaration.parent.kind === 217; + return declaration.parent.kind === 248 || declaration.parent.kind === 219; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -12044,7 +12256,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 99); + writeKeyword(writer, 101); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } @@ -12078,7 +12290,7 @@ var ts; if (flags & 64) { writePunctuation(writer, 17); } - writeKeyword(writer, 90); + writeKeyword(writer, 92); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); if (flags & 64) { @@ -12087,6 +12299,8 @@ var ts; return; } } + var saveInObjectTypeLiteral = inObjectTypeLiteral; + inObjectTypeLiteral = true; writePunctuation(writer, 15); writer.writeLine(); writer.increaseIndent(); @@ -12098,7 +12312,7 @@ var ts; } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 90); + writeKeyword(writer, 92); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 23); @@ -12107,11 +12321,11 @@ var ts; if (resolved.stringIndexType) { writePunctuation(writer, 19); writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); - writeKeyword(writer, 128); + writeKeyword(writer, 130); writePunctuation(writer, 20); - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); writeType(resolved.stringIndexType, 0); writePunctuation(writer, 23); @@ -12120,11 +12334,11 @@ var ts; if (resolved.numberIndexType) { writePunctuation(writer, 19); writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); - writeKeyword(writer, 126); + writeKeyword(writer, 128); writePunctuation(writer, 20); - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); writeType(resolved.numberIndexType, 0); writePunctuation(writer, 23); @@ -12139,7 +12353,7 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 52); + writePunctuation(writer, 53); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 23); @@ -12149,9 +12363,9 @@ var ts; else { buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 52); + writePunctuation(writer, 53); } - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); writeType(t, 0); writePunctuation(writer, 23); @@ -12160,6 +12374,7 @@ var ts; } writer.decreaseIndent(); writePunctuation(writer, 16); + inObjectTypeLiteral = saveInObjectTypeLiteral; } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { @@ -12173,7 +12388,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 81); + writeKeyword(writer, 83); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -12185,9 +12400,9 @@ var ts; } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 52); + writePunctuation(writer, 53); } - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } @@ -12234,14 +12449,14 @@ var ts; writePunctuation(writer, 34); } else { - writePunctuation(writer, 53); + writePunctuation(writer, 54); } writeSpace(writer); var returnType; if (signature.typePredicate) { writer.writeParameter(signature.typePredicate.parameterName); writeSpace(writer); - writeKeyword(writer, 122); + writeKeyword(writer, 124); writeSpace(writer); returnType = signature.typePredicate.type; } @@ -12275,12 +12490,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 216) { + if (node.kind === 218) { if (node.name.kind === 9) { return node; } } - else if (node.kind === 246) { + else if (node.kind === 248) { return ts.isExternalModule(node) ? node : undefined; } } @@ -12323,59 +12538,59 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 161: + case 163: return isDeclarationVisible(node.parent.parent); - case 209: + case 211: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 216: - case 212: - case 213: + case 218: case 214: - case 211: case 215: - case 219: + case 216: + case 213: + case 217: + case 221: var parent_4 = getDeclarationContainer(node); if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 219 && parent_4.kind !== 246 && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 221 && parent_4.kind !== 248 && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } return isDeclarationVisible(parent_4); - case 139: - case 138: - case 143: - case 144: case 141: case 140: + case 145: + case 146: + case 143: + case 142: if (node.flags & (32 | 64)) { return false; } - case 142: - case 146: - case 145: + case 144: + case 148: case 147: - case 136: - case 217: - case 150: - case 151: - case 153: case 149: - case 154: + case 138: + case 219: + case 152: + case 153: case 155: + case 151: case 156: case 157: case 158: + case 159: + case 160: return isDeclarationVisible(node.parent); - case 221: - case 222: + case 223: case 224: + case 226: return false; - case 135: - case 246: + case 137: + case 248: return true; - case 225: + case 227: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -12391,10 +12606,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 225) { + if (node.parent && node.parent.kind === 227) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 228) { + else if (node.parent.kind === 230) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -12469,7 +12684,7 @@ var ts; } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); - return node.kind === 209 ? node.parent.parent.parent : node.parent; + return node.kind === 211 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); @@ -12482,9 +12697,13 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1) !== 0; } + function getTypeForBindingElementParent(node) { + var symbol = getSymbolOfNode(node); + return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node); + } function getTypeForBindingElement(declaration) { var pattern = declaration.parent; - var parentType = getTypeForVariableLikeDeclaration(pattern.parent); + var parentType = getTypeForBindingElementParent(pattern.parent); if (parentType === unknownType) { return unknownType; } @@ -12495,7 +12714,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 159) { + if (pattern.kind === 161) { var name_11 = declaration.propertyName || declaration.name; type = getTypeOfPropertyOfType(parentType, name_11.text) || isNumericLiteralName(name_11.text) && getIndexTypeOfType(parentType, 1) || @@ -12529,10 +12748,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 198) { + if (declaration.parent.parent.kind === 200) { return anyType; } - if (declaration.parent.parent.kind === 199) { + if (declaration.parent.parent.kind === 201) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -12541,10 +12760,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 136) { + if (declaration.kind === 138) { var func = declaration.parent; - if (func.kind === 144 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 143); + if (func.kind === 146 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 145); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -12557,56 +12776,56 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 244) { + if (declaration.kind === 246) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name); + return getTypeFromBindingPattern(declaration.name, false); } return undefined; } - function getTypeFromBindingElement(element) { + function getTypeFromBindingElement(element, includePatternInType) { if (element.initializer) { return getWidenedType(checkExpressionCached(element.initializer)); } if (ts.isBindingPattern(element.name)) { - return getTypeFromBindingPattern(element.name); + return getTypeFromBindingPattern(element.name, includePatternInType); } return anyType; } - function getTypeFromObjectBindingPattern(pattern) { + function getTypeFromObjectBindingPattern(pattern, includePatternInType) { var members = {}; ts.forEach(pattern.elements, function (e) { var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0); var name = e.propertyName || e.name; var symbol = createSymbol(flags, name.text); - symbol.type = getTypeFromBindingElement(e); + symbol.type = getTypeFromBindingElement(e, includePatternInType); + symbol.bindingElement = e; members[symbol.name] = symbol; }); - return createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + if (includePatternInType) { + result.pattern = pattern; + } + return result; } - function getTypeFromArrayBindingPattern(pattern) { - var hasSpreadElement = false; - var elementTypes = []; - ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 185 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); - if (e.dotDotDotToken) { - hasSpreadElement = true; - } - }); - if (!elementTypes.length) { + function getTypeFromArrayBindingPattern(pattern, includePatternInType) { + var elements = pattern.elements; + if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType; } - else if (hasSpreadElement) { - var unionOfElements = getUnionType(elementTypes); - return languageVersion >= 2 ? createIterableType(unionOfElements) : createArrayType(unionOfElements); + var elementTypes = ts.map(elements, function (e) { return e.kind === 187 ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + if (includePatternInType) { + var result = createNewTupleType(elementTypes); + result.pattern = pattern; + return result; } return createTupleType(elementTypes); } - function getTypeFromBindingPattern(pattern) { - return pattern.kind === 159 - ? getTypeFromObjectBindingPattern(pattern) - : getTypeFromArrayBindingPattern(pattern); + function getTypeFromBindingPattern(pattern, includePatternInType) { + return pattern.kind === 161 + ? getTypeFromObjectBindingPattern(pattern, includePatternInType) + : getTypeFromArrayBindingPattern(pattern, includePatternInType); } function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { var type = getTypeForVariableLikeDeclaration(declaration); @@ -12614,12 +12833,12 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - return declaration.kind !== 243 ? getWidenedType(type) : type; + return declaration.kind !== 245 ? getWidenedType(type) : type; } type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 136 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 138 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -12632,10 +12851,10 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 242) { + if (declaration.parent.kind === 244) { return links.type = anyType; } - if (declaration.kind === 225) { + if (declaration.kind === 227) { return links.type = checkExpression(declaration.expression); } if (!pushTypeResolution(symbol, 0)) { @@ -12660,7 +12879,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 143) { + if (accessor.kind === 145) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -12676,8 +12895,8 @@ var ts; if (!pushTypeResolution(symbol, 0)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 143); - var setter = ts.getDeclarationOfKind(symbol, 144); + var getter = ts.getDeclarationOfKind(symbol, 145); + var setter = ts.getDeclarationOfKind(symbol, 146); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -12703,7 +12922,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 143); + var getter_1 = ts.getDeclarationOfKind(symbol, 145); 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)); } } @@ -12792,9 +13011,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 212 || node.kind === 184 || - node.kind === 211 || node.kind === 171 || - node.kind === 141 || node.kind === 172) { + if (node.kind === 214 || node.kind === 186 || + node.kind === 213 || node.kind === 173 || + node.kind === 143 || node.kind === 174) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -12803,15 +13022,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 213); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 215); return appendOuterTypeParameters(undefined, declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 213 || node.kind === 212 || - node.kind === 184 || node.kind === 214) { + if (node.kind === 215 || node.kind === 214 || + node.kind === 186 || node.kind === 216) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -12916,7 +13135,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 213 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 215 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -12937,6 +13156,29 @@ var ts; } } } + function isIndependentInterface(symbol) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 215) { + if (declaration.flags & 524288) { + return false; + } + var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); + if (baseTypeNodes) { + for (var _b = 0; _b < baseTypeNodes.length; _b++) { + var node = baseTypeNodes[_b]; + if (ts.isSupportedExpressionWithTypeArguments(node)) { + var baseSymbol = resolveEntityName(node.expression, 793056, true); + if (!baseSymbol || !(baseSymbol.flags & 64) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { + return false; + } + } + } + } + } + } + return true; + } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { @@ -12944,7 +13186,7 @@ var ts; var type = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - if (outerTypeParameters || localTypeParameters) { + if (outerTypeParameters || localTypeParameters || kind === 1024 || !isIndependentInterface(symbol)) { type.flags |= 4096; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; @@ -12953,6 +13195,9 @@ var ts; type.instantiations[getTypeListId(type.typeParameters)] = type; type.target = type; type.typeArguments = type.typeParameters; + type.thisType = createType(512 | 33554432); + type.thisType.symbol = symbol; + type.thisType.constraint = getTypeWithThisArgument(type); } } return links.declaredType; @@ -12963,7 +13208,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 214); + var declaration = ts.getDeclarationOfKind(symbol, 216); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -12994,7 +13239,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 135).constraint) { + if (!ts.getDeclarationOfKind(symbol, 137).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -13027,6 +13272,66 @@ var ts; } return unknownType; } + function isIndependentTypeReference(node) { + if (node.typeArguments) { + for (var _i = 0, _a = node.typeArguments; _i < _a.length; _i++) { + var typeNode = _a[_i]; + if (!isIndependentType(typeNode)) { + return false; + } + } + } + return true; + } + function isIndependentType(node) { + switch (node.kind) { + case 117: + case 130: + case 128: + case 120: + case 131: + case 103: + case 9: + return true; + case 156: + return isIndependentType(node.elementType); + case 151: + return isIndependentTypeReference(node); + } + return false; + } + function isIndependentVariableLikeDeclaration(node) { + return node.type && isIndependentType(node.type) || !node.type && !node.initializer; + } + function isIndependentFunctionLikeDeclaration(node) { + if (node.kind !== 144 && (!node.type || !isIndependentType(node.type))) { + return false; + } + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + if (!isIndependentVariableLikeDeclaration(parameter)) { + return false; + } + } + return true; + } + function isIndependentMember(symbol) { + if (symbol.declarations && symbol.declarations.length === 1) { + var declaration = symbol.declarations[0]; + if (declaration) { + switch (declaration.kind) { + case 141: + case 140: + return isIndependentVariableLikeDeclaration(declaration); + case 143: + case 142: + case 144: + return isIndependentFunctionLikeDeclaration(declaration); + } + } + } + return false; + } function createSymbolTable(symbols) { var result = {}; for (var _i = 0; _i < symbols.length; _i++) { @@ -13035,11 +13340,11 @@ var ts; } return result; } - function createInstantiatedSymbolTable(symbols, mapper) { + function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { var result = {}; for (var _i = 0; _i < symbols.length; _i++) { var symbol = symbols[_i]; - result[symbol.name] = instantiateSymbol(symbol, mapper); + result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); } return result; } @@ -13070,44 +13375,54 @@ var ts; } return type; } - function resolveClassOrInterfaceMembers(type) { - var target = resolveDeclaredMembers(type); - var members = target.symbol.members; - var callSignatures = target.declaredCallSignatures; - var constructSignatures = target.declaredConstructSignatures; - var stringIndexType = target.declaredStringIndexType; - var numberIndexType = target.declaredNumberIndexType; - var baseTypes = getBaseTypes(target); + function getTypeWithThisArgument(type, thisArgument) { + if (type.flags & 4096) { + return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); + } + return type; + } + function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) { + var mapper = identityMapper; + var members = source.symbol.members; + var callSignatures = source.declaredCallSignatures; + var constructSignatures = source.declaredConstructSignatures; + var stringIndexType = source.declaredStringIndexType; + var numberIndexType = source.declaredNumberIndexType; + if (!ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { + mapper = createTypeMapper(typeParameters, typeArguments); + members = createInstantiatedSymbolTable(source.declaredProperties, mapper, typeParameters.length === 1); + callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); + constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); + stringIndexType = instantiateType(source.declaredStringIndexType, mapper); + numberIndexType = instantiateType(source.declaredNumberIndexType, mapper); + } + var baseTypes = getBaseTypes(source); if (baseTypes.length) { - members = createSymbolTable(target.declaredProperties); + if (members === source.symbol.members) { + members = createSymbolTable(source.declaredProperties); + } + var thisArgument = ts.lastOrUndefined(typeArguments); for (var _i = 0; _i < baseTypes.length; _i++) { var baseType = baseTypes[_i]; - addInheritedMembers(members, getPropertiesOfObjectType(baseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(baseType, 0)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(baseType, 1)); - stringIndexType = stringIndexType || getIndexTypeOfType(baseType, 0); - numberIndexType = numberIndexType || getIndexTypeOfType(baseType, 1); + var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; + addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); + stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0); + numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1); } } setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } + function resolveClassOrInterfaceMembers(type) { + resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); + } function resolveTypeReferenceMembers(type) { - var target = resolveDeclaredMembers(type.target); - var mapper = createTypeMapper(target.typeParameters, type.typeArguments); - var members = createInstantiatedSymbolTable(target.declaredProperties, mapper); - var callSignatures = instantiateList(target.declaredCallSignatures, mapper, instantiateSignature); - var constructSignatures = instantiateList(target.declaredConstructSignatures, mapper, instantiateSignature); - var stringIndexType = target.declaredStringIndexType ? instantiateType(target.declaredStringIndexType, mapper) : undefined; - var numberIndexType = target.declaredNumberIndexType ? instantiateType(target.declaredNumberIndexType, mapper) : undefined; - ts.forEach(getBaseTypes(target), function (baseType) { - var instantiatedBaseType = instantiateType(baseType, mapper); - addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); - stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0); - numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1); - }); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + var source = resolveDeclaredMembers(type.target); + var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); + var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? + type.typeArguments : ts.concatenate(type.typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, typeArguments); } function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); @@ -13156,7 +13471,8 @@ var ts; return members; } function resolveTupleTypeMembers(type) { - var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, true))); + var arrayElementType = getUnionType(type.elementTypes, true); + var arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); @@ -13258,7 +13574,14 @@ var ts; var constructSignatures; var stringIndexType; var numberIndexType; - if (symbol.flags & 2048) { + if (type.target) { + members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false); + callSignatures = instantiateList(getSignaturesOfType(type.target, 0), type.mapper, instantiateSignature); + constructSignatures = instantiateList(getSignaturesOfType(type.target, 1), type.mapper, instantiateSignature); + stringIndexType = instantiateType(getIndexTypeOfType(type.target, 0), type.mapper); + numberIndexType = instantiateType(getIndexTypeOfType(type.target, 1), type.mapper); + } + else if (symbol.flags & 2048) { members = symbol.members; callSignatures = getSignaturesOfSymbol(members["__call"]); constructSignatures = getSignaturesOfSymbol(members["__new"]); @@ -13294,7 +13617,10 @@ var ts; } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & (1024 | 2048)) { + if (type.flags & 4096) { + resolveTypeReferenceMembers(type); + } + else if (type.flags & (1024 | 2048)) { resolveClassOrInterfaceMembers(type); } else if (type.flags & 65536) { @@ -13309,9 +13635,6 @@ var ts; else if (type.flags & 32768) { resolveIntersectionTypeMembers(type); } - else { - resolveTypeReferenceMembers(type); - } } return type; } @@ -13518,7 +13841,9 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 142 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 144 ? + getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) + : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -13549,7 +13874,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 148) { + if (declaration.type.kind === 150) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -13559,8 +13884,8 @@ var ts; } } else { - if (declaration.kind === 143 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 144); + if (declaration.kind === 145 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 146); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -13578,19 +13903,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 150: - case 151: - case 211: - case 141: - case 140: + case 152: + case 153: + case 213: + case 143: case 142: + case 144: + case 147: + case 148: + case 149: case 145: case 146: - case 147: - case 143: - case 144: - case 171: - case 172: + case 173: + case 174: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -13660,7 +13985,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 142 || signature.declaration.kind === 146; + var isConstructor = signature.declaration.kind === 144 || signature.declaration.kind === 148; var type = createObjectType(65536 | 262144); type.members = emptySymbols; type.properties = emptyArray; @@ -13674,7 +13999,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 126 : 128; + var syntaxKind = kind === 1 ? 128 : 130; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -13703,30 +14028,33 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 135).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 137).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 135).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 137).parent); } function getTypeListId(types) { - switch (types.length) { - case 1: - return "" + types[0].id; - case 2: - return types[0].id + "," + types[1].id; - default: - var result = ""; - for (var i = 0; i < types.length; i++) { - if (i > 0) { - result += ","; + if (types) { + switch (types.length) { + case 1: + return "" + types[0].id; + case 2: + return types[0].id + "," + types[1].id; + default: + var result = ""; + for (var i = 0; i < types.length; i++) { + if (i > 0) { + result += ","; + } + result += types[i].id; } - result += types[i].id; - } - return result; + return result; + } } + return ""; } function getPropagatingFlagsOfTypes(types) { var result = 0; @@ -13740,7 +14068,7 @@ var ts; var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var flags = 4096 | getPropagatingFlagsOfTypes(typeArguments); + var flags = 4096 | (typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0); type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; @@ -13756,13 +14084,13 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 135; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 137; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 149 && n.typeName.kind === 67) { + if (n.kind === 151 && n.typeName.kind === 69) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); @@ -13829,7 +14157,7 @@ var ts; function getTypeFromTypeReference(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var typeNameOrExpression = node.kind === 149 ? node.typeName : + var typeNameOrExpression = node.kind === 151 ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; @@ -13855,9 +14183,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 212: - case 213: + case 214: case 215: + case 217: return declaration; } } @@ -13907,17 +14235,17 @@ var ts; ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) : emptyObjectType; } - function createTypeFromGenericGlobalType(genericGlobalType, elementType) { - return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, [elementType]) : emptyObjectType; + function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) { + return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; } function createIterableType(elementType) { - return createTypeFromGenericGlobalType(globalIterableType, elementType); + return createTypeFromGenericGlobalType(globalIterableType, [elementType]); } function createIterableIteratorType(elementType) { - return createTypeFromGenericGlobalType(globalIterableIteratorType, elementType); + return createTypeFromGenericGlobalType(globalIterableIteratorType, [elementType]); } function createArrayType(elementType) { - return createTypeFromGenericGlobalType(globalArrayType, elementType); + return createTypeFromGenericGlobalType(globalArrayType, [elementType]); } function getTypeFromArrayTypeNode(node) { var links = getNodeLinks(node); @@ -13928,11 +14256,11 @@ var ts; } function createTupleType(elementTypes) { var id = getTypeListId(elementTypes); - var type = tupleTypes[id]; - if (!type) { - type = tupleTypes[id] = createObjectType(8192 | getPropagatingFlagsOfTypes(elementTypes)); - type.elementTypes = elementTypes; - } + return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes)); + } + function createNewTupleType(elementTypes) { + var type = createObjectType(8192 | getPropagatingFlagsOfTypes(elementTypes)); + type.elementTypes = elementTypes; return type; } function getTypeFromTupleTypeNode(node) { @@ -14074,46 +14402,66 @@ var ts; } return links.resolvedType; } + function getThisType(node) { + var container = ts.getThisContainer(node, false); + var parent = container && container.parent; + if (parent && (ts.isClassLike(parent) || parent.kind === 215)) { + if (!(container.flags & 128)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; + } + } + error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); + return unknownType; + } + function getTypeFromThisTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getThisType(node); + } + return links.resolvedType; + } function getTypeFromTypeNode(node) { switch (node.kind) { - case 115: + case 117: return anyType; - case 128: + case 130: return stringType; - case 126: + case 128: return numberType; - case 118: + case 120: return booleanType; - case 129: + case 131: return esSymbolType; - case 101: + case 103: return voidType; + case 97: + return getTypeFromThisTypeNode(node); case 9: return getTypeFromStringLiteral(node); - case 149: + case 151: return getTypeFromTypeReference(node); - case 148: + case 150: return booleanType; - case 186: + case 188: return getTypeFromTypeReference(node); - case 152: - return getTypeFromTypeQueryNode(node); case 154: + return getTypeFromTypeQueryNode(node); + case 156: return getTypeFromArrayTypeNode(node); - case 155: + case 157: return getTypeFromTupleTypeNode(node); - case 156: + case 158: return getTypeFromUnionTypeNode(node); - case 157: + case 159: return getTypeFromIntersectionTypeNode(node); - case 158: + case 160: return getTypeFromTypeNode(node.type); - case 150: - case 151: + case 152: case 153: + case 155: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 67: - case 133: + case 69: + case 135: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -14217,7 +14565,7 @@ var ts; 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); + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -14249,21 +14597,13 @@ var ts; mapper.instantiations = []; } var result = createObjectType(65536 | 131072, type.symbol); - result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); - result.members = createSymbolTable(result.properties); - result.callSignatures = instantiateList(getSignaturesOfType(type, 0), mapper, instantiateSignature); - result.constructSignatures = instantiateList(getSignaturesOfType(type, 1), mapper, instantiateSignature); - var stringIndexType = getIndexTypeOfType(type, 0); - var numberIndexType = getIndexTypeOfType(type, 1); - if (stringIndexType) - result.stringIndexType = instantiateType(stringIndexType, mapper); - if (numberIndexType) - result.numberIndexType = instantiateType(numberIndexType, mapper); + result.target = type; + result.mapper = mapper; mapper.instantiations[type.id] = result; return result; } function instantiateType(type, mapper) { - if (mapper !== identityMapper) { + if (type && mapper !== identityMapper) { if (type.flags & 512) { return mapper(type); } @@ -14287,27 +14627,27 @@ var ts; return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 171: - case 172: + case 173: + case 174: return isContextSensitiveFunctionLikeDeclaration(node); - case 163: + case 165: return ts.forEach(node.properties, isContextSensitive); - case 162: + case 164: return ts.forEach(node.elements, isContextSensitive); - case 180: + case 182: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 179: - return node.operatorToken.kind === 51 && + case 181: + return node.operatorToken.kind === 52 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 243: + case 245: return isContextSensitive(node.initializer); - case 141: - case 140: + case 143: + case 142: return isContextSensitiveFunctionLikeDeclaration(node); - case 170: + case 172: return isContextSensitive(node.expression); } return false; @@ -14420,7 +14760,9 @@ var ts; } return 0; } - source = getRegularTypeOfObjectLiteral(source); + if (target.flags & 49152) { + source = getRegularTypeOfObjectLiteral(source); + } } var saveErrorInfo = errorInfo; if (source.flags & 16384) { @@ -14458,7 +14800,7 @@ var ts; } else { if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { return result; } } @@ -14480,7 +14822,7 @@ var ts; var result; if (source.flags & 80896 && target.flags & 80896) { if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, false)) { + if (result = typeArgumentsRelatedTo(source, target, false)) { return result; } } @@ -14590,9 +14932,14 @@ var ts; } return result; } - function typesRelatedTo(sources, targets, reportErrors) { + function typeArgumentsRelatedTo(source, target, reportErrors) { + var sources = source.typeArguments || emptyArray; + var targets = target.typeArguments || emptyArray; + if (sources.length !== targets.length && relation === identityRelation) { + return 0; + } var result = -1; - for (var i = 0, len = sources.length; i < len; i++) { + for (var i = 0; i < targets.length; i++) { var related = isRelatedTo(sources[i], targets[i], reportErrors); if (!related) { return 0; @@ -14819,8 +15166,8 @@ var ts; return result; function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) { if (sourceSig && targetSig) { - var sourceDecl = source.symbol && ts.getDeclarationOfKind(source.symbol, 212); - var targetDecl = target.symbol && ts.getDeclarationOfKind(target.symbol, 212); + var sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol); + var targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol); if (!sourceDecl) { return -1; } @@ -14828,8 +15175,8 @@ var ts; var targetErasedSignature = getErasedSignature(targetSig); var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); - var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 212); - var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 212); + var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); + var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256; var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256; if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { @@ -15152,6 +15499,7 @@ var ts; regularType.constructSignatures = type.constructSignatures; regularType.stringIndexType = type.stringIndexType; regularType.numberIndexType = type.numberIndexType; + type.regularType = regularType; } return regularType; } @@ -15242,22 +15590,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 139: - case 138: + case 141: + case 140: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 136: + case 138: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 211: - case 141: - case 140: + case 213: case 143: - case 144: - case 171: - case 172: + case 142: + case 145: + case 146: + case 173: + case 174: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -15353,9 +15701,10 @@ var ts; } } else if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - var sourceTypes = source.typeArguments; - var targetTypes = target.typeArguments; - for (var i = 0; i < sourceTypes.length; i++) { + var sourceTypes = source.typeArguments || emptyArray; + var targetTypes = target.typeArguments || emptyArray; + var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; + for (var i = 0; i < count; i++) { inferFromTypes(sourceTypes[i], targetTypes[i]); } } @@ -15509,10 +15858,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 152: + case 154: return true; - case 67: - case 133: + case 69: + case 135: node = node.parent; continue; default: @@ -15552,12 +15901,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 55 && node.operatorToken.kind <= 66) { + if (node.operatorToken.kind >= 56 && node.operatorToken.kind <= 68) { var n = node.left; - while (n.kind === 170) { + while (n.kind === 172) { n = n.expression; } - if (n.kind === 67 && getResolvedSymbol(n) === symbol) { + if (n.kind === 69 && getResolvedSymbol(n) === symbol) { return true; } } @@ -15571,55 +15920,55 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 179: + case 181: return isAssignedInBinaryExpression(node); - case 209: - case 161: + case 211: + case 163: return isAssignedInVariableDeclaration(node); - case 159: - case 160: + case 161: case 162: - case 163: case 164: case 165: case 166: case 167: + case 168: case 169: - case 187: - case 170: - case 177: - case 173: - case 176: - case 174: + case 171: + case 189: + case 172: + case 179: case 175: case 178: - case 182: + case 176: + case 177: case 180: - case 183: - case 190: - case 191: + case 184: + case 182: + case 185: + case 192: case 193: - case 194: case 195: case 196: case 197: case 198: case 199: - case 202: - case 203: + case 200: + case 201: case 204: - case 239: - case 240: case 205: case 206: - case 207: + case 241: case 242: - case 231: - case 232: - case 236: - case 237: + case 207: + case 208: + case 209: + case 244: case 233: + case 234: case 238: + case 239: + case 235: + case 240: return ts.forEachChild(node, isAssignedIn); } return false; @@ -15634,34 +15983,34 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 194: + case 196: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 180: + case 182: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 179: + case 181: if (child === node.right) { - if (node.operatorToken.kind === 50) { + if (node.operatorToken.kind === 51) { narrowedType = narrowType(type, node.left, true); } - else if (node.operatorToken.kind === 51) { + else if (node.operatorToken.kind === 52) { narrowedType = narrowType(type, node.left, false); } } break; - case 246: - case 216: - case 211: - case 141: - case 140: + case 248: + case 218: + case 213: case 143: - case 144: case 142: + case 145: + case 146: + case 144: break loop; } if (narrowedType !== type) { @@ -15675,12 +16024,12 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 174 || expr.right.kind !== 9) { + if (expr.left.kind !== 176 || expr.right.kind !== 9) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 67 || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 69 || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; @@ -15726,7 +16075,7 @@ var ts; } } function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 67 || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 69 || getResolvedSymbol(expr.left) !== symbol) { return type; } var rightType = checkExpression(expr.right); @@ -15790,27 +16139,27 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 166: + case 168: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 170: + case 172: return narrowType(type, expr.expression, assumeTrue); - case 179: + case 181: var operator = expr.operatorToken.kind; if (operator === 32 || operator === 33) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 50) { + else if (operator === 51) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 51) { + else if (operator === 52) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 89) { + else if (operator === 91) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 177: - if (expr.operator === 48) { + case 179: + if (expr.operator === 49) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -15822,7 +16171,7 @@ var ts; var symbol = getResolvedSymbol(node); if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 172) { + if (container.kind === 174) { if (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); } @@ -15853,15 +16202,15 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 242) { + symbol.valueDeclaration.parent.kind === 244) { return; } var container = symbol.valueDeclaration; - while (container.kind !== 210) { + while (container.kind !== 212) { container = container.parent; } container = container.parent; - if (container.kind === 191) { + if (container.kind === 193) { container = container.parent; } var inFunction = isInsideFunction(node.parent, container); @@ -15879,7 +16228,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 139 || container.kind === 142) { + if (container.kind === 141 || container.kind === 144) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -15890,29 +16239,29 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 172) { + if (container.kind === 174) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 216: + case 218: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 215: + case 217: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 142: + case 144: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 139: - case 138: + case 141: + case 140: if (container.flags & 128) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 134: + case 136: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -15921,27 +16270,27 @@ var ts; } if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); - return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); + return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; } return anyType; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 136) { + if (n.kind === 138) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 166 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 168 && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 172) { + while (container && container.kind === 174) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -15967,7 +16316,7 @@ var ts; return unknownType; } if (!canUseSuperExpression) { - if (container && container.kind === 134) { + if (container && container.kind === 136) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -15978,7 +16327,7 @@ var ts; } return unknownType; } - if (container.kind === 142 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 144 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -15990,24 +16339,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 142; + return container.kind === 144; } else { if (container && ts.isClassLike(container.parent)) { if (container.flags & 128) { - return container.kind === 141 || - container.kind === 140 || - container.kind === 143 || - container.kind === 144; + return container.kind === 143 || + container.kind === 142 || + container.kind === 145 || + container.kind === 146; } else { - return container.kind === 141 || + return container.kind === 143 || + container.kind === 142 || + container.kind === 145 || + container.kind === 146 || + container.kind === 141 || container.kind === 140 || - container.kind === 143 || - container.kind === 144 || - container.kind === 139 || - container.kind === 138 || - container.kind === 142; + container.kind === 144; } } } @@ -16015,8 +16364,8 @@ var ts; } } function getContextuallyTypedParameterType(parameter) { - if (isFunctionExpressionOrArrowFunction(parameter.parent)) { - var func = parameter.parent; + var func = parameter.parent; + if (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) { if (isContextSensitive(func)) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { @@ -16041,14 +16390,14 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 136) { + if (declaration.kind === 138) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; } } if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name); + return getTypeFromBindingPattern(declaration.name, true); } } return undefined; @@ -16074,7 +16423,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 136 && node.parent.initializer === node) { + if (node.parent.kind === 138 && node.parent.initializer === node) { return true; } node = node.parent; @@ -16083,8 +16432,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 142 || - functionDecl.kind === 143 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 144))) { + functionDecl.kind === 144 || + functionDecl.kind === 145 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 146))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -16103,7 +16452,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 168) { + if (template.parent.kind === 170) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -16111,12 +16460,12 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 55 && operator <= 66) { + if (operator >= 56 && operator <= 68) { if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 51) { + else if (operator === 52) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = checkExpression(binaryExpression.left); @@ -16203,7 +16552,7 @@ var ts; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } function getContextualTypeForJsxExpression(expr) { - if (expr.parent.kind === 236) { + if (expr.parent.kind === 238) { var attrib = expr.parent; var attrsType = getJsxElementAttributesType(attrib.parent); if (!attrsType || isTypeAny(attrsType)) { @@ -16213,7 +16562,7 @@ var ts; return getTypeOfPropertyOfType(attrsType, attrib.name.text); } } - if (expr.kind === 237) { + if (expr.kind === 239) { return getJsxElementAttributesType(expr.parent); } return undefined; @@ -16231,38 +16580,38 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 209: - case 136: - case 139: + case 211: case 138: - case 161: + case 141: + case 140: + case 163: return getContextualTypeForInitializerExpression(node); - case 172: - case 202: + case 174: + case 204: return getContextualTypeForReturnExpression(node); - case 182: + case 184: return getContextualTypeForYieldOperand(parent); - case 166: - case 167: - return getContextualTypeForArgument(parent, node); + case 168: case 169: - case 187: + return getContextualTypeForArgument(parent, node); + case 171: + case 189: return getTypeFromTypeNode(parent.type); - case 179: + case 181: return getContextualTypeForBinaryOperand(node); - case 243: + case 245: return getContextualTypeForObjectLiteralElement(parent); - case 162: + case 164: return getContextualTypeForElementExpression(node); - case 180: + case 182: return getContextualTypeForConditionalOperand(node); - case 188: - ts.Debug.assert(parent.parent.kind === 181); + case 190: + ts.Debug.assert(parent.parent.kind === 183); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 170: + case 172: return getContextualType(parent); - case 238: - case 237: + case 240: + case 239: return getContextualTypeForJsxExpression(parent); } return undefined; @@ -16277,7 +16626,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 171 || node.kind === 172; + return node.kind === 173 || node.kind === 174; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -16285,7 +16634,7 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -16325,13 +16674,13 @@ var ts; } function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 179 && parent.operatorToken.kind === 55 && parent.left === node) { + if (parent.kind === 181 && parent.operatorToken.kind === 56 && parent.left === node) { return true; } - if (parent.kind === 243) { + if (parent.kind === 245) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 162) { + if (parent.kind === 164) { return isAssignmentTarget(parent); } return false; @@ -16340,17 +16689,18 @@ var ts; var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper); return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } + function hasDefaultValue(node) { + return (node.kind === 163 && !!node.initializer) || + (node.kind === 181 && node.operatorToken.kind === 56); + } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; - if (!elements.length) { - return createArrayType(undefinedType); - } var hasSpreadElement = false; var elementTypes = []; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 183) { + if (inDestructuringPattern && e.kind === 185) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -16362,18 +16712,41 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 183; + hasSpreadElement = hasSpreadElement || e.kind === 185; } if (!hasSpreadElement) { + if (inDestructuringPattern && elementTypes.length) { + var type = createNewTupleType(elementTypes); + type.pattern = node; + return type; + } var contextualType = getContextualType(node); - if (contextualType && contextualTypeIsTupleLikeType(contextualType) || inDestructuringPattern) { - return createTupleType(elementTypes); + if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { + var pattern = contextualType.pattern; + if (pattern && (pattern.kind === 162 || pattern.kind === 164)) { + var patternElements = pattern.elements; + for (var i = elementTypes.length; i < patternElements.length; i++) { + var patternElement = patternElements[i]; + if (hasDefaultValue(patternElement)) { + elementTypes.push(contextualType.elementTypes[i]); + } + else { + if (patternElement.kind !== 187) { + error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + } + elementTypes.push(unknownType); + } + } + } + if (elementTypes.length) { + return createTupleType(elementTypes); + } } } - return createArrayType(getUnionType(elementTypes)); + return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); } function isNumericName(name) { - return name.kind === 134 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 136 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); @@ -16398,30 +16771,49 @@ var ts; return links.resolvedType; } function checkObjectLiteral(node, contextualMapper) { - checkGrammarObjectLiteralExpression(node); + var inDestructuringPattern = isAssignmentTarget(node); + checkGrammarObjectLiteralExpression(node, inDestructuringPattern); var propertiesTable = {}; var propertiesArray = []; var contextualType = getContextualType(node); + var contextualTypeHasPattern = contextualType && contextualType.pattern && + (contextualType.pattern.kind === 161 || contextualType.pattern.kind === 165); var typeFlags = 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 243 || - memberDecl.kind === 244 || + if (memberDecl.kind === 245 || + memberDecl.kind === 246 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 243) { + if (memberDecl.kind === 245) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 141) { + else if (memberDecl.kind === 143) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 244); + ts.Debug.assert(memberDecl.kind === 246); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; var prop = createSymbol(4 | 67108864 | member.flags, member.name); + if (inDestructuringPattern) { + var isOptional = (memberDecl.kind === 245 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 246 && memberDecl.objectAssignmentInitializer); + if (isOptional) { + prop.flags |= 536870912; + } + } + else if (contextualTypeHasPattern) { + var impliedProp = getPropertyOfType(contextualType, member.name); + if (impliedProp) { + prop.flags |= impliedProp.flags & 536870912; + } + else if (!compilerOptions.suppressExcessPropertyErrors) { + error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); + } + } prop.declarations = member.declarations; prop.parent = member.parent; if (member.valueDeclaration) { @@ -16432,7 +16824,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 143 || memberDecl.kind === 144); + ts.Debug.assert(memberDecl.kind === 145 || memberDecl.kind === 146); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -16440,11 +16832,26 @@ var ts; } propertiesArray.push(member); } + if (contextualTypeHasPattern) { + for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) { + var prop = _c[_b]; + if (!ts.hasProperty(propertiesTable, prop.name)) { + if (!(prop.flags & 536870912)) { + error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + } + propertiesTable[prop.name] = prop; + propertiesArray.push(prop); + } + } + } var stringIndexType = getIndexType(0); var numberIndexType = getIndexType(1); var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576; result.flags |= 524288 | 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064); + if (inDestructuringPattern) { + result.pattern = node; + } return result; function getIndexType(kind) { if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { @@ -16473,7 +16880,7 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 67) { + if (lhs.kind === 69) { return lhs.text === rhs.text; } return lhs.right.text === rhs.right.text && @@ -16490,17 +16897,17 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 238: + case 240: checkJsxExpression(child); break; - case 231: + case 233: checkJsxElement(child); break; - case 232: + case 234: checkJsxSelfClosingElement(child); break; default: - ts.Debug.assert(child.kind === 234); + ts.Debug.assert(child.kind === 236); } } return jsxElementType || anyType; @@ -16509,7 +16916,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 133) { + if (tagName.kind === 135) { return false; } else { @@ -16610,12 +17017,14 @@ var ts; var valueSymbol = resolveJsxTagName(node); if (valueSymbol && valueSymbol !== unknownSymbol) { links.jsxFlags |= 4; - getSymbolLinks(valueSymbol).referenced = true; + if (valueSymbol.flags & 8388608) { + markAliasSymbolAsReferenced(valueSymbol); + } } return valueSymbol || unknownSymbol; } function resolveJsxTagName(node) { - if (node.tagName.kind === 67) { + if (node.tagName.kind === 69) { var tag = node.tagName; var sym = getResolvedSymbol(tag); return sym.exportSymbol || sym; @@ -16755,11 +17164,11 @@ var ts; var nameTable = {}; var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 236) { + if (node.attributes[i].kind === 238) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 237); + ts.Debug.assert(node.attributes[i].kind === 239); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -16785,7 +17194,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 139; + return s.valueDeclaration ? s.valueDeclaration.kind : 141; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; @@ -16793,11 +17202,11 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 93) { - var errorNode = node.kind === 164 ? + if (left.kind === 95) { + var errorNode = node.kind === 166 ? node.name : node.right; - if (getDeclarationKindFromSymbol(prop) !== 141) { + if (getDeclarationKindFromSymbol(prop) !== 143) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -16818,7 +17227,7 @@ var ts; } return true; } - if (left.kind === 93) { + if (left.kind === 95) { return true; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { @@ -16828,6 +17237,9 @@ var ts; if (flags & 128) { return true; } + if (type.flags & 33554432) { + type = getConstraintOfTypeParameter(type); + } if (!(getTargetType(type).flags & (1024 | 2048) && hasBaseType(type, enclosingClass))) { error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); return false; @@ -16852,18 +17264,18 @@ var ts; var prop = getPropertyOfType(apparentType, right.text); if (!prop) { if (right.text) { - error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type)); + error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type.flags & 33554432 ? apparentType : type)); } return unknownType; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32) { - checkClassPropertyAccess(node, left, type, prop); + checkClassPropertyAccess(node, left, apparentType, prop); } return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 164 + var left = node.kind === 166 ? node.expression : node.left; var type = checkExpression(left); @@ -16878,7 +17290,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 167 && node.parent.expression === node) { + if (node.parent.kind === 169 && 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); @@ -16937,6 +17349,12 @@ var ts; if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { return indexArgumentExpression.text; } + if (indexArgumentExpression.kind === 167 || indexArgumentExpression.kind === 166) { + var value = getConstantValue(indexArgumentExpression); + if (value !== undefined) { + return value.toString(); + } + } if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, false)) { var rightHandSideName = indexArgumentExpression.name.text; return ts.getPropertyNameForKnownSymbolName(rightHandSideName); @@ -16974,10 +17392,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 168) { + if (node.kind === 170) { checkExpression(node.template); } - else if (node.kind !== 137) { + else if (node.kind !== 139) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -17028,7 +17446,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 183) { + if (arg && arg.kind === 185) { return i; } } @@ -17040,11 +17458,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 168) { + if (node.kind === 170) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 181) { + if (tagExpression.template.kind === 183) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -17056,7 +17474,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 137) { + else if (node.kind === 139) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); @@ -17064,7 +17482,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 167); + ts.Debug.assert(callExpression.kind === 169); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -17117,7 +17535,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 185) { + if (arg === undefined || arg.kind !== 187) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -17164,7 +17582,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 185) { + if (arg === undefined || arg.kind !== 187) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -17183,16 +17601,16 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 168) { + if (node.kind === 170) { var template = node.template; args = [undefined]; - if (template.kind === 181) { + if (template.kind === 183) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 137) { + else if (node.kind === 139) { return undefined; } else { @@ -17201,18 +17619,21 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 137) { + if (node.kind === 139) { switch (node.parent.kind) { - case 212: - case 184: + case 214: + case 186: return 1; - case 139: - return 2; case 141: + return 2; case 143: - case 144: + case 145: + case 146: + if (languageVersion === 0) { + return 2; + } return signature.parameters.length >= 3 ? 3 : 2; - case 136: + case 138: return 3; } } @@ -17221,83 +17642,83 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - switch (node.kind) { - case 212: - case 184: + if (node.kind === 214) { + var classSymbol = getSymbolOfNode(node); + return getTypeOfSymbol(classSymbol); + } + if (node.kind === 138) { + node = node.parent; + if (node.kind === 144) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 136: - node = node.parent; - if (node.kind === 142) { - var classSymbol_1 = getSymbolOfNode(node); - return getTypeOfSymbol(classSymbol_1); - } - case 139: - case 141: - case 143: - case 144: - return getParentTypeOfClassElement(node); - default: - ts.Debug.fail("Unsupported decorator target."); - return unknownType; + } } + if (node.kind === 141 || + node.kind === 143 || + node.kind === 145 || + node.kind === 146) { + return getParentTypeOfClassElement(node); + } + ts.Debug.fail("Unsupported decorator target."); + return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - switch (node.kind) { - case 212: - ts.Debug.fail("Class decorators should not have a second synthetic argument."); - return unknownType; - case 136: - node = node.parent; - if (node.kind === 142) { - return anyType; - } - case 139: - case 141: - case 143: - case 144: - var element = node; - switch (element.name.kind) { - case 67: - case 8: - case 9: - return getStringLiteralType(element.name); - case 134: - var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 16777216)) { - return nameType; - } - else { - return stringType; - } - default: - ts.Debug.fail("Unsupported property name."); - return unknownType; - } - default: - ts.Debug.fail("Unsupported decorator target."); - return unknownType; + if (node.kind === 214) { + ts.Debug.fail("Class decorators should not have a second synthetic argument."); + return unknownType; + } + if (node.kind === 138) { + node = node.parent; + if (node.kind === 144) { + return anyType; + } + } + if (node.kind === 141 || + node.kind === 143 || + node.kind === 145 || + node.kind === 146) { + var element = node; + switch (element.name.kind) { + case 69: + case 8: + case 9: + return getStringLiteralType(element.name); + case 136: + var nameType = checkComputedPropertyName(element.name); + if (allConstituentTypesHaveKind(nameType, 16777216)) { + return nameType; + } + else { + return stringType; + } + default: + ts.Debug.fail("Unsupported property name."); + return unknownType; + } } + ts.Debug.fail("Unsupported decorator target."); + return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - switch (node.kind) { - case 212: - ts.Debug.fail("Class decorators should not have a third synthetic argument."); - return unknownType; - case 136: - return numberType; - case 139: - ts.Debug.fail("Property decorators should not have a third synthetic argument."); - return unknownType; - case 141: - case 143: - case 144: - var propertyType = getTypeOfNode(node); - return createTypedPropertyDescriptorType(propertyType); - default: - ts.Debug.fail("Unsupported decorator target."); - return unknownType; + if (node.kind === 214) { + ts.Debug.fail("Class decorators should not have a third synthetic argument."); + return unknownType; + } + if (node.kind === 138) { + return numberType; + } + if (node.kind === 141) { + ts.Debug.fail("Property decorators should not have a third synthetic argument."); + return unknownType; } + if (node.kind === 143 || + node.kind === 145 || + node.kind === 146) { + var propertyType = getTypeOfNode(node); + return createTypedPropertyDescriptorType(propertyType); + } + ts.Debug.fail("Unsupported decorator target."); + return unknownType; } function getEffectiveDecoratorArgumentType(node, argIndex) { if (argIndex === 0) { @@ -17313,26 +17734,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 137) { + if (node.kind === 139) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 168) { + else if (argIndex === 0 && node.kind === 170) { return globalTemplateStringsArrayType; } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 137 || - (argIndex === 0 && node.kind === 168)) { + if (node.kind === 139 || + (argIndex === 0 && node.kind === 170)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 137) { + if (node.kind === 139) { return node.expression; } - else if (argIndex === 0 && node.kind === 168) { + else if (argIndex === 0 && node.kind === 170) { return node.template; } else { @@ -17340,12 +17761,12 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 168; - var isDecorator = node.kind === 137; + var isTaggedTemplate = node.kind === 170; + var isDecorator = node.kind === 139; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; - if (node.expression.kind !== 93) { + if (node.expression.kind !== 95) { ts.forEach(typeArguments, checkSourceElement); } } @@ -17483,7 +17904,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 93) { + if (node.expression.kind === 95) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); @@ -17528,7 +17949,7 @@ var ts; if (expressionType === unknownType) { return resolveErrorCall(node); } - var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 212); + var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); if (valueDecl && valueDecl.flags & 256) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); return resolveErrorCall(node); @@ -17572,16 +17993,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 212: - case 184: + case 214: + case 186: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 136: + case 138: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 139: - return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; case 141: + return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; case 143: - case 144: + case 145: + case 146: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -17609,16 +18030,16 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 166) { + if (node.kind === 168) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 167) { + else if (node.kind === 169) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 168) { + else if (node.kind === 170) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 137) { + else if (node.kind === 139) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -17630,15 +18051,15 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 93) { + if (node.expression.kind === 95) { return voidType; } - if (node.kind === 167) { + if (node.kind === 169) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 142 && - declaration.kind !== 146 && - declaration.kind !== 151) { + declaration.kind !== 144 && + declaration.kind !== 148 && + declaration.kind !== 153) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } @@ -17679,10 +18100,22 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); } } + function assignBindingElementTypes(node) { + if (ts.isBindingPattern(node.name)) { + for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.kind !== 187) { + getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); + assignBindingElementTypes(element); + } + } + } + } function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { var links = getSymbolLinks(parameter); if (!links.type) { links.type = instantiateType(contextualType, mapper); + assignBindingElementTypes(parameter.valueDeclaration); } else if (isInferentialContext(mapper)) { inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); @@ -17703,7 +18136,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 190) { + if (func.body.kind !== 192) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -17807,7 +18240,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 206); + return (body.statements.length === 1) && (body.statements[0].kind === 208); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!produceDiagnostics) { @@ -17816,7 +18249,7 @@ var ts; if (returnType === voidType || isTypeAny(returnType)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 190) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 192) { return; } var bodyBlock = func.body; @@ -17829,9 +18262,9 @@ 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 !== 141 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 171) { + if (!hasGrammarError && node.kind === 173) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -17867,14 +18300,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 141 && node.kind !== 140) { + if (produceDiagnostics && node.kind !== 143 && node.kind !== 142) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; @@ -17891,7 +18324,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 190) { + if (node.body.kind === 192) { checkSourceElement(node.body); } else { @@ -17923,17 +18356,17 @@ var ts; } function isReferenceOrErrorExpression(n) { switch (n.kind) { - case 67: { + case 69: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 164: { + case 166: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; } - case 165: + case 167: return true; - case 170: + case 172: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -17941,12 +18374,12 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 67: - case 164: { + case 69: + case 166: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768) !== 0; } - case 165: { + case 167: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 9) { @@ -17956,7 +18389,7 @@ var ts; } return false; } - case 170: + case 172: return isConstVariableReference(n.expression); default: return false; @@ -18001,15 +18434,15 @@ var ts; switch (node.operator) { case 35: case 36: - case 49: + case 50: if (someConstituentTypeHasKind(operandType, 16777216)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 48: + case 49: return booleanType; - case 40: case 41: + case 42: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); @@ -18064,21 +18497,21 @@ var ts; function isConstEnumSymbol(symbol) { return (symbol.flags & 128) !== 0; } - function checkInstanceOfExpression(node, leftType, rightType) { + function checkInstanceOfExpression(left, right, leftType, rightType) { if (allConstituentTypesHaveKind(leftType, 16777726)) { - error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { - error(node.right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); + error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); } return booleanType; } - function checkInExpression(node, leftType, rightType) { + function checkInExpression(left, right, leftType, rightType) { if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 16777216)) { - error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); + error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 | 512)) { - error(node.right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; } @@ -18086,7 +18519,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 243 || p.kind === 244) { + if (p.kind === 245 || p.kind === 246) { var name_14 = p.name; var type = isTypeAny(sourceType) ? sourceType @@ -18094,7 +18527,12 @@ var ts; isNumericLiteralName(name_14.text) && getIndexTypeOfType(sourceType, 1) || getIndexTypeOfType(sourceType, 0); if (type) { - checkDestructuringAssignment(p.initializer || name_14, type); + if (p.kind === 246) { + checkDestructuringAssignment(p, type); + } + else { + checkDestructuringAssignment(p.initializer || name_14, type); + } } else { error(name_14, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_14)); @@ -18111,8 +18549,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 185) { - if (e.kind !== 183) { + if (e.kind !== 187) { + if (e.kind !== 185) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -18137,7 +18575,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 179 && restExpression.operatorToken.kind === 55) { + if (restExpression.kind === 181 && restExpression.operatorToken.kind === 56) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -18149,15 +18587,26 @@ var ts; } return sourceType; } - function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 179 && target.operatorToken.kind === 55) { + function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { + var target; + if (exprOrAssignment.kind === 246) { + var prop = exprOrAssignment; + if (prop.objectAssignmentInitializer) { + checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); + } + target = exprOrAssignment.name; + } + else { + target = exprOrAssignment; + } + if (target.kind === 181 && target.operatorToken.kind === 56) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 163) { + if (target.kind === 165) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 162) { + if (target.kind === 164) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -18170,33 +18619,38 @@ var ts; return sourceType; } function checkBinaryExpression(node, contextualMapper) { - var operator = node.operatorToken.kind; - if (operator === 55 && (node.left.kind === 163 || node.left.kind === 162)) { - return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); + return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node); + } + function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { + var operator = operatorToken.kind; + if (operator === 56 && (left.kind === 165 || left.kind === 164)) { + return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } - var leftType = checkExpression(node.left, contextualMapper); - var rightType = checkExpression(node.right, contextualMapper); + var leftType = checkExpression(left, contextualMapper); + var rightType = checkExpression(right, contextualMapper); switch (operator) { case 37: - case 58: case 38: case 59: - case 39: case 60: - case 36: - case 57: - case 42: + case 39: case 61: - case 43: + case 40: case 62: - case 44: + case 36: + case 58: + case 43: case 63: - case 46: + case 44: + case 64: + case 45: case 65: case 47: + case 67: + case 48: + case 68: + case 46: case 66: - case 45: - case 64: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -18204,19 +18658,19 @@ var ts; var suggestedOperator; if ((leftType.flags & 8) && (rightType.flags & 8) && - (suggestedOperator = getSuggestedBooleanOperator(node.operatorToken.kind)) !== undefined) { - error(node, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(node.operatorToken.kind), ts.tokenToString(suggestedOperator)); + (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { + error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); } else { - var leftOk = checkArithmeticOperandType(node.left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - var rightOk = checkArithmeticOperandType(node.right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); if (leftOk && rightOk) { checkAssignmentOperator(numberType); } } return numberType; case 35: - case 56: + case 57: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -18240,7 +18694,7 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 56) { + if (operator === 57) { checkAssignmentOperator(resultType); } return resultType; @@ -18259,23 +18713,23 @@ var ts; reportOperatorError(); } return booleanType; - case 89: - return checkInstanceOfExpression(node, leftType, rightType); - case 88: - return checkInExpression(node, leftType, rightType); - case 50: - return rightType; + case 91: + return checkInstanceOfExpression(left, right, leftType, rightType); + case 90: + return checkInExpression(left, right, leftType, rightType); case 51: + return rightType; + case 52: return getUnionType([leftType, rightType]); - case 55: + case 56: checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); case 24: return rightType; } function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216) ? node.left : - someConstituentTypeHasKind(rightType, 16777216) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216) ? left : + someConstituentTypeHasKind(rightType, 16777216) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -18285,29 +18739,29 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 46: - case 65: - return 51; case 47: - case 66: + case 67: + return 52; + case 48: + case 68: return 33; - case 45: - case 64: - return 50; + case 46: + case 66: + return 51; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 55 && operator <= 66) { - var ok = checkReferenceExpression(node.left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); + if (produceDiagnostics && operator >= 56 && operator <= 68) { + var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); if (ok) { - checkTypeAssignableTo(valueType, leftType, node.left, undefined); + checkTypeAssignableTo(valueType, leftType, left, undefined); } } } function reportOperatorError() { - error(node, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(node.operatorToken.kind), typeToString(leftType), typeToString(rightType)); + error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); } } function isYieldExpressionInClass(node) { @@ -18383,14 +18837,14 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 134) { + if (node.name.kind === 136) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 134) { + if (node.name.kind === 136) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -18413,7 +18867,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 133) { + if (node.kind === 135) { type = checkQualifiedName(node); } else { @@ -18421,9 +18875,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 164 && node.parent.expression === node) || - (node.parent.kind === 165 && node.parent.expression === node) || - ((node.kind === 67 || node.kind === 133) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 166 && node.parent.expression === node) || + (node.parent.kind === 167 && node.parent.expression === node) || + ((node.kind === 69 || node.kind === 135) && 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); } @@ -18436,78 +18890,78 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 67: + case 69: return checkIdentifier(node); - case 95: + case 97: return checkThisExpression(node); - case 93: + case 95: return checkSuperExpression(node); - case 91: + case 93: return nullType; - case 97: - case 82: + case 99: + case 84: return booleanType; case 8: return checkNumericLiteral(node); - case 181: + case 183: return checkTemplateExpression(node); case 9: case 11: return stringType; case 10: return globalRegExpType; - case 162: - return checkArrayLiteral(node, contextualMapper); - case 163: - return checkObjectLiteral(node, contextualMapper); case 164: - return checkPropertyAccessExpression(node); + return checkArrayLiteral(node, contextualMapper); case 165: - return checkIndexedAccess(node); + return checkObjectLiteral(node, contextualMapper); case 166: + return checkPropertyAccessExpression(node); case 167: - return checkCallExpression(node); + return checkIndexedAccess(node); case 168: - return checkTaggedTemplateExpression(node); + case 169: + return checkCallExpression(node); case 170: + return checkTaggedTemplateExpression(node); + case 172: return checkExpression(node.expression, contextualMapper); - case 184: + case 186: return checkClassExpression(node); - case 171: - case 172: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 173: case 174: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 176: return checkTypeOfExpression(node); - case 169: - case 187: + case 171: + case 189: return checkAssertion(node); - case 173: - return checkDeleteExpression(node); case 175: + return checkDeleteExpression(node); + case 177: return checkVoidExpression(node); - case 176: + case 178: return checkAwaitExpression(node); - case 177: + case 179: return checkPrefixUnaryExpression(node); - case 178: + case 180: return checkPostfixUnaryExpression(node); - case 179: + case 181: return checkBinaryExpression(node, contextualMapper); - case 180: + case 182: return checkConditionalExpression(node, contextualMapper); - case 183: - return checkSpreadElementExpression(node, contextualMapper); case 185: + return checkSpreadElementExpression(node, contextualMapper); + case 187: return undefinedType; - case 182: + case 184: return checkYieldExpression(node); - case 238: + case 240: return checkJsxExpression(node); - case 231: + case 233: return checkJsxElement(node); - case 232: + case 234: return checkJsxSelfClosingElement(node); - case 233: + case 235: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -18523,16 +18977,12 @@ var ts; } } function checkParameter(node) { - // Grammar checking - // 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). checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (node.flags & 112) { func = ts.getContainingFunction(node); - if (!(func.kind === 142 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 144 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -18547,15 +18997,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 141 || - node.kind === 211 || - node.kind === 171; + return node.kind === 143 || + node.kind === 213 || + node.kind === 173; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 67 && + if (param.name.kind === 69 && param.name.text === parameter.text) { return i; } @@ -18565,30 +19015,30 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { - case 172: - case 145: - case 211: - case 171: - case 150: - case 141: - case 140: + case 174: + case 147: + case 213: + case 173: + case 152: + case 143: + case 142: return node === node.parent.type; } return false; } function checkSignatureDeclaration(node) { - if (node.kind === 147) { + if (node.kind === 149) { checkGrammarIndexSignature(node); } - else if (node.kind === 150 || node.kind === 211 || node.kind === 151 || - node.kind === 145 || node.kind === 142 || - node.kind === 146) { + else if (node.kind === 152 || node.kind === 213 || node.kind === 153 || + node.kind === 147 || node.kind === 144 || + node.kind === 148) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 148) { + if (node.type.kind === 150) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -18607,19 +19057,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 159 || - param.name.kind === 160) { + if (param.name.kind === 161 || + param.name.kind === 162) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 67 && + if (element.name.kind === 69 && 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 === 160 || - element.name.kind === 159) { + else if (element.name.kind === 162 || + element.name.kind === 161) { checkBindingPattern(element.name); } } @@ -18643,10 +19093,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 146: + case 148: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 145: + case 147: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -18668,7 +19118,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 213) { + if (node.kind === 215) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -18683,7 +19133,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 128: + case 130: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -18691,7 +19141,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 126: + case 128: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -18731,7 +19181,7 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 166 && n.expression.kind === 93; + return n.kind === 168 && n.expression.kind === 95; } function containsSuperCallAsComputedPropertyName(n) { return n.name && containsSuperCall(n.name); @@ -18749,15 +19199,15 @@ var ts; return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 95) { + if (n.kind === 97) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 171 && n.kind !== 211) { + else if (n.kind !== 173 && n.kind !== 213) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 139 && + return n.kind === 141 && !(n.flags & 128) && !!n.initializer; } @@ -18777,7 +19227,7 @@ var ts; var superCallStatement; for (var _i = 0; _i < statements.length; _i++) { var statement = statements[_i]; - if (statement.kind === 193 && isSuperCallExpression(statement.expression)) { + if (statement.kind === 195 && isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; } @@ -18801,13 +19251,13 @@ var ts; function checkAccessorDeclaration(node) { if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 143) { + if (node.kind === 145) { 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 === 143 ? 144 : 143; + var otherKind = node.kind === 145 ? 146 : 145; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112) !== (otherAccessor.flags & 112))) { @@ -18892,9 +19342,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 213) { - ts.Debug.assert(signatureDeclarationNode.kind === 145 || signatureDeclarationNode.kind === 146); - var signatureKind = signatureDeclarationNode.kind === 145 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 215) { + ts.Debug.assert(signatureDeclarationNode.kind === 147 || signatureDeclarationNode.kind === 148); + var signatureKind = signatureDeclarationNode.kind === 147 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -18912,7 +19362,10 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 213 && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 215 && + n.parent.kind !== 214 && + n.parent.kind !== 186 && + ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; } @@ -18988,7 +19441,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 === 141 || node.kind === 140); + ts.Debug.assert(node.kind === 143 || node.kind === 142); 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); @@ -19020,11 +19473,11 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 213 || node.parent.kind === 153 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 215 || node.parent.kind === 155 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 211 || node.kind === 141 || node.kind === 140 || node.kind === 142) { + if (node.kind === 213 || node.kind === 143 || node.kind === 142 || node.kind === 144) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -19137,16 +19590,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 213: + case 215: return 2097152; - case 216: + case 218: return d.name.kind === 9 || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 212: - case 215: + case 214: + case 217: return 2097152 | 1048576; - case 219: + case 221: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -19157,7 +19610,8 @@ var ts; } } function checkNonThenableType(type, location, message) { - if (!(type.flags & 1) && isTypeAssignableTo(type, getGlobalThenableType())) { + type = getWidenedType(type); + if (!isTypeAny(type) && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -19169,15 +19623,6 @@ var ts; return type; } function getPromisedType(promise) { - // - // { // promise - // then( // thenFunction - // onfulfilled: ( // onfulfilledParameterType - // value: T // valueParameterType - // ) => any - // ): any; - // } - // if (promise.flags & 1) { return undefined; } @@ -19281,22 +19726,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 212: + case 214: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 136: + case 138: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 139: + case 141: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 141: case 143: - case 144: + case 145: + case 146: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -19305,9 +19750,9 @@ var ts; checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 149) { + if (node && node.kind === 151) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 149 ? 793056 : 1536; + var meaning = root.parent.kind === 151 ? 793056 : 1536; var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); if (rootSymbol && rootSymbol.flags & 8388608) { var aliasTarget = resolveAlias(rootSymbol); @@ -19319,19 +19764,19 @@ var ts; } function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 139: + case 141: checkTypeNodeAsExpression(node.type); break; - case 136: + case 138: checkTypeNodeAsExpression(node.type); break; - case 141: + case 143: checkTypeNodeAsExpression(node.type); break; - case 143: + case 145: checkTypeNodeAsExpression(node.type); break; - case 144: + case 146: checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } @@ -19354,24 +19799,24 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 212: + case 214: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 141: - checkParameterTypeAnnotationsAsExpressions(node); - case 144: case 143: - case 139: - case 136: + checkParameterTypeAnnotationsAsExpressions(node); + case 146: + case 145: + case 141: + case 138: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 136) { + if (node.kind === 138) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -19389,12 +19834,9 @@ var ts; checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { - if (!compilerOptions.experimentalAsyncFunctions) { - error(node, ts.Diagnostics.Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning); - } emitAwaiter = true; } - if (node.name && node.name.kind === 134) { + if (node.name && node.name.kind === 136) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -19429,11 +19871,11 @@ var ts; } } function checkBlock(node) { - if (node.kind === 190) { + if (node.kind === 192) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 217) { + if (ts.isFunctionBlock(node) || node.kind === 219) { checkFunctionAndClassExpressionBodies(node); } } @@ -19451,19 +19893,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 139 || - node.kind === 138 || - node.kind === 141 || + if (node.kind === 141 || node.kind === 140 || node.kind === 143 || - node.kind === 144) { + node.kind === 142 || + node.kind === 145 || + node.kind === 146) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 136 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 138 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -19477,7 +19919,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 67; + var isDeclaration_1 = node.kind !== 69; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -19498,7 +19940,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 67; + var isDeclaration_2 = node.kind !== 69; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -19511,22 +19953,19 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 216 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 218 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 246 && ts.isExternalModule(parent)) { + if (parent.kind === 248 && 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)); } } function checkVarDeclaredNamesNotShadowed(node) { - // - ScriptBody : StatementList - // It is a Syntax Error if any element of the LexicallyDeclaredNames of StatementList - // also occurs in the VarDeclaredNames of StatementList. if ((ts.getCombinedNodeFlags(node) & 49152) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 209 && !node.initializer) { + if (node.kind === 211 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -19536,15 +19975,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 210); - var container = varDeclList.parent.kind === 191 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212); + var container = varDeclList.parent.kind === 193 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 190 && ts.isFunctionLike(container.parent) || - container.kind === 217 || - container.kind === 216 || - container.kind === 246); + (container.kind === 192 && ts.isFunctionLike(container.parent) || + container.kind === 219 || + container.kind === 218 || + container.kind === 248); if (!namesShareScope) { var name_15 = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_15, name_15); @@ -19554,16 +19993,16 @@ var ts; } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 136) { + if (ts.getRootDeclaration(node).kind !== 138) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 67) { + if (n.kind === 69) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 136) { + if (referencedSymbol.valueDeclaration.kind === 138) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -19583,7 +20022,7 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 134) { + if (node.name.kind === 136) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -19592,7 +20031,7 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 136 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 138 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -19620,9 +20059,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 139 && node.kind !== 138) { + if (node.kind !== 141 && node.kind !== 140) { checkExportsOnMergedDeclarations(node); - if (node.kind === 209 || node.kind === 161) { + if (node.kind === 211 || node.kind === 163) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -19643,7 +20082,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 163) { + if (node.modifiers && node.parent.kind === 165) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -19676,12 +20115,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 210) { + if (node.initializer && node.initializer.kind === 212) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 210) { + if (node.initializer.kind === 212) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -19696,13 +20135,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 210) { + if (node.initializer.kind === 212) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 162 || varExpr.kind === 163) { + if (varExpr.kind === 164 || varExpr.kind === 165) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -19717,7 +20156,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 210) { + if (node.initializer.kind === 212) { 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); @@ -19727,7 +20166,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 162 || varExpr.kind === 163) { + if (varExpr.kind === 164 || varExpr.kind === 165) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { @@ -19889,7 +20328,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 143 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 144))); + return !!(node.kind === 145 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 146))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -19907,10 +20346,10 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 144) { + if (func.kind === 146) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 142) { + else if (func.kind === 144) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -19919,7 +20358,9 @@ var ts; if (ts.isAsyncFunctionLike(func)) { var promisedType = getPromisedType(returnType); var awaitedType = checkAwaitedType(exprType, node.expression, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); - checkTypeAssignableTo(awaitedType, promisedType, node.expression); + if (promisedType) { + checkTypeAssignableTo(awaitedType, promisedType, node.expression); + } } else { checkTypeAssignableTo(exprType, returnType, node.expression); @@ -19943,7 +20384,7 @@ var ts; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 240 && !hasDuplicateDefaultClause) { + if (clause.kind === 242 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -19955,7 +20396,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 239) { + if (produceDiagnostics && clause.kind === 241) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { @@ -19972,7 +20413,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 205 && current.label.text === node.label.text) { + if (current.kind === 207 && 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; @@ -19998,7 +20439,7 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 67) { + if (catchClause.variableDeclaration.name.kind !== 69) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -20066,7 +20507,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 134 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 136 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -20119,9 +20560,6 @@ var ts; grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); - if (getSymbolOfNode(node).flags & 64 && !ts.isInAmbientContext(node)) { - error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); - } ts.forEach(node.members, checkSourceElement); } function checkClassLikeDeclaration(node) { @@ -20136,6 +20574,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { @@ -20154,7 +20593,7 @@ var ts; } } } - checkTypeAssignableTo(type, baseType, node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); 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); @@ -20167,7 +20606,8 @@ var ts; } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { - ts.forEach(implementedTypeNodes, function (typeRefNode) { + for (var _b = 0; _b < implementedTypeNodes.length; _b++) { + var typeRefNode = implementedTypeNodes[_b]; if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } @@ -20177,14 +20617,14 @@ var ts; if (t !== unknownType) { var declaredType = (t.flags & 4096) ? t.target : t; if (declaredType.flags & (1024 | 2048)) { - checkTypeAssignableTo(type, t, node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); } else { error(typeRefNode, ts.Diagnostics.A_class_may_only_implement_another_class_or_interface); } } } - }); + } } if (produceDiagnostics) { checkIndexConstraints(type); @@ -20194,20 +20634,10 @@ var ts; function getTargetSymbol(s) { return s.flags & 16777216 ? getSymbolLinks(s).target : s; } + function getClassLikeDeclarationOfSymbol(symbol) { + return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; }); + } function checkKindsOfPropertyMemberOverrides(type, baseType) { - // TypeScript 1.0 spec (April 2014): 8.2.3 - // A derived class inherits all members from its base class it doesn't override. - // Inheritance means that a derived class implicitly contains all non - overridden members of the base class. - // Both public and private property members are inherited, but only public property members can be overridden. - // A property member in a derived class is said to override a property member in a base class - // when the derived class property member has the same name and kind(instance or static) - // as the base class property member. - // The type of an overriding property member must be assignable(section 3.8.4) - // to the type of the overridden property member, or otherwise a compile - time error occurs. - // Base class instance member functions can be overridden by derived class instance member functions, - // but not by other kinds of members. - // Base class instance member variables and accessors can be overridden by - // derived class instance member variables and accessors, but not by other kinds of members. var baseProperties = getPropertiesOfObjectType(baseType); for (var _i = 0; _i < baseProperties.length; _i++) { var baseProperty = baseProperties[_i]; @@ -20220,9 +20650,14 @@ var ts; ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); if (derived) { if (derived === base) { - var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 212); + var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 256 && (!derivedClassDecl || !(derivedClassDecl.flags & 256))) { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + if (derivedClassDecl.kind === 186) { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); + } + else { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + } } } else { @@ -20261,7 +20696,7 @@ var ts; } } function isAccessor(kind) { - return kind === 143 || kind === 144; + return kind === 145 || kind === 146; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -20298,7 +20733,7 @@ var ts; var ok = true; for (var _i = 0; _i < baseTypes.length; _i++) { var base = baseTypes[_i]; - var properties = getPropertiesOfObjectType(base); + var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); for (var _a = 0; _a < properties.length; _a++) { var prop = properties[_a]; if (!ts.hasProperty(seen, prop.name)) { @@ -20327,7 +20762,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 213); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 215); 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); @@ -20335,20 +20770,13 @@ var ts; } if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); if (checkInheritedPropertiesAreIdentical(type, node.name)) { - ts.forEach(getBaseTypes(type), function (baseType) { - checkTypeAssignableTo(type, baseType, node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); - }); - checkIndexConstraints(type); - } - } - if (symbol && symbol.declarations) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 212 && !ts.isInAmbientContext(declaration)) { - error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); - break; + for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) { + var baseType = _a[_i]; + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); } + checkIndexConstraints(type); } } } @@ -20376,10 +20804,15 @@ var ts; var autoValue = 0; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); - ts.forEach(node.members, function (member) { - if (member.name.kind !== 134 && isNumericLiteralName(member.name.text)) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.name.kind === 136) { + error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); + } + else if (isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } + var previousEnumMemberIsNonConstant = autoValue === undefined; var initializer = member.initializer; if (initializer) { autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); @@ -20387,10 +20820,13 @@ var ts; else if (ambient && !enumIsConst) { autoValue = undefined; } + else if (previousEnumMemberIsNonConstant) { + error(member.name, ts.Diagnostics.Enum_member_must_have_initializer); + } if (autoValue !== undefined) { getNodeLinks(member).enumMemberValue = autoValue++; } - }); + } nodeLinks.flags |= 8192; } function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { @@ -20401,7 +20837,10 @@ var ts; if (enumIsConst) { error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); } - else if (!ambient) { + else if (ambient) { + error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); + } + else { checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); } } @@ -20417,7 +20856,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 177: + case 179: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -20425,10 +20864,10 @@ var ts; switch (e.operator) { case 35: return value_1; case 36: return -value_1; - case 49: return ~value_1; + case 50: return ~value_1; } return undefined; - case 179: + case 181: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -20438,37 +20877,37 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 46: return left | right; - case 45: return left & right; - case 43: return left >> right; - case 44: return left >>> right; - case 42: return left << right; - case 47: return left ^ right; + case 47: return left | right; + case 46: return left & right; + case 44: return left >> right; + case 45: return left >>> right; + case 43: return left << right; + case 48: return left ^ right; case 37: return left * right; - case 38: return left / right; + case 39: return left / right; case 35: return left + right; case 36: return left - right; - case 39: return left % right; + case 40: return left % right; } return undefined; case 8: return +e.text; - case 170: + case 172: return evalConstant(e.expression); - case 67: - case 165: - case 164: + case 69: + case 167: + case 166: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; var propertyName; - if (e.kind === 67) { + if (e.kind === 69) { enumType_1 = currentType; propertyName = e.text; } else { var expression; - if (e.kind === 165) { + if (e.kind === 167) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -20482,10 +20921,10 @@ var ts; } var current = expression; while (current) { - if (current.kind === 67) { + if (current.kind === 69) { break; } - else if (current.kind === 164) { + else if (current.kind === 166) { current = current.expression; } else { @@ -20508,7 +20947,7 @@ var ts; if (member === propertyDecl) { return undefined; } - if (!isDefinedBefore(propertyDecl, member)) { + if (!isBlockScopedNameDeclaredBeforeUse(propertyDecl, member)) { reportError = false; error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; @@ -20522,7 +20961,7 @@ var ts; if (!produceDiagnostics) { return; } - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -20544,7 +20983,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 215) { + if (declaration.kind !== 217) { return false; } var enumDeclaration = declaration; @@ -20567,8 +21006,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 212 || - (declaration.kind === 211 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 214 || + (declaration.kind === 213 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -20619,7 +21058,7 @@ 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, 212); + var mergedClass = ts.getDeclarationOfKind(symbol, 214); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -20627,9 +21066,9 @@ var ts; } if (isAmbientExternalModule) { if (!isGlobalSourceFile(node.parent)) { - error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules); + error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); } - if (isExternalModuleNameRelative(node.name.text)) { + if (ts.isExternalModuleNameRelative(node.name.text)) { error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); } } @@ -20638,17 +21077,17 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 133) { + if (node.kind === 135) { node = node.left; } - else if (node.kind === 164) { + else if (node.kind === 166) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 67); + ts.Debug.assert(node.kind === 69); return node; } function checkExternalImportOrExportDeclaration(node) { @@ -20657,14 +21096,14 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 217 && node.parent.parent.name.kind === 9; - if (node.parent.kind !== 246 && !inAmbientExternalModule) { - error(moduleName, node.kind === 226 ? + var inAmbientExternalModule = node.parent.kind === 219 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 248 && !inAmbientExternalModule) { + error(moduleName, node.kind === 228 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; } - if (inAmbientExternalModule && isExternalModuleNameRelative(moduleName.text)) { + if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) { error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); return false; } @@ -20678,7 +21117,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 228 ? + var message = node.kind === 230 ? 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)); @@ -20704,7 +21143,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 222) { + if (importClause.namedBindings.kind === 224) { checkImportBinding(importClause.namedBindings); } else { @@ -20739,8 +21178,8 @@ var ts; } } else { - if (languageVersion >= 2 && !ts.isInAmbientContext(node)) { - grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead); + if (modulekind === 5 && !ts.isInAmbientContext(node)) { + grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } } @@ -20755,8 +21194,8 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 217 && node.parent.parent.name.kind === 9; - if (node.parent.kind !== 246 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 219 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 248 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -20769,7 +21208,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 246 && node.parent.kind !== 217 && node.parent.kind !== 216) { + if (node.parent.kind !== 248 && node.parent.kind !== 219 && node.parent.kind !== 218) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -20783,15 +21222,15 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 246 ? node.parent : node.parent.parent; - if (container.kind === 216 && container.name.kind === 67) { + var container = node.parent.kind === 248 ? node.parent : node.parent.parent; + if (container.kind === 218 && container.name.kind === 69) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 67) { + if (node.expression.kind === 69) { markExportAsReferenced(node); } else { @@ -20799,19 +21238,19 @@ var ts; } checkExternalModuleExports(container); if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (languageVersion >= 2) { - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + if (modulekind === 5) { + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead); } - else if (compilerOptions.module === 4) { + else if (modulekind === 4) { grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); } } } function getModuleStatements(node) { - if (node.kind === 246) { + if (node.kind === 248) { return node.statements; } - if (node.kind === 216 && node.body.kind === 217) { + if (node.kind === 218 && node.body.kind === 219) { return node.body.statements; } return emptyArray; @@ -20848,183 +21287,182 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 216: - case 212: + case 218: + case 214: + case 215: case 213: - case 211: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 135: + case 137: return checkTypeParameter(node); - case 136: - return checkParameter(node); - case 139: case 138: + return checkParameter(node); + case 141: + case 140: return checkPropertyDeclaration(node); - case 150: - case 151: - case 145: - case 146: - return checkSignatureDeclaration(node); + case 152: + case 153: case 147: + case 148: + return checkSignatureDeclaration(node); + case 149: return checkSignatureDeclaration(node); - case 141: - case 140: - return checkMethodDeclaration(node); - case 142: - return checkConstructorDeclaration(node); case 143: + case 142: + return checkMethodDeclaration(node); case 144: + return checkConstructorDeclaration(node); + case 145: + case 146: return checkAccessorDeclaration(node); - case 149: + case 151: return checkTypeReferenceNode(node); - case 148: + case 150: return checkTypePredicate(node); - case 152: - return checkTypeQuery(node); - case 153: - return checkTypeLiteral(node); case 154: - return checkArrayType(node); + return checkTypeQuery(node); case 155: - return checkTupleType(node); + return checkTypeLiteral(node); case 156: + return checkArrayType(node); case 157: - return checkUnionOrIntersectionType(node); + return checkTupleType(node); case 158: + case 159: + return checkUnionOrIntersectionType(node); + case 160: return checkSourceElement(node.type); - case 211: + case 213: return checkFunctionDeclaration(node); - case 190: - case 217: + case 192: + case 219: return checkBlock(node); - case 191: - return checkVariableStatement(node); case 193: - return checkExpressionStatement(node); - case 194: - return checkIfStatement(node); + return checkVariableStatement(node); case 195: - return checkDoStatement(node); + return checkExpressionStatement(node); case 196: - return checkWhileStatement(node); + return checkIfStatement(node); case 197: - return checkForStatement(node); + return checkDoStatement(node); case 198: - return checkForInStatement(node); + return checkWhileStatement(node); case 199: - return checkForOfStatement(node); + return checkForStatement(node); case 200: + return checkForInStatement(node); case 201: - return checkBreakOrContinueStatement(node); + return checkForOfStatement(node); case 202: - return checkReturnStatement(node); case 203: - return checkWithStatement(node); + return checkBreakOrContinueStatement(node); case 204: - return checkSwitchStatement(node); + return checkReturnStatement(node); case 205: - return checkLabeledStatement(node); + return checkWithStatement(node); case 206: - return checkThrowStatement(node); + return checkSwitchStatement(node); case 207: - return checkTryStatement(node); + return checkLabeledStatement(node); + case 208: + return checkThrowStatement(node); case 209: + return checkTryStatement(node); + case 211: return checkVariableDeclaration(node); - case 161: + case 163: return checkBindingElement(node); - case 212: + case 214: return checkClassDeclaration(node); - case 213: + case 215: return checkInterfaceDeclaration(node); - case 214: + case 216: return checkTypeAliasDeclaration(node); - case 215: + case 217: return checkEnumDeclaration(node); - case 216: + case 218: return checkModuleDeclaration(node); - case 220: + case 222: return checkImportDeclaration(node); - case 219: + case 221: return checkImportEqualsDeclaration(node); - case 226: + case 228: return checkExportDeclaration(node); - case 225: + case 227: return checkExportAssignment(node); - case 192: + case 194: checkGrammarStatementInAmbientContext(node); return; - case 208: + case 210: checkGrammarStatementInAmbientContext(node); return; - case 229: + case 231: return checkMissingDeclaration(node); } } function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 171: - case 172: + case 173: + case 174: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 184: + case 186: ts.forEach(node.members, checkSourceElement); + ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; - case 141: - case 140: + case 143: + case 142: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 142: - case 143: case 144: - case 211: + case 145: + case 146: + case 213: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 203: + case 205: checkFunctionAndClassExpressionBodies(node.expression); break; - case 137: - case 136: case 139: case 138: - case 159: - case 160: + case 141: + case 140: case 161: case 162: case 163: - case 243: case 164: case 165: + case 245: case 166: case 167: case 168: - case 181: - case 188: case 169: - case 187: case 170: - case 174: - case 175: + case 183: + case 190: + case 171: + case 189: + case 172: case 176: - case 173: case 177: case 178: + case 175: case 179: case 180: - case 183: + case 181: case 182: - case 190: - case 217: - case 191: + case 185: + case 184: + case 192: + case 219: case 193: - case 194: case 195: case 196: case 197: @@ -21033,29 +21471,31 @@ var ts; case 200: case 201: case 202: + case 203: case 204: - case 218: - case 239: - case 240: - case 205: case 206: - case 207: + case 220: + case 241: case 242: + case 207: + case 208: case 209: - case 210: + case 244: + case 211: case 212: - case 241: - case 186: - case 215: - case 245: - case 225: - case 246: - case 238: - case 231: - case 232: - case 236: - case 237: + case 214: + case 243: + case 188: + case 217: + case 247: + case 227: + case 248: + case 240: case 233: + case 234: + case 238: + case 239: + case 235: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -21133,7 +21573,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 203 && node.parent.statement === node) { + if (node.parent.kind === 205 && node.parent.statement === node) { return true; } node = node.parent; @@ -21155,28 +21595,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 246: + case 248: if (!ts.isExternalModule(location)) { break; } - case 216: + case 218: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 215: + case 217: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 184: + case 186: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 212: - case 213: + case 214: + case 215: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 171: + case 173: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -21209,42 +21649,42 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 67 && + return name.kind === 69 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 135: - case 212: - case 213: + case 137: case 214: case 215: + case 216: + case 217: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 133) { + while (node.parent && node.parent.kind === 135) { node = node.parent; } - return node.parent && node.parent.kind === 149; + return node.parent && node.parent.kind === 151; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 164) { + while (node.parent && node.parent.kind === 166) { node = node.parent; } - return node.parent && node.parent.kind === 186; + return node.parent && node.parent.kind === 188; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 133) { + while (nodeOnRightSide.parent.kind === 135) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 219) { + if (nodeOnRightSide.parent.kind === 221) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 225) { + if (nodeOnRightSide.parent.kind === 227) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -21256,10 +21696,10 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 225) { + if (entityName.parent.kind === 227) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 164) { + if (entityName.kind !== 166) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -21268,31 +21708,40 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 186 ? 793056 : 1536; + var meaning = 0; + if (entityName.parent.kind === 188) { + meaning = 793056; + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + meaning |= 107455; + } + } + else { + meaning = 1536; + } meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 233) || - (entityName.parent.kind === 232) || - (entityName.parent.kind === 235)) { + else if ((entityName.parent.kind === 235) || + (entityName.parent.kind === 234) || + (entityName.parent.kind === 237)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 67) { + if (entityName.kind === 69) { var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 164) { + else if (entityName.kind === 166) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 133) { + else if (entityName.kind === 135) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -21301,14 +21750,14 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 149 ? 793056 : 1536; + var meaning = entityName.parent.kind === 151 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 236) { + else if (entityName.parent.kind === 238) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 148) { + if (entityName.parent.kind === 150) { return resolveEntityName(entityName, 1); } return undefined; @@ -21320,14 +21769,14 @@ var ts; if (ts.isDeclarationName(node)) { return getSymbolOfNode(node.parent); } - if (node.kind === 67) { + if (node.kind === 69) { if (isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 225 + return node.parent.kind === 227 ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } - else if (node.parent.kind === 161 && - node.parent.parent.kind === 159 && + else if (node.parent.kind === 163 && + node.parent.parent.kind === 161 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -21337,29 +21786,29 @@ var ts; } } switch (node.kind) { - case 67: - case 164: - case 133: + case 69: + case 166: + case 135: return getSymbolOfEntityNameOrPropertyAccessExpression(node); + case 97: case 95: - case 93: - var type = checkExpression(node); + var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 119: + case 121: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 142) { + if (constructorDeclaration && constructorDeclaration.kind === 144) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 220 || node.parent.kind === 226) && + ((node.parent.kind === 222 || node.parent.kind === 228) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 165 && node.parent.argumentExpression === node) { + if (node.parent.kind === 167 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -21373,7 +21822,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 244) { + if (location && location.kind === 246) { return resolveEntityName(location.name, 107455); } return undefined; @@ -21473,11 +21922,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 246) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 248) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 216 || n.kind === 215) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 218 || n.kind === 217) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -21490,11 +21939,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 190: - case 218: - case 197: - case 198: + case 192: + case 220: case 199: + case 200: + case 201: return true; } return false; @@ -21520,22 +21969,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 219: case 221: - case 222: + case 223: case 224: - case 228: - return isAliasResolvedToValue(getSymbolOfNode(node)); case 226: + case 230: + return isAliasResolvedToValue(getSymbolOfNode(node)); + case 228: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 225: - return node.expression && node.expression.kind === 67 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 227: + return node.expression && node.expression.kind === 69 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 246 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 248 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -21583,7 +22032,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 245) { + if (node.kind === 247) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -21669,21 +22118,6 @@ var ts; var symbol = getReferencedValueSymbol(reference); return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; } - function getBlockScopedVariableId(n) { - ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 161 || (n.parent.kind === 209 && 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 !== 242; - if (isLetOrConst) { - getSymbolLinks(symbol); - return symbol.id; - } - return undefined; - } function instantiateSingleCallFunctionType(functionType, typeArguments) { if (functionType === unknownType) { return unknownType; @@ -21715,7 +22149,6 @@ var ts; isEntityNameVisible: isEntityNameVisible, getConstantValue: getConstantValue, collectLinkedAliases: collectLinkedAliases, - getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, isOptionalParameter: isOptionalParameter @@ -21796,10 +22229,7 @@ var ts; if (!ts.nodeCanBeDecorated(node)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } - else if (languageVersion < 1) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (node.kind === 143 || node.kind === 144) { + else if (node.kind === 145 || node.kind === 146) { 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); @@ -21809,38 +22239,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 143: + case 145: + case 146: case 144: - case 142: - case 139: - case 138: case 141: case 140: - case 147: - case 216: - case 220: - case 219: - case 226: - case 225: - case 136: + case 143: + case 142: + case 149: + case 218: + case 222: + case 221: + case 228: + case 227: + case 138: break; - case 211: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 116) && - node.parent.kind !== 217 && node.parent.kind !== 246) { + case 213: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118) && + node.parent.kind !== 219 && node.parent.kind !== 248) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 212: - case 213: - case 191: case 214: - if (node.modifiers && node.parent.kind !== 217 && node.parent.kind !== 246) { + case 215: + case 193: + case 216: + if (node.modifiers && node.parent.kind !== 219 && node.parent.kind !== 248) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 215: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 72) && - node.parent.kind !== 217 && node.parent.kind !== 246) { + case 217: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74) && + node.parent.kind !== 219 && node.parent.kind !== 248) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -21855,14 +22285,14 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { + case 112: + case 111: case 110: - case 109: - case 108: var text = void 0; - if (modifier.kind === 110) { + if (modifier.kind === 112) { text = "public"; } - else if (modifier.kind === 109) { + else if (modifier.kind === 111) { text = "protected"; lastProtected = modifier; } @@ -21879,11 +22309,11 @@ var ts; else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 217 || node.parent.kind === 246) { + else if (node.parent.kind === 219 || node.parent.kind === 248) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 256) { - if (modifier.kind === 108) { + if (modifier.kind === 110) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -21892,17 +22322,17 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 111: + case 113: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 217 || node.parent.kind === 246) { + else if (node.parent.kind === 219 || node.parent.kind === 248) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 136) { + else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 256) { @@ -21911,7 +22341,7 @@ var ts; flags |= 128; lastStatic = modifier; break; - case 80: + case 82: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -21924,42 +22354,42 @@ var ts; else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 214) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 136) { + else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 120: + case 122: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 214) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 136) { + else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 217) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; - case 113: + case 115: if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 212) { - if (node.kind !== 141) { + if (node.kind !== 214) { + if (node.kind !== 143) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 212 && node.parent.flags & 256)) { + if (!(node.parent.kind === 214 && node.parent.flags & 256)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 128) { @@ -21971,14 +22401,14 @@ var ts; } flags |= 256; break; - case 116: + case 118: if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 136) { + else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 512; @@ -21986,7 +22416,7 @@ var ts; break; } } - if (node.kind === 142) { + if (node.kind === 144) { if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -22004,10 +22434,10 @@ var ts; } return; } - else if ((node.kind === 220 || node.kind === 219) && flags & 2) { + else if ((node.kind === 222 || node.kind === 221) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 136 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 138 && (flags & 112) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 512) { @@ -22019,10 +22449,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 141: - case 211: - case 171: - case 172: + case 143: + case 213: + case 173: + case 174: if (!node.asteriskToken) { return false; } @@ -22087,7 +22517,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 172) { + if (node.kind === 174) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -22122,7 +22552,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 !== 128 && parameter.type.kind !== 126) { + if (parameter.type.kind !== 130 && parameter.type.kind !== 128) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -22154,7 +22584,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < args.length; _i++) { var arg = args[_i]; - if (arg.kind === 185) { + if (arg.kind === 187) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -22181,7 +22611,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 81) { + if (heritageClause.token === 83) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -22194,7 +22624,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 104); + ts.Debug.assert(heritageClause.token === 106); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -22209,14 +22639,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 81) { + if (heritageClause.token === 83) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 104); + ts.Debug.assert(heritageClause.token === 106); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -22225,19 +22655,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 134) { + if (node.kind !== 136) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 179 && computedPropertyName.expression.operatorToken.kind === 24) { + if (computedPropertyName.expression.kind === 181 && computedPropertyName.expression.operatorToken.kind === 24) { 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 === 211 || - node.kind === 171 || - node.kind === 141); + ts.Debug.assert(node.kind === 213 || + node.kind === 173 || + node.kind === 143); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -22254,7 +22684,7 @@ var ts; return grammarErrorOnNode(questionToken, message); } } - function checkGrammarObjectLiteralExpression(node) { + function checkGrammarObjectLiteralExpression(node, inDestructuring) { var seen = {}; var Property = 1; var GetAccessor = 2; @@ -22263,26 +22693,29 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_17 = prop.name; - if (prop.kind === 185 || - name_17.kind === 134) { + if (prop.kind === 187 || + name_17.kind === 136) { checkGrammarComputedPropertyName(name_17); continue; } + if (prop.kind === 246 && !inDestructuring && prop.objectAssignmentInitializer) { + return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); + } var currentKind = void 0; - if (prop.kind === 243 || prop.kind === 244) { + if (prop.kind === 245 || prop.kind === 246) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_17.kind === 8) { checkGrammarNumericLiteral(name_17); } currentKind = Property; } - else if (prop.kind === 141) { + else if (prop.kind === 143) { currentKind = Property; } - else if (prop.kind === 143) { + else if (prop.kind === 145) { currentKind = GetAccessor; } - else if (prop.kind === 144) { + else if (prop.kind === 146) { currentKind = SetAccesor; } else { @@ -22314,7 +22747,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 237) { + if (attr.kind === 239) { continue; } var jsxAttr = attr; @@ -22326,7 +22759,7 @@ var ts; return grammarErrorOnNode(name_18, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 238 && !initializer.expression) { + if (initializer && initializer.kind === 240 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -22335,24 +22768,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 210) { + if (forInOrOfStatement.initializer.kind === 212) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 198 + var diagnostic = forInOrOfStatement.kind === 200 ? 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 === 198 + var diagnostic = forInOrOfStatement.kind === 200 ? 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 === 198 + var diagnostic = forInOrOfStatement.kind === 200 ? 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); @@ -22375,10 +22808,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 143 && accessor.parameters.length) { + else if (kind === 145 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 144) { + else if (kind === 146) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -22403,7 +22836,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 134 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 136 && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -22413,7 +22846,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 163) { + if (node.parent.kind === 165) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -22432,22 +22865,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 === 213) { + else if (node.parent.kind === 215) { 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 === 153) { + else if (node.parent.kind === 155) { 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 199: + case 200: + case 201: case 197: case 198: - case 199: - case 195: - case 196: return true; - case 205: + case 207: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -22459,9 +22892,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 205: + case 207: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 200 + var isMisplacedContinueLabel = node.kind === 202 && !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); @@ -22469,8 +22902,8 @@ var ts; return false; } break; - case 204: - if (node.kind === 201 && !node.label) { + case 206: + if (node.kind === 203 && !node.label) { return false; } break; @@ -22483,13 +22916,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 201 + var message = node.kind === 203 ? 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 === 201 + var message = node.kind === 203 ? 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); @@ -22501,7 +22934,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 === 160 || node.name.kind === 159) { + if (node.name.kind === 162 || node.name.kind === 161) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -22510,7 +22943,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 198 && node.parent.parent.kind !== 199) { + if (node.parent.parent.kind !== 200 && node.parent.parent.kind !== 201) { if (ts.isInAmbientContext(node)) { if (node.initializer) { var equalsTokenLength = "=".length; @@ -22530,7 +22963,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 67) { + if (name.kind === 69) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -22539,7 +22972,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 185) { + if (element.kind !== 187) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -22556,15 +22989,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 194: - case 195: case 196: - case 203: case 197: case 198: + case 205: case 199: + case 200: + case 201: return false; - case 205: + case 207: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -22580,7 +23013,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 177) { + if (expression.kind === 179) { var unaryExpression = expression; if (unaryExpression.operator === 35 || unaryExpression.operator === 36) { expression = unaryExpression.operand; @@ -22591,32 +23024,6 @@ var ts; } return false; } - function checkGrammarEnumDeclaration(enumDecl) { - var enumIsConst = (enumDecl.flags & 32768) !== 0; - var hasError = false; - if (!enumIsConst) { - var inConstantEnumMemberSection = true; - var inAmbientContext = ts.isInAmbientContext(enumDecl); - for (var _i = 0, _a = enumDecl.members; _i < _a.length; _i++) { - var node = _a[_i]; - if (node.name.kind === 134) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); - } - else if (inAmbientContext) { - if (node.initializer && !isIntegerLiteral(node.initializer)) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers) || hasError; - } - } - else if (node.initializer) { - inConstantEnumMemberSection = isIntegerLiteral(node.initializer); - } - else if (!inConstantEnumMemberSection) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Enum_member_must_have_initializer) || hasError; - } - } - } - return hasError; - } function hasParseDiagnostics(sourceFile) { return sourceFile.parseDiagnostics.length > 0; } @@ -22642,7 +23049,7 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 67 && + return node.kind === 69 && (node.text === "eval" || node.text === "arguments"); } function checkGrammarConstructorTypeParameters(node) { @@ -22662,12 +23069,12 @@ var ts; return true; } } - else if (node.parent.kind === 213) { + else if (node.parent.kind === 215) { 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 === 153) { + else if (node.parent.kind === 155) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -22677,11 +23084,11 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 213 || - node.kind === 220 || - node.kind === 219 || - node.kind === 226 || - node.kind === 225 || + if (node.kind === 215 || + node.kind === 222 || + node.kind === 221 || + node.kind === 228 || + node.kind === 227 || (node.flags & 2) || (node.flags & (1 | 1024))) { return false; @@ -22691,7 +23098,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 === 191) { + if (ts.isDeclaration(decl) || decl.kind === 193) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -22710,7 +23117,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 === 190 || node.parent.kind === 217 || node.parent.kind === 246) { + if (node.parent.kind === 192 || node.parent.kind === 219 || node.parent.kind === 248) { 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); @@ -22736,7 +23143,6 @@ var ts; } ts.createTypeChecker = createTypeChecker; })(ts || (ts = {})); -/// var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, targetSourceFile) { @@ -22758,6 +23164,7 @@ var ts; var enclosingDeclaration; var currentSourceFile; var reportedDeclarationError = false; + var errorNameNode; var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var moduleElementDeclarationEmitInfo = []; @@ -22783,7 +23190,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 220); + ts.Debug.assert(aliasEmitInfo.node.kind === 222); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -22834,6 +23241,7 @@ var ts; function createAndSetNewTextWriterWithSymbolWriter() { var writer = ts.createTextWriter(newLine); writer.trackSymbol = trackSymbol; + writer.reportInaccessibleThisError = reportInaccessibleThisError; writer.writeKeyword = writer.write; writer.writeOperator = writer.write; writer.writePunctuation = writer.write; @@ -22856,10 +23264,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 209) { + if (declaration.kind === 211) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 223 || declaration.kind === 224 || declaration.kind === 221) { + else if (declaration.kind === 225 || declaration.kind === 226 || declaration.kind === 223) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -22870,7 +23278,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 220) { + if (moduleElementEmitInfo.node.kind === 222) { moduleElementEmitInfo.isVisible = true; } else { @@ -22878,12 +23286,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 216) { + if (nodeToCheck.kind === 218) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 216) { + if (nodeToCheck.kind === 218) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -22915,6 +23323,11 @@ var ts; function trackSymbol(symbol, enclosingDeclaration, meaning) { handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); } + function reportInaccessibleThisError() { + if (errorNameNode) { + diagnostics.push(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode))); + } + } function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); @@ -22922,7 +23335,9 @@ var ts; emitType(type); } else { + errorNameNode = declaration.name; resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2, writer); + errorNameNode = undefined; } } function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) { @@ -22932,7 +23347,9 @@ var ts; emitType(signature.type); } else { + errorNameNode = signature.name; resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2, writer); + errorNameNode = undefined; } } function emitLines(nodes) { @@ -22970,62 +23387,63 @@ var ts; } function emitType(type) { switch (type.kind) { - case 115: + case 117: + case 130: case 128: - case 126: - case 118: - case 129: - case 101: + case 120: + case 131: + case 103: + case 97: case 9: return writeTextOfNode(currentSourceFile, type); - case 186: + case 188: return emitExpressionWithTypeArguments(type); - case 149: + case 151: return emitTypeReference(type); - case 152: - return emitTypeQuery(type); case 154: + return emitTypeQuery(type); + case 156: return emitArrayType(type); - case 155: + case 157: return emitTupleType(type); - case 156: + case 158: return emitUnionType(type); - case 157: + case 159: return emitIntersectionType(type); - case 158: + case 160: return emitParenType(type); - case 150: - case 151: - return emitSignatureDeclarationWithJsDocComments(type); + case 152: case 153: + return emitSignatureDeclarationWithJsDocComments(type); + case 155: return emitTypeLiteral(type); - case 67: + case 69: return emitEntityName(type); - case 133: + case 135: return emitEntityName(type); - case 148: + case 150: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 67) { + if (entityName.kind === 69) { writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 133 ? entityName.left : entityName.expression; - var right = entityName.kind === 133 ? entityName.right : entityName.name; + var left = entityName.kind === 135 ? entityName.left : entityName.expression; + var right = entityName.kind === 135 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 219 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 221 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 67 || node.expression.kind === 164); + ts.Debug.assert(node.expression.kind === 69 || node.expression.kind === 166); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -23101,7 +23519,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 67) { + if (node.expression.kind === 69) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -23119,7 +23537,7 @@ var ts; } write(";"); writeLine(); - if (node.expression.kind === 67) { + if (node.expression.kind === 69) { var nodes = resolver.collectLinkedAliases(node.expression); writeAsynchronousModuleElements(nodes); } @@ -23137,10 +23555,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 219 || - (node.parent.kind === 246 && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 221 || + (node.parent.kind === 248 && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 246) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 248) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -23149,7 +23567,7 @@ var ts; }); } else { - if (node.kind === 220) { + if (node.kind === 222) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -23167,23 +23585,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 211: + case 213: return writeFunctionDeclaration(node); - case 191: + case 193: return writeVariableStatement(node); - case 213: + case 215: return writeInterfaceDeclaration(node); - case 212: - return writeClassDeclaration(node); case 214: + return writeClassDeclaration(node); + case 216: return writeTypeAliasDeclaration(node); - case 215: + case 217: return writeEnumDeclaration(node); - case 216: + case 218: return writeModuleDeclaration(node); - case 219: + case 221: return writeImportEqualsDeclaration(node); - case 220: + case 222: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -23197,7 +23615,7 @@ var ts; if (node.flags & 1024) { write("default "); } - else if (node.kind !== 213) { + else if (node.kind !== 215) { write("declare "); } } @@ -23244,7 +23662,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 222) { + if (namedBindings.kind === 224) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -23270,7 +23688,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 222) { + if (node.importClause.namedBindings.kind === 224) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -23326,7 +23744,7 @@ var ts; write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 217) { + while (node.body.kind !== 219) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -23391,7 +23809,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 141 && (node.parent.flags & 32); + return node.parent.kind === 143 && (node.parent.flags & 32); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -23401,15 +23819,15 @@ var ts; writeTextOfNode(currentSourceFile, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 150 || - node.parent.kind === 151 || - (node.parent.parent && node.parent.parent.kind === 153)) { - ts.Debug.assert(node.parent.kind === 141 || - node.parent.kind === 140 || - node.parent.kind === 150 || - node.parent.kind === 151 || - node.parent.kind === 145 || - node.parent.kind === 146); + if (node.parent.kind === 152 || + node.parent.kind === 153 || + (node.parent.parent && node.parent.parent.kind === 155)) { + ts.Debug.assert(node.parent.kind === 143 || + node.parent.kind === 142 || + node.parent.kind === 152 || + node.parent.kind === 153 || + node.parent.kind === 147 || + node.parent.kind === 148); emitType(node.constraint); } else { @@ -23419,31 +23837,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 212: + case 214: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 213: + case 215: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 146: + case 148: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 145: + case 147: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 141: - case 140: + case 143: + case 142: 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 === 212) { + else if (node.parent.parent.kind === 214) { 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 211: + case 213: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -23471,12 +23889,12 @@ var ts; if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } - else if (!isImplementsList && node.expression.kind === 91) { + else if (!isImplementsList && node.expression.kind === 93) { write("null"); } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 212) { + if (node.parent.parent.kind === 214) { 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; @@ -23556,16 +23974,16 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 209 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 211 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 139 || node.kind === 138) && ts.hasQuestionToken(node)) { + if ((node.kind === 141 || node.kind === 140) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 139 || node.kind === 138) && node.parent.kind === 153) { + if ((node.kind === 141 || node.kind === 140) && node.parent.kind === 155) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32)) { @@ -23574,14 +23992,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 209) { + if (node.kind === 211) { 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 === 139 || node.kind === 138) { + else if (node.kind === 141 || node.kind === 140) { if (node.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23589,7 +24007,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 === 212) { + else if (node.parent.kind === 214) { 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 : @@ -23615,7 +24033,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 185) { + if (element.kind !== 187) { elements.push(element); } } @@ -23681,7 +24099,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 143 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 145 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -23694,7 +24112,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 143 + return accessor.kind === 145 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -23703,7 +24121,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 144) { + if (accessorWithTypeAnnotation.kind === 146) { 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 : @@ -23749,17 +24167,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 211) { + if (node.kind === 213) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 141) { + else if (node.kind === 143) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 211) { + if (node.kind === 213) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 142) { + else if (node.kind === 144) { write("constructor"); } else { @@ -23776,11 +24194,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 146 || node.kind === 151) { + if (node.kind === 148 || node.kind === 153) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 147) { + if (node.kind === 149) { write("["); } else { @@ -23789,20 +24207,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 147) { + if (node.kind === 149) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 150 || node.kind === 151; - if (isFunctionTypeOrConstructorType || node.parent.kind === 153) { + var isFunctionTypeOrConstructorType = node.kind === 152 || node.kind === 153; + if (isFunctionTypeOrConstructorType || node.parent.kind === 155) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 142 && !(node.flags & 32)) { + else if (node.kind !== 144 && !(node.flags & 32)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -23813,23 +24231,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 146: + case 148: 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 145: + case 147: 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 147: + case 149: 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 141: - case 140: + case 143: + case 142: if (node.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23837,7 +24255,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 === 212) { + else if (node.parent.kind === 214) { 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 : @@ -23850,7 +24268,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 211: + case 213: 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 : @@ -23882,9 +24300,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 150 || - node.parent.kind === 151 || - node.parent.parent.kind === 153) { + if (node.parent.kind === 152 || + node.parent.kind === 153 || + node.parent.parent.kind === 155) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32)) { @@ -23900,22 +24318,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 142: + case 144: 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 146: + case 148: 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 145: + case 147: 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 141: - case 140: + case 143: + case 142: if (node.parent.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23923,7 +24341,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 === 212) { + else if (node.parent.parent.kind === 214) { 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 : @@ -23935,7 +24353,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 211: + case 213: 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 : @@ -23946,12 +24364,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 159) { + if (bindingPattern.kind === 161) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 160) { + else if (bindingPattern.kind === 162) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -23970,10 +24388,10 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 185) { + if (bindingElement.kind === 187) { write(" "); } - else if (bindingElement.kind === 161) { + else if (bindingElement.kind === 163) { if (bindingElement.propertyName) { writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); @@ -23983,7 +24401,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 67); + ts.Debug.assert(bindingElement.name.kind === 69); if (bindingElement.dotDotDotToken) { write("..."); } @@ -23995,39 +24413,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 211: - case 216: - case 219: case 213: - case 212: - case 214: + case 218: + case 221: case 215: + case 214: + case 216: + case 217: return emitModuleElement(node, isModuleElementVisible(node)); - case 191: + case 193: return emitModuleElement(node, isVariableStatementVisible(node)); - case 220: + case 222: return emitModuleElement(node, !node.importClause); - case 226: + case 228: return emitExportDeclaration(node); + case 144: + case 143: case 142: - case 141: - case 140: return writeFunctionDeclaration(node); - case 146: - case 145: + case 148: case 147: + case 149: return emitSignatureDeclarationWithJsDocComments(node); - case 143: - case 144: + case 145: + case 146: return emitAccessorDeclaration(node); - case 139: - case 138: + case 141: + case 140: return emitPropertyDeclaration(node); - case 245: + case 247: return emitEnumMemberDeclaration(node); - case 225: + case 227: return emitExportAssignment(node); - case 246: + case 248: return emitSourceFile(node); } } @@ -24064,22 +24482,276 @@ var ts; } ts.writeDeclarationFile = writeDeclarationFile; })(ts || (ts = {})); -/// -/// var ts; (function (ts) { function isExternalModuleOrDeclarationFile(sourceFile) { return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); } ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; + var entities = { + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }; 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 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 decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\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};"; var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 ? 5 : 0; var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; var diagnostics = []; var newLine = host.getNewLine(); @@ -24158,6 +24830,15 @@ var ts; var scopeEmitStart = function (scopeDeclaration, scopeName) { }; var scopeEmitEnd = function () { }; var sourceMapData; + var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; + var moduleEmitDelegates = (_a = {}, + _a[5] = emitES6Module, + _a[2] = emitAMDModule, + _a[4] = emitSystemModule, + _a[3] = emitUMDModule, + _a[1] = emitCommonJSModule, + _a + ); if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { initializeEmitterWithSourceMaps(); } @@ -24234,19 +24915,19 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 67: + case 69: return makeUniqueName(node.text); - case 216: - case 215: + case 218: + case 217: return generateNameForModuleOrEnum(node); - case 220: - case 226: + case 222: + case 228: return generateNameForImportOrExportDeclaration(node); - case 211: - case 212: - case 225: + case 213: + case 214: + case 227: return generateNameForExportDefault(); - case 184: + case 186: return generateNameForClassExpression(); } } @@ -24385,7 +25066,7 @@ var ts; var parentIndex = getSourceMapNameIndex(); if (parentIndex !== -1) { var name_22 = node.name; - if (!name_22 || name_22.kind !== 134) { + if (!name_22 || name_22.kind !== 136) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -24402,18 +25083,18 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 211 || - node.kind === 171 || - node.kind === 141 || - node.kind === 140 || + else if (node.kind === 213 || + node.kind === 173 || node.kind === 143 || - node.kind === 144 || - node.kind === 216 || - node.kind === 212 || - node.kind === 215) { + node.kind === 142 || + node.kind === 145 || + node.kind === 146 || + node.kind === 218 || + node.kind === 214 || + node.kind === 217) { if (node.name) { var name_23 = node.name; - scopeName = name_23.kind === 134 + scopeName = name_23.kind === 136 ? ts.getTextOfNode(name_23) : node.name.text; } @@ -24512,7 +25193,7 @@ var ts; if (ts.nodeIsSynthesized(node)) { return emitNodeWithoutSourceMap(node); } - if (node.kind !== 246) { + if (node.kind !== 248) { recordEmitNodeStartSpan(node); emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); @@ -24539,7 +25220,7 @@ var ts; ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); } function createTempVariable(flags) { - var result = ts.createSynthesizedNode(67); + var result = ts.createSynthesizedNode(69); result.text = makeTempVariableName(flags); return result; } @@ -24762,10 +25443,10 @@ var ts; emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); - if (node.template.kind === 181) { + if (node.template.kind === 183) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 179 + var needsParens = templateSpan.expression.kind === 181 && templateSpan.expression.operatorToken.kind === 24; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -24789,7 +25470,7 @@ var ts; } for (var i = 0, n = node.templateSpans.length; i < n; i++) { var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 170 + var needsParens = templateSpan.expression.kind !== 172 && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; if (i > 0 || headEmitted) { write(" + "); @@ -24804,29 +25485,16 @@ var ts; write(")"); } function shouldEmitTemplateHead() { - // If this expression has an empty head literal and the first template span has a non-empty - // literal, then emitting the empty head literal is not necessary. - // `${ foo } and ${ bar }` - // can be emitted as - // foo + " and " + bar - // This is because it is only required that one of the first two operands in the emit - // output must be a string literal, so that the other operand and all following operands - // are forced into strings. - // - // If the first template span has an empty literal, then the head must still be emitted. - // `${ foo }${ bar }` - // must still be emitted as - // "" + foo + bar ts.Debug.assert(node.templateSpans.length !== 0); return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 166: - case 167: - return parent.expression === template; case 168: + case 169: + return parent.expression === template; case 170: + case 172: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1; @@ -24834,11 +25502,11 @@ var ts; } function comparePrecedenceToBinaryPlus(expression) { switch (expression.kind) { - case 179: + case 181: switch (expression.operatorToken.kind) { case 37: - case 38: case 39: + case 40: return 1; case 35: case 36: @@ -24846,8 +25514,8 @@ var ts; default: return -1; } + case 184: case 182: - case 180: return -1; default: return 1; @@ -24860,7 +25528,7 @@ var ts; } function jsxEmitReact(node) { function emitTagName(name) { - if (name.kind === 67 && ts.isIntrinsicJsxName(name.text)) { + if (name.kind === 69 && ts.isIntrinsicJsxName(name.text)) { write("\""); emit(name); write("\""); @@ -24890,8 +25558,8 @@ var ts; } } function emitJsxElement(openingNode, children) { - var syntheticReactRef = ts.createSynthesizedNode(67); - syntheticReactRef.text = 'React'; + var syntheticReactRef = ts.createSynthesizedNode(69); + syntheticReactRef.text = "React"; syntheticReactRef.parent = openingNode; emitLeadingComments(openingNode); emitExpressionIdentifier(syntheticReactRef); @@ -24903,12 +25571,12 @@ var ts; } else { var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 237; })) { + if (ts.forEach(attrs, function (attr) { return attr.kind === 239; })) { emitExpressionIdentifier(syntheticReactRef); write(".__spread("); var haveOpenedObjectLiteral = false; for (var i_1 = 0; i_1 < attrs.length; i_1++) { - if (attrs[i_1].kind === 237) { + if (attrs[i_1].kind === 239) { if (i_1 === 0) { write("{}, "); } @@ -24922,7 +25590,7 @@ var ts; emit(attrs[i_1].expression); } else { - ts.Debug.assert(attrs[i_1].kind === 236); + ts.Debug.assert(attrs[i_1].kind === 238); if (haveOpenedObjectLiteral) { write(", "); } @@ -24953,10 +25621,10 @@ var ts; } if (children) { for (var i = 0; i < children.length; i++) { - if (children[i].kind === 238 && !(children[i].expression)) { + if (children[i].kind === 240 && !(children[i].expression)) { continue; } - if (children[i].kind === 234) { + if (children[i].kind === 236) { var text = getTextToEmit(children[i]); if (text !== undefined) { write(", \""); @@ -24973,11 +25641,11 @@ var ts; write(")"); emitTrailingComments(openingNode); } - if (node.kind === 231) { + if (node.kind === 233) { emitJsxElement(node.openingElement, node.children); } else { - ts.Debug.assert(node.kind === 232); + ts.Debug.assert(node.kind === 234); emitJsxElement(node); } } @@ -24999,11 +25667,11 @@ var ts; if (i > 0) { write(" "); } - if (attribs[i].kind === 237) { + if (attribs[i].kind === 239) { emitJsxSpreadAttribute(attribs[i]); } else { - ts.Debug.assert(attribs[i].kind === 236); + ts.Debug.assert(attribs[i].kind === 238); emitJsxAttribute(attribs[i]); } } @@ -25011,11 +25679,11 @@ var ts; function emitJsxOpeningOrSelfClosingElement(node) { write("<"); emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 232)) { + if (node.attributes.length > 0 || (node.kind === 234)) { write(" "); } emitAttributes(node.attributes); - if (node.kind === 232) { + if (node.kind === 234) { write("/>"); } else { @@ -25034,20 +25702,20 @@ var ts; } emitJsxClosingElement(node.closingElement); } - if (node.kind === 231) { + if (node.kind === 233) { emitJsxElement(node); } else { - ts.Debug.assert(node.kind === 232); + ts.Debug.assert(node.kind === 234); emitJsxOpeningOrSelfClosingElement(node); } } function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 161); + ts.Debug.assert(node.kind !== 163); if (node.kind === 9) { emitLiteral(node); } - else if (node.kind === 134) { + else if (node.kind === 136) { if (ts.nodeIsDecorated(node.parent)) { if (!computedPropertyNamesToGeneratedNames) { computedPropertyNamesToGeneratedNames = []; @@ -25078,60 +25746,61 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 162: - case 179: - case 166: - case 239: - case 134: - case 180: - case 137: - case 173: - case 195: - case 165: - case 225: - case 193: - case 186: + case 164: + case 189: + case 181: + case 168: + case 241: + case 136: + case 182: + case 139: + case 175: case 197: - case 198: - case 199: - case 194: - case 232: - case 233: - case 237: - case 238: case 167: - case 170: - case 178: - case 177: - case 202: - case 244: - case 183: - case 204: - case 168: + case 227: + case 195: case 188: - case 206: - case 169: - case 174: - case 175: + case 199: + case 200: + case 201: case 196: - case 203: - case 182: + case 234: + case 235: + case 239: + case 240: + case 169: + case 172: + case 180: + case 179: + case 204: + case 246: + case 185: + case 206: + case 170: + case 190: + case 208: + case 171: + case 176: + case 177: + case 198: + case 205: + case 184: return true; - case 161: + case 163: + case 247: + case 138: case 245: - case 136: - case 243: - case 139: - case 209: + case 141: + case 211: return parent.initializer === node; - case 164: + case 166: return parent.expression === node; - case 172: - case 171: + case 174: + case 173: return parent.body === node; - case 219: + case 221: return parent.moduleReference === node; - case 133: + case 135: return parent.left === node; } return false; @@ -25143,8 +25812,8 @@ var ts; } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 246) { - if (languageVersion < 2 && compilerOptions.module !== 4) { + if (container.kind === 248) { + if (modulekind !== 5 && modulekind !== 4) { write("exports."); } } @@ -25153,18 +25822,25 @@ var ts; write("."); } } - else if (languageVersion < 2) { + else if (modulekind !== 5) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 221) { + if (declaration.kind === 223) { write(getGeneratedNameForNode(declaration.parent)); write(languageVersion === 0 ? "[\"default\"]" : ".default"); return; } - else if (declaration.kind === 224) { + else if (declaration.kind === 226) { write(getGeneratedNameForNode(declaration.parent.parent.parent)); - write("."); - writeTextOfNode(currentSourceFile, declaration.propertyName || declaration.name); + var name_24 = declaration.propertyName || declaration.name; + var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name_24); + if (languageVersion === 0 && identifier === "default") { + write("[\"default\"]"); + } + else { + write("."); + write(identifier); + } return; } } @@ -25185,10 +25861,10 @@ var ts; if (languageVersion < 2) { var parent_6 = node.parent; switch (parent_6.kind) { - case 161: - case 212: - case 215: - case 209: + case 163: + case 214: + case 217: + case 211: return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); } } @@ -25266,7 +25942,7 @@ var ts; emit(node.expression); } function emitYieldExpression(node) { - write(ts.tokenToString(112)); + write(ts.tokenToString(114)); if (node.asteriskToken) { write("*"); } @@ -25280,7 +25956,7 @@ var ts; if (needsParenthesis) { write("("); } - write(ts.tokenToString(112)); + write(ts.tokenToString(114)); write(" "); emit(node.expression); if (needsParenthesis) { @@ -25288,22 +25964,22 @@ var ts; } } function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 179 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + if (node.parent.kind === 181 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { return true; } - else if (node.parent.kind === 180 && node.parent.condition === node) { + else if (node.parent.kind === 182 && node.parent.condition === node) { return true; } return false; } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { - case 67: - case 162: + case 69: case 164: - case 165: case 166: - case 170: + case 167: + case 168: + case 172: return false; } return true; @@ -25320,17 +25996,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 183) { + if (e.kind === 185) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 162) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 164) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 183) { + while (i < length && elements[i].kind !== 185) { i++; } write("["); @@ -25353,7 +26029,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 183; + return node.kind === 185; } function emitArrayLiteral(node) { var elements = node.elements; @@ -25414,7 +26090,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 143 || property.kind === 144) { + if (property.kind === 145 || property.kind === 146) { var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { continue; @@ -25465,13 +26141,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 243) { + if (property.kind === 245) { emit(property.initializer); } - else if (property.kind === 244) { + else if (property.kind === 246) { emitExpressionIdentifier(property.name); } - else if (property.kind === 141) { + else if (property.kind === 143) { emitFunctionDeclaration(property); } else { @@ -25503,7 +26179,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 === 134) { + if (properties[i].name.kind === 136) { numInitialNonComputedProperties = i; break; } @@ -25517,35 +26193,35 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(179, startsOnNewLine); + var result = ts.createSynthesizedNode(181, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(164); + var result = ts.createSynthesizedNode(166); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(21); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(165); + var result = ts.createSynthesizedNode(167); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; } function parenthesizeForAccess(expr) { - while (expr.kind === 169 || expr.kind === 187) { + while (expr.kind === 171 || expr.kind === 189) { expr = expr.expression; } if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 167 && + expr.kind !== 169 && expr.kind !== 8) { return expr; } - var node = ts.createSynthesizedNode(170); + var node = ts.createSynthesizedNode(172); node.expression = expr; return node; } @@ -25572,7 +26248,7 @@ var ts; } function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 246; + return container && container.kind !== 248; } function emitShorthandPropertyAssignment(node) { writeTextOfNode(currentSourceFile, node.name); @@ -25580,13 +26256,17 @@ var ts; write(": "); emit(node.name); } + if (languageVersion >= 2 && node.objectAssignmentInitializer) { + write(" = "); + emit(node.objectAssignmentInitializer); + } } function tryEmitConstantValue(node) { var constantValue = tryGetConstEnumValue(node); if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 164 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 166 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -25597,7 +26277,7 @@ var ts; if (compilerOptions.isolatedModules) { return undefined; } - return node.kind === 164 || node.kind === 165 + return node.kind === 166 || node.kind === 167 ? resolver.getConstantValue(node) : undefined; } @@ -25649,7 +26329,7 @@ var ts; emit(node.right); } function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 67) { + if (node.left.kind === 69) { emitEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -25669,7 +26349,7 @@ var ts; } function emitEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 67: + case 69: if (useFallback) { write("typeof "); emitExpressionIdentifier(node); @@ -25677,7 +26357,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 133: + case 135: emitQualifiedNameAsExpression(node, useFallback); break; } @@ -25692,16 +26372,16 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 183; }); + return ts.forEach(elements, function (e) { return e.kind === 185; }); } function skipParentheses(node) { - while (node.kind === 170 || node.kind === 169 || node.kind === 187) { + while (node.kind === 172 || node.kind === 171 || node.kind === 189) { node = node.expression; } return node; } function emitCallTarget(node) { - if (node.kind === 67 || node.kind === 95 || node.kind === 93) { + if (node.kind === 69 || node.kind === 97 || node.kind === 95) { emit(node); return node; } @@ -25716,18 +26396,18 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 164) { + if (expr.kind === 166) { target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 165) { + else if (expr.kind === 167) { target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); write("]"); } - else if (expr.kind === 93) { + else if (expr.kind === 95) { target = expr; write("_super"); } @@ -25736,7 +26416,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 93) { + if (target.kind === 95) { emitThis(target); } else { @@ -25756,13 +26436,13 @@ var ts; return; } var superCall = false; - if (node.expression.kind === 93) { + if (node.expression.kind === 95) { emitSuper(node.expression); superCall = true; } else { emit(node.expression); - superCall = node.expression.kind === 164 && node.expression.expression.kind === 93; + superCall = node.expression.kind === 166 && node.expression.expression.kind === 95; } if (superCall && languageVersion < 2) { write(".call("); @@ -25813,20 +26493,21 @@ var ts; } } function emitParenExpression(node) { - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 172) { - if (node.expression.kind === 169 || node.expression.kind === 187) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 174) { + if (node.expression.kind === 171 || node.expression.kind === 189) { var operand = node.expression.expression; - while (operand.kind === 169 || operand.kind === 187) { + while (operand.kind === 171 || operand.kind === 189) { operand = operand.expression; } - if (operand.kind !== 177 && + if (operand.kind !== 179 && + operand.kind !== 177 && + operand.kind !== 176 && operand.kind !== 175 && - operand.kind !== 174 && - operand.kind !== 173 && - operand.kind !== 178 && - operand.kind !== 167 && - !(operand.kind === 166 && node.parent.kind === 167) && - !(operand.kind === 171 && node.parent.kind === 166)) { + operand.kind !== 180 && + operand.kind !== 169 && + !(operand.kind === 168 && node.parent.kind === 169) && + !(operand.kind === 173 && node.parent.kind === 168) && + !(operand.kind === 8 && node.parent.kind === 166)) { emit(operand); return; } @@ -25837,25 +26518,25 @@ var ts; write(")"); } function emitDeleteExpression(node) { - write(ts.tokenToString(76)); + write(ts.tokenToString(78)); write(" "); emit(node.expression); } function emitVoidExpression(node) { - write(ts.tokenToString(101)); + write(ts.tokenToString(103)); write(" "); emit(node.expression); } function emitTypeOfExpression(node) { - write(ts.tokenToString(99)); + write(ts.tokenToString(101)); write(" "); emit(node.expression); } function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 67 || ts.nodeIsSynthesized(node)) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 69 || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 209 || node.parent.kind === 161); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 211 || node.parent.kind === 163); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -25869,12 +26550,12 @@ var ts; write("\", "); } write(ts.tokenToString(node.operator)); - if (node.operand.kind === 177) { + if (node.operand.kind === 179) { var operand = node.operand; - if (node.operator === 35 && (operand.operator === 35 || operand.operator === 40)) { + if (node.operator === 35 && (operand.operator === 35 || operand.operator === 41)) { write(" "); } - else if (node.operator === 36 && (operand.operator === 36 || operand.operator === 41)) { + else if (node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) { write(" "); } } @@ -25891,7 +26572,7 @@ var ts; write("\", "); write(ts.tokenToString(node.operator)); emit(node.operand); - if (node.operator === 40) { + if (node.operator === 41) { write(") - 1)"); } else { @@ -25912,10 +26593,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 246) { + if (current.kind === 248) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 217) { + else if (ts.isFunctionLike(current) || current.kind === 219) { return false; } else { @@ -25923,26 +26604,82 @@ var ts; } } } + function emitExponentiationOperator(node) { + var leftHandSideExpression = node.left; + if (node.operatorToken.kind === 60) { + var synthesizedLHS; + var shouldEmitParentheses = false; + if (ts.isElementAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(167, false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); + synthesizedLHS.expression = identifier; + if (leftHandSideExpression.argumentExpression.kind !== 8 && + leftHandSideExpression.argumentExpression.kind !== 9) { + var tempArgumentExpression = createAndRecordTempVariable(268435456); + synthesizedLHS.argumentExpression = tempArgumentExpression; + emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, true); + } + else { + synthesizedLHS.argumentExpression = leftHandSideExpression.argumentExpression; + } + write(", "); + } + else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(166, false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); + synthesizedLHS.expression = identifier; + synthesizedLHS.dotToken = leftHandSideExpression.dotToken; + synthesizedLHS.name = leftHandSideExpression.name; + write(", "); + } + emit(synthesizedLHS || leftHandSideExpression); + write(" = "); + write("Math.pow("); + emit(synthesizedLHS || leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + if (shouldEmitParentheses) { + write(")"); + } + } + else { + write("Math.pow("); + emit(leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + } + } function emitBinaryExpression(node) { - if (languageVersion < 2 && node.operatorToken.kind === 55 && - (node.left.kind === 163 || node.left.kind === 162)) { - emitDestructuring(node, node.parent.kind === 193); + if (languageVersion < 2 && node.operatorToken.kind === 56 && + (node.left.kind === 165 || node.left.kind === 164)) { + emitDestructuring(node, node.parent.kind === 195); } else { - var exportChanged = node.operatorToken.kind >= 55 && - node.operatorToken.kind <= 66 && + var exportChanged = node.operatorToken.kind >= 56 && + node.operatorToken.kind <= 68 && isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); if (exportChanged) { write(exportFunctionForFile + "(\""); emitNodeWithoutSourceMap(node.left); write("\", "); } - emit(node.left); - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 ? " " : undefined); - write(ts.tokenToString(node.operatorToken.kind)); - var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); - emit(node.right); - decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); + if (node.operatorToken.kind === 38 || node.operatorToken.kind === 60) { + emitExponentiationOperator(node); + } + else { + emit(node.left); + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 ? " " : undefined); + write(ts.tokenToString(node.operatorToken.kind)); + var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); + emit(node.right); + decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); + } if (exportChanged) { write(")"); } @@ -25973,7 +26710,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 190) { + if (node && node.kind === 192) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -25988,12 +26725,12 @@ var ts; emitToken(15, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 217) { - ts.Debug.assert(node.parent.kind === 216); + if (node.kind === 219) { + ts.Debug.assert(node.parent.kind === 218); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 217) { + if (node.kind === 219) { emitTempDeclarations(true); } decreaseIndent(); @@ -26002,7 +26739,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 190) { + if (node.kind === 192) { write(" "); emit(node); } @@ -26014,11 +26751,11 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 172); + emitParenthesizedIf(node.expression, node.expression.kind === 174); write(";"); } function emitIfStatement(node) { - var endPos = emitToken(86, node.pos); + var endPos = emitToken(88, node.pos); write(" "); endPos = emitToken(17, endPos); emit(node.expression); @@ -26026,8 +26763,8 @@ var ts; emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(78, node.thenStatement.end); - if (node.elseStatement.kind === 194) { + emitToken(80, node.thenStatement.end); + if (node.elseStatement.kind === 196) { write(" "); emit(node.elseStatement); } @@ -26039,7 +26776,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 190) { + if (node.statement.kind === 192) { write(" "); } else { @@ -26059,13 +26796,13 @@ var ts; if (shouldHoistVariable(decl, true)) { return false; } - var tokenKind = 100; + var tokenKind = 102; if (decl && languageVersion >= 2) { if (ts.isLet(decl)) { - tokenKind = 106; + tokenKind = 108; } else if (ts.isConst(decl)) { - tokenKind = 72; + tokenKind = 74; } } if (startPos !== undefined) { @@ -26074,13 +26811,13 @@ var ts; } else { switch (tokenKind) { - case 100: + case 102: write("var "); break; - case 106: + case 108: write("let "); break; - case 72: + case 74: write("const "); break; } @@ -26105,10 +26842,10 @@ var ts; return started; } function emitForStatement(node) { - var endPos = emitToken(84, node.pos); + var endPos = emitToken(86, node.pos); write(" "); endPos = emitToken(17, endPos); - if (node.initializer && node.initializer.kind === 210) { + if (node.initializer && node.initializer.kind === 212) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -26129,13 +26866,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 199) { + if (languageVersion < 2 && node.kind === 201) { return emitDownLevelForOfStatement(node); } - var endPos = emitToken(84, node.pos); + var endPos = emitToken(86, node.pos); write(" "); endPos = emitToken(17, endPos); - if (node.initializer.kind === 210) { + if (node.initializer.kind === 212) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -26145,7 +26882,7 @@ var ts; else { emit(node.initializer); } - if (node.kind === 198) { + if (node.kind === 200) { write(" in "); } else { @@ -26156,30 +26893,10 @@ var ts; emitEmbeddedStatement(node.statement); } function emitDownLevelForOfStatement(node) { - // The following ES6 code: - // - // for (let v of expr) { } - // - // should be emitted as - // - // for (let _i = 0, _a = expr; _i < _a.length; _i++) { - // let v = _a[_i]; - // } - // - // where _a and _i are temps emitted to capture the RHS and the counter, - // respectively. - // When the left hand side is an expression instead of a let declaration, - // the "let v" is not emitted. - // When the left hand side is a let/const, the v is renamed if there is - // another v in scope. - // Note that all assignments to the LHS are emitted in the body, including - // all destructuring. - // Note also that because an extra statement is needed to assign to the LHS, - // for-of bodies are always emitted as blocks. - var endPos = emitToken(84, node.pos); + var endPos = emitToken(86, node.pos); write(" "); endPos = emitToken(17, endPos); - var rhsIsIdentifier = node.expression.kind === 67; + var rhsIsIdentifier = node.expression.kind === 69; var counter = createTempVariable(268435456); var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); emitStart(node.expression); @@ -26213,7 +26930,7 @@ var ts; increaseIndent(); var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 210) { + if (node.initializer.kind === 212) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -26234,8 +26951,8 @@ var ts; } } else { - var assignmentExpression = createBinaryExpression(node.initializer, 55, rhsIterationValue, false); - if (node.initializer.kind === 162 || node.initializer.kind === 163) { + var assignmentExpression = createBinaryExpression(node.initializer, 56, rhsIterationValue, false); + if (node.initializer.kind === 164 || node.initializer.kind === 165) { emitDestructuring(assignmentExpression, true, undefined); } else { @@ -26244,7 +26961,7 @@ var ts; } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 190) { + if (node.statement.kind === 192) { emitLines(node.statement.statements); } else { @@ -26256,12 +26973,12 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 201 ? 68 : 73, node.pos); + emitToken(node.kind === 203 ? 70 : 75, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { - emitToken(92, node.pos); + emitToken(94, node.pos); emitOptional(" ", node.expression); write(";"); } @@ -26272,7 +26989,7 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(94, node.pos); + var endPos = emitToken(96, node.pos); write(" "); emitToken(17, endPos); emit(node.expression); @@ -26301,7 +27018,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 239) { + if (node.kind === 241) { write("case "); emit(node.expression); write(":"); @@ -26336,7 +27053,7 @@ var ts; } function emitCatchClause(node) { writeLine(); - var endPos = emitToken(70, node.pos); + var endPos = emitToken(72, node.pos); write(" "); emitToken(17, endPos); emit(node.variableDeclaration); @@ -26345,7 +27062,7 @@ var ts; emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(74, node.pos); + emitToken(76, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -26356,7 +27073,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 216); + } while (node && node.kind !== 218); return node; } function emitContainingModuleName(node) { @@ -26371,7 +27088,7 @@ var ts; write(getGeneratedNameForNode(container)); write("."); } - else if (languageVersion < 2 && compilerOptions.module !== 4) { + else if (modulekind !== 5 && modulekind !== 4) { write("exports."); } } @@ -26381,14 +27098,14 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(8); zero.text = "0"; - var result = ts.createSynthesizedNode(175); + var result = ts.createSynthesizedNode(177); result.expression = zero; return result; } function emitEs6ExportDefaultCompat(node) { - if (node.parent.kind === 246) { - ts.Debug.assert(!!(node.flags & 1024) || node.kind === 225); - if (compilerOptions.module === 1 || compilerOptions.module === 2 || compilerOptions.module === 3) { + if (node.parent.kind === 248) { + ts.Debug.assert(!!(node.flags & 1024) || node.kind === 227); + if (modulekind === 1 || modulekind === 2 || modulekind === 3) { if (!currentSourceFile.symbol.exports["___esModule"]) { if (languageVersion === 1) { write("Object.defineProperty(exports, \"__esModule\", { value: true });"); @@ -26406,7 +27123,7 @@ var ts; if (node.flags & 1) { writeLine(); emitStart(node); - if (compilerOptions.module === 4 && node.parent === currentSourceFile) { + if (modulekind === 4 && node.parent === currentSourceFile) { write(exportFunctionForFile + "(\""); if (node.flags & 1024) { write("default"); @@ -26439,7 +27156,7 @@ var ts; } } function emitExportMemberAssignments(name) { - if (compilerOptions.module === 4) { + if (modulekind === 4) { return; } if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { @@ -26458,7 +27175,7 @@ var ts; } } function emitExportSpecifierInSystemModule(specifier) { - ts.Debug.assert(compilerOptions.module === 4); + ts.Debug.assert(modulekind === 4); if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { return; } @@ -26472,72 +27189,77 @@ var ts; emitEnd(specifier.name); write(";"); } + function emitAssignment(name, value, shouldEmitCommaBeforeAssignment) { + if (shouldEmitCommaBeforeAssignment) { + write(", "); + } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(name); + write("\", "); + } + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 211 || name.parent.kind === 163); + if (isVariableDeclarationOrBindingElement) { + emitModuleMemberName(name.parent); + } + else { + emit(name); + } + write(" = "); + emit(value); + if (exportChanged) { + write(")"); + } + } + function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment) { + var identifier = createTempVariable(0); + if (!canDefineTempVariablesInPlace) { + recordTempDeclaration(identifier); + } + emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment); + return identifier; + } function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; var canDefineTempVariablesInPlace = false; - if (root.kind === 209) { + if (root.kind === 211) { var isExported = ts.getCombinedNodeFlags(root) & 1; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 136) { + else if (root.kind === 138) { canDefineTempVariablesInPlace = true; } - if (root.kind === 179) { + if (root.kind === 181) { emitAssignmentExpression(root); } else { ts.Debug.assert(!isAssignmentExpressionStatement); emitBindingElement(root, value); } - function emitAssignment(name, value) { - if (emitCount++) { - write(", "); - } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 209 || name.parent.kind === 161); - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(name); - write("\", "); - } - if (isVariableDeclarationOrBindingElement) { - emitModuleMemberName(name.parent); - } - else { - emit(name); - } - write(" = "); - emit(value); - if (exportChanged) { - write(")"); - } - } function ensureIdentifier(expr, reuseIdentifierExpressions) { - if (expr.kind === 67 && reuseIdentifierExpressions) { + if (expr.kind === 69 && reuseIdentifierExpressions) { return expr; } - var identifier = createTempVariable(0); - if (!canDefineTempVariablesInPlace) { - recordTempDeclaration(identifier); - } - emitAssignment(identifier, expr); + var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0); + emitCount++; return identifier; } function createDefaultValueCheck(value, defaultValue) { value = ensureIdentifier(value, true); - var equals = ts.createSynthesizedNode(179); + var equals = ts.createSynthesizedNode(181); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(32); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(180); + var cond = ts.createSynthesizedNode(182); cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(52); + cond.questionToken = ts.createSynthesizedNode(53); cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(53); + cond.colonToken = ts.createSynthesizedNode(54); cond.whenFalse = whenFalse; return cond; } @@ -26549,14 +27271,14 @@ var ts; function createPropertyAccessForDestructuringProperty(object, propName) { var syntheticName = ts.createSynthesizedNode(propName.kind); syntheticName.text = propName.text; - if (syntheticName.kind !== 67) { + if (syntheticName.kind !== 69) { return createElementAccessExpression(object, syntheticName); } return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(166); - var sliceIdentifier = ts.createSynthesizedNode(67); + var call = ts.createSynthesizedNode(168); + var sliceIdentifier = ts.createSynthesizedNode(69); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); call.arguments = ts.createSynthesizedNodeArray(); @@ -26570,9 +27292,10 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 243 || p.kind === 244) { + if (p.kind === 245 || p.kind === 246) { var propName = p.name; - emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); + var target_1 = p.kind === 246 ? p : p.initializer || propName; + emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName)); } } } @@ -26583,8 +27306,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 185) { - if (e.kind !== 183) { + if (e.kind !== 187) { + if (e.kind !== 185) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -26594,18 +27317,25 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 179 && target.operatorToken.kind === 55) { + if (target.kind === 246) { + if (target.objectAssignmentInitializer) { + value = createDefaultValueCheck(value, target.objectAssignmentInitializer); + } + target = target.name; + } + else if (target.kind === 181 && target.operatorToken.kind === 56) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 163) { + if (target.kind === 165) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 162) { + else if (target.kind === 164) { emitArrayLiteralAssignment(target, value); } else { - emitAssignment(target, value); + emitAssignment(target, value, emitCount > 0); + emitCount++; } } function emitAssignmentExpression(root) { @@ -26618,14 +27348,14 @@ var ts; emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 170) { + if (root.parent.kind !== 172) { write("("); } value = ensureIdentifier(value, true); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 170) { + if (root.parent.kind !== 172) { write(")"); } } @@ -26646,11 +27376,11 @@ var ts; } for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (pattern.kind === 159) { + if (pattern.kind === 161) { var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 185) { + else if (element.kind !== 187) { if (!element.dotDotDotToken) { emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); } @@ -26661,7 +27391,8 @@ var ts; } } else { - emitAssignment(target.name, value); + emitAssignment(target.name, value, emitCount > 0); + emitCount++; } } } @@ -26681,8 +27412,8 @@ var ts; var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384) && (getCombinedFlagsForIdentifier(node.name) & 16384); if (isUninitializedLet && - node.parent.parent.kind !== 198 && - node.parent.parent.kind !== 199) { + node.parent.parent.kind !== 200 && + node.parent.parent.kind !== 201) { initializer = createVoidZero(); } } @@ -26700,11 +27431,11 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 185) { + if (node.kind === 187) { return; } var name = node.name; - if (name.kind === 67) { + if (name.kind === 69) { emitExportMemberAssignments(name); } else if (ts.isBindingPattern(name)) { @@ -26712,15 +27443,15 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 209 && node.parent.kind !== 161)) { + if (!node.parent || (node.parent.kind !== 211 && node.parent.kind !== 163)) { return 0; } return ts.getCombinedNodeFlags(node.parent); } function isES6ExportedDeclaration(node) { return !!(node.flags & 1) && - languageVersion >= 2 && - node.parent.kind === 246; + modulekind === 5 && + node.parent.kind === 248; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -26743,7 +27474,7 @@ var ts; write(";"); } } - if (languageVersion < 2 && node.parent === currentSourceFile) { + if (modulekind !== 5 && node.parent === currentSourceFile) { ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); } } @@ -26765,12 +27496,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2) { if (ts.isBindingPattern(node.name)) { - var name_24 = createTempVariable(0); + var name_25 = createTempVariable(0); if (!tempParameters) { tempParameters = []; } - tempParameters.push(name_24); - emit(name_24); + tempParameters.push(name_25); + emit(name_25); } else { emit(node.name); @@ -26869,12 +27600,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 143 ? "get " : "set "); + write(node.kind === 145 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 172 && languageVersion >= 2; + return node.kind === 174 && languageVersion >= 2; } function emitDeclarationName(node) { if (node.name) { @@ -26885,20 +27616,20 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 171) { + if (node.kind === 173) { return !!node.name; } - if (node.kind === 211) { + if (node.kind === 213) { return !!node.name || languageVersion < 2; } } function emitFunctionDeclaration(node) { if (ts.nodeIsMissing(node.body)) { - return emitOnlyPinnedOrTripleSlashComments(node); + return emitCommentsOnNotEmittedNode(node); } - if (node.kind !== 141 && node.kind !== 140 && - node.parent && node.parent.kind !== 243 && - node.parent.kind !== 166) { + if (node.kind !== 143 && node.kind !== 142 && + node.parent && node.parent.kind !== 245 && + node.parent.kind !== 168) { emitLeadingComments(node); } emitStart(node); @@ -26919,11 +27650,11 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 && node.kind === 211 && node.parent === currentSourceFile && node.name) { + if (modulekind !== 5 && node.kind === 213 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } emitEnd(node); - if (node.kind !== 141 && node.kind !== 140) { + if (node.kind !== 143 && node.kind !== 142) { emitTrailingComments(node); } } @@ -26955,7 +27686,7 @@ var ts; } function emitAsyncFunctionBodyForES6(node) { var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 172; + var isArrowFunction = node.kind === 174; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096) !== 0; var args; if (!isArrowFunction) { @@ -26998,7 +27729,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 190) { + if (node.body.kind === 192) { emitBlockFunctionBody(node, node.body); } else { @@ -27046,10 +27777,10 @@ var ts; } write(" "); var current = body; - while (current.kind === 169) { + while (current.kind === 171) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 163); + emitParenthesizedIf(body, current.kind === 165); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -27121,11 +27852,11 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 193) { + if (statement && statement.kind === 195) { var expr = statement.expression; - if (expr && expr.kind === 166) { + if (expr && expr.kind === 168) { var func = expr.expression; - if (func && func.kind === 93) { + if (func && func.kind === 95) { return statement; } } @@ -27154,7 +27885,7 @@ var ts; emitNodeWithCommentsAndWithoutSourcemap(memberName); write("]"); } - else if (memberName.kind === 134) { + else if (memberName.kind === 136) { emitComputedPropertyName(memberName); } else { @@ -27166,7 +27897,7 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 139 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { + if (member.kind === 141 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { properties.push(member); } } @@ -27206,13 +27937,13 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 189) { + if (member.kind === 191) { writeLine(); write(";"); } - else if (member.kind === 141 || node.kind === 140) { + else if (member.kind === 143 || node.kind === 142) { if (!member.body) { - return emitOnlyPinnedOrTripleSlashComments(member); + return emitCommentsOnNotEmittedNode(member); } writeLine(); emitLeadingComments(member); @@ -27227,7 +27958,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 143 || member.kind === 144) { + else if (member.kind === 145 || member.kind === 146) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -27277,22 +28008,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 141 || node.kind === 140) && !member.body) { - emitOnlyPinnedOrTripleSlashComments(member); + if ((member.kind === 143 || node.kind === 142) && !member.body) { + emitCommentsOnNotEmittedNode(member); } - else if (member.kind === 141 || - member.kind === 143 || - member.kind === 144) { + else if (member.kind === 143 || + member.kind === 145 || + member.kind === 146) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128) { write("static "); } - if (member.kind === 143) { + if (member.kind === 145) { write("get "); } - else if (member.kind === 144) { + else if (member.kind === 146) { write("set "); } if (member.asteriskToken) { @@ -27303,7 +28034,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 189) { + else if (member.kind === 191) { writeLine(); write(";"); } @@ -27324,10 +28055,10 @@ var ts; function emitConstructorWorker(node, baseTypeElement) { var hasInstancePropertyWithInitializer = false; ts.forEach(node.members, function (member) { - if (member.kind === 142 && !member.body) { - emitOnlyPinnedOrTripleSlashComments(member); + if (member.kind === 144 && !member.body) { + emitCommentsOnNotEmittedNode(member); } - if (member.kind === 139 && member.initializer && (member.flags & 128) === 0) { + if (member.kind === 141 && member.initializer && (member.flags & 128) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -27427,10 +28158,13 @@ var ts; else { emitClassLikeDeclarationForES6AndHigher(node); } + if (modulekind !== 5 && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 212) { + if (node.kind === 214) { if (thisNodeIsDecorated) { if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { write("export "); @@ -27447,7 +28181,7 @@ var ts; } } var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 184; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 186; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0); @@ -27457,7 +28191,7 @@ var ts; write(" = "); } write("class"); - if ((node.name || !(node.flags & 1024)) && !thisNodeIsDecorated) { + if ((node.name || (node.flags & 1024 && staticProperties.length > 0)) && !thisNodeIsDecorated) { write(" "); emitDeclarationName(node); } @@ -27514,7 +28248,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 212) { + if (node.kind === 214) { if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); } @@ -27572,16 +28306,13 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 212) { + if (node.kind === 214) { write(";"); } emitEnd(node); - if (node.kind === 212) { + if (node.kind === 214) { emitExportMemberAssignment(node); } - if (languageVersion < 2 && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } } function emitClassMemberPrefix(node, member) { emitDeclarationName(node); @@ -27650,23 +28381,12 @@ var ts; } else { decorators = member.decorators; - if (member.kind === 141) { + if (member.kind === 143) { functionLikeMember = member; } } writeLine(); emitStart(member); - if (member.kind !== 139) { - write("Object.defineProperty("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write(","); - increaseIndent(); - writeLine(); - } write("__decorate(["); increaseIndent(); writeLine(); @@ -27686,15 +28406,13 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 139) { - write(", Object.getOwnPropertyDescriptor("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write("))"); - decreaseIndent(); + if (languageVersion > 0) { + if (member.kind !== 141) { + write(", null"); + } + else { + write(", void 0"); + } } write(");"); emitEnd(member); @@ -27725,45 +28443,45 @@ var ts; } function shouldEmitTypeMetadata(node) { switch (node.kind) { - case 141: case 143: - case 144: - case 139: + case 145: + case 146: + case 141: return true; } return false; } function shouldEmitReturnTypeMetadata(node) { switch (node.kind) { - case 141: + case 143: return true; } return false; } function shouldEmitParamTypesMetadata(node) { switch (node.kind) { - case 212: - case 141: - case 144: + case 214: + case 143: + case 146: return true; } return false; } function emitSerializedTypeOfNode(node) { switch (node.kind) { - case 212: + case 214: write("Function"); return; - case 139: + case 141: emitSerializedTypeNode(node.type); return; - case 136: + case 138: emitSerializedTypeNode(node.type); return; - case 143: + case 145: emitSerializedTypeNode(node.type); return; - case 144: + case 146: emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); return; } @@ -27776,42 +28494,42 @@ var ts; function emitSerializedTypeNode(node) { if (node) { switch (node.kind) { - case 101: + case 103: write("void 0"); return; - case 158: + case 160: emitSerializedTypeNode(node.type); return; - case 150: - case 151: + case 152: + case 153: write("Function"); return; - case 154: - case 155: + case 156: + case 157: write("Array"); return; - case 148: - case 118: + case 150: + case 120: write("Boolean"); return; - case 128: + case 130: case 9: write("String"); return; - case 126: + case 128: write("Number"); return; - case 129: + case 131: write("Symbol"); return; - case 149: + case 151: emitSerializedTypeReferenceNode(node); return; - case 152: - case 153: - case 156: - case 157: - case 115: + case 154: + case 155: + case 158: + case 159: + case 117: break; default: ts.Debug.fail("Cannot serialize unexpected type node."); @@ -27876,7 +28594,7 @@ var ts; function emitSerializedParameterTypesOfNode(node) { if (node) { var valueDeclaration; - if (node.kind === 212) { + if (node.kind === 214) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -27892,10 +28610,10 @@ var ts; } if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 154) { + if (parameterType.kind === 156) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 149 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 151 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -27955,7 +28673,7 @@ var ts; return argumentsWritten; } function emitInterfaceDeclaration(node) { - emitOnlyPinnedOrTripleSlashComments(node); + emitCommentsOnNotEmittedNode(node); } function shouldEmitEnumDeclaration(node) { var isConstEnum = ts.isConst(node); @@ -28007,8 +28725,8 @@ var ts; emitEnd(node); write(";"); } - if (languageVersion < 2 && node.parent === currentSourceFile) { - if (compilerOptions.module === 4 && (node.flags & 1)) { + if (modulekind !== 5 && node.parent === currentSourceFile) { + if (modulekind === 4 && (node.flags & 1)) { writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); @@ -28048,7 +28766,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 216) { + if (moduleDeclaration.body.kind === 218) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -28062,7 +28780,7 @@ var ts; function emitModuleDeclaration(node) { var shouldEmit = shouldEmitModuleDeclaration(node); if (!shouldEmit) { - return emitOnlyPinnedOrTripleSlashComments(node); + return emitCommentsOnNotEmittedNode(node); } var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); @@ -28083,7 +28801,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 217) { + if (node.body.kind === 219) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -28115,8 +28833,8 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 67 && node.parent === currentSourceFile) { - if (compilerOptions.module === 4 && (node.flags & 1)) { + if (!isES6ExportedDeclaration(node) && node.name.kind === 69 && node.parent === currentSourceFile) { + if (modulekind === 4 && (node.flags & 1)) { writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); @@ -28152,16 +28870,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 219) { + if (node.kind === 221) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 222) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 224) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 220 && node.importClause && !!node.importClause.name; + return node.kind === 222 && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -28170,7 +28888,7 @@ var ts; ts.forEachChild(node, emitExportImportAssignments); } function emitImportDeclaration(node) { - if (languageVersion < 2) { + if (modulekind !== 5) { return emitExternalImportDeclaration(node); } if (node.importClause) { @@ -28188,7 +28906,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 222) { + if (node.importClause.namedBindings.kind === 224) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -28214,9 +28932,9 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 219 && (node.flags & 1) !== 0; + var isExportedImport = node.kind === 221 && (node.flags & 1) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (compilerOptions.module !== 2) { + if (modulekind !== 2) { emitLeadingComments(node); emitStart(node); if (namespaceDeclaration && !isDefaultImport(node)) { @@ -28226,7 +28944,7 @@ var ts; write(" = "); } else { - var isNakedImport = 220 && !node.importClause; + var isNakedImport = 222 && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -28302,13 +29020,13 @@ var ts; } } function emitExportDeclaration(node) { - ts.Debug.assert(compilerOptions.module !== 4); - if (languageVersion < 2) { + ts.Debug.assert(modulekind !== 4); + if (modulekind !== 5) { if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { emitStart(node); var generatedName = getGeneratedNameForNode(node); if (node.exportClause) { - if (compilerOptions.module !== 2) { + if (modulekind !== 2) { write("var "); write(generatedName); write(" = "); @@ -28335,7 +29053,7 @@ var ts; else { writeLine(); write("__export("); - if (compilerOptions.module !== 2) { + if (modulekind !== 2) { emitRequire(ts.getExternalModuleName(node)); } else { @@ -28366,7 +29084,7 @@ var ts; } } function emitExportOrImportSpecifierList(specifiers, shouldEmit) { - ts.Debug.assert(languageVersion >= 2); + ts.Debug.assert(modulekind === 5); var needsComma = false; for (var _a = 0; _a < specifiers.length; _a++) { var specifier = specifiers[_a]; @@ -28385,14 +29103,14 @@ var ts; } function emitExportAssignment(node) { if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { - if (languageVersion >= 2) { + if (modulekind === 5) { writeLine(); emitStart(node); write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 211 && - expression.kind !== 212) { + if (expression.kind !== 213 && + expression.kind !== 214) { write(";"); } emitEnd(node); @@ -28400,7 +29118,7 @@ var ts; else { writeLine(); emitStart(node); - if (compilerOptions.module === 4) { + if (modulekind === 4) { write(exportFunctionForFile + "(\"default\","); emit(node.expression); write(")"); @@ -28429,18 +29147,18 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 220: + case 222: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { externalImports.push(node); } break; - case 219: - if (node.moduleReference.kind === 230 && resolver.isReferencedAliasDeclaration(node)) { + case 221: + if (node.moduleReference.kind === 232 && resolver.isReferencedAliasDeclaration(node)) { externalImports.push(node); } break; - case 226: + case 228: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -28453,12 +29171,12 @@ var ts; else { for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; - var name_25 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_25] || (exportSpecifiers[name_25] = [])).push(specifier); + var name_26 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_26] || (exportSpecifiers[name_26] = [])).push(specifier); } } break; - case 225: + case 227: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -28483,10 +29201,10 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - if (node.kind === 220 && node.importClause) { + if (node.kind === 222 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 226 && node.moduleSpecifier) { + if (node.kind === 228 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } @@ -28505,8 +29223,8 @@ var ts; var started = false; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; - var skipNode = importNode.kind === 226 || - (importNode.kind === 220 && !importNode.importClause); + var skipNode = importNode.kind === 228 || + (importNode.kind === 222 && !importNode.importClause); if (skipNode) { continue; } @@ -28531,7 +29249,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 226 && externalImport.exportClause) { + if (externalImport.kind === 228 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -28560,7 +29278,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 226) { + if (externalImport.kind !== 228) { continue; } var exportDecl = externalImport; @@ -28603,7 +29321,7 @@ var ts; return exportStarFunction; } function writeExportedName(node) { - if (node.kind !== 67 && node.flags & 1024) { + if (node.kind !== 69 && node.flags & 1024) { return; } if (started) { @@ -28614,7 +29332,7 @@ var ts; } writeLine(); write("'"); - if (node.kind === 67) { + if (node.kind === 69) { emitNodeWithCommentsAndWithoutSourcemap(node); } else { @@ -28634,11 +29352,11 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_26 = local.kind === 67 + var name_27 = local.kind === 69 ? local : local.name; - if (name_26) { - var text = ts.unescapeIdentifier(name_26.text); + if (name_27) { + var text = ts.unescapeIdentifier(name_27.text); if (ts.hasProperty(seen, text)) { continue; } @@ -28649,13 +29367,13 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 212 || local.kind === 216 || local.kind === 215) { + if (local.kind === 214 || local.kind === 218 || local.kind === 217) { emitDeclarationName(local); } else { emit(local); } - var flags = ts.getCombinedNodeFlags(local.kind === 67 ? local.parent : local); + var flags = ts.getCombinedNodeFlags(local.kind === 69 ? local.parent : local); if (flags & 1) { if (!exportedDeclarations) { exportedDeclarations = []; @@ -28683,21 +29401,21 @@ var ts; if (node.flags & 2) { return; } - if (node.kind === 211) { + if (node.kind === 213) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 212) { + if (node.kind === 214) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 215) { + if (node.kind === 217) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -28706,7 +29424,7 @@ var ts; } return; } - if (node.kind === 216) { + if (node.kind === 218) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -28715,17 +29433,17 @@ var ts; } return; } - if (node.kind === 209 || node.kind === 161) { + if (node.kind === 211 || node.kind === 163) { if (shouldHoistVariable(node, false)) { - var name_27 = node.name; - if (name_27.kind === 67) { + var name_28 = node.name; + if (name_28.kind === 69) { if (!hoistedVars) { hoistedVars = []; } - hoistedVars.push(name_27); + hoistedVars.push(name_28); } else { - ts.forEachChild(name_27, visit); + ts.forEachChild(name_28, visit); } } return; @@ -28751,10 +29469,10 @@ var ts; return false; } return (ts.getCombinedNodeFlags(node) & 49152) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 246; + ts.getEnclosingBlockScopeContainer(node).kind === 248; } function isCurrentFileSystemExternalModule() { - return compilerOptions.module === 4 && ts.isExternalModule(currentSourceFile); + return modulekind === 4 && ts.isExternalModule(currentSourceFile); } function emitSystemModuleBody(node, dependencyGroups, startIndex) { emitVariableDeclarationsForImports(); @@ -28789,17 +29507,17 @@ var ts; var entry = group[_a]; var importVariableName = getLocalNameForExternalImport(entry) || ""; switch (entry.kind) { - case 220: + case 222: if (!entry.importClause) { break; } - case 219: + case 221: ts.Debug.assert(importVariableName !== ""); writeLine(); write(importVariableName + " = " + parameterName + ";"); writeLine(); break; - case 226: + case 228: ts.Debug.assert(importVariableName !== ""); if (entry.exportClause) { writeLine(); @@ -28843,10 +29561,10 @@ var ts; for (var i = startIndex; i < node.statements.length; ++i) { var statement = node.statements[i]; switch (statement.kind) { - case 211: - case 220: + case 213: + case 222: continue; - case 226: + case 228: if (!statement.moduleSpecifier) { for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { var element = _b[_a]; @@ -28854,7 +29572,7 @@ var ts; } } continue; - case 219: + case 221: if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { continue; } @@ -28867,7 +29585,7 @@ var ts; writeLine(); write("}"); } - function emitSystemModule(node, startIndex) { + function emitSystemModule(node) { collectExternalModuleInfo(node); ts.Debug.assert(!exportFunctionForFile); exportFunctionForFile = makeUniqueName("exports"); @@ -28898,6 +29616,7 @@ var ts; write("], function(" + exportFunctionForFile + ") {"); writeLine(); increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, true); emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitSystemModuleBody(node, dependencyGroups, startIndex); @@ -28905,18 +29624,7 @@ var ts; writeLine(); write("});"); } - function emitAMDDependencies(node, includeNonAmdDependencies) { - // An AMD define function has the following shape: - // define(id?, dependencies?, factory); - // - // This has the shape of - // define(name, ["module1", "module2"], function (module1Alias) { - // The location of the alias in the parameter list in the factory function needs to - // match the position of the module name in the dependency list. - // - // To ensure this is true in cases of modules with no aliases, e.g.: - // `import "module"` or `` - // we need to add modules without alias names to the end of the dependencies list + function getAMDDependencyNames(node, includeNonAmdDependencies) { var aliasedModuleNames = []; var unaliasedModuleNames = []; var importAliasNames = []; @@ -28942,6 +29650,16 @@ var ts; unaliasedModuleNames.push(externalModuleName); } } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + } + function emitAMDDependencies(node, includeNonAmdDependencies) { + var dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies); + emitAMDDependencyList(dependencyNames); + write(", "); + emitAMDFactoryHeader(dependencyNames); + } + function emitAMDDependencyList(_a) { + var aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames; write("[\"require\", \"exports\""); if (aliasedModuleNames.length) { write(", "); @@ -28951,13 +29669,18 @@ var ts; write(", "); write(unaliasedModuleNames.join(", ")); } - write("], function (require, exports"); + write("]"); + } + function emitAMDFactoryHeader(_a) { + var importAliasNames = _a.importAliasNames; + write("function (require, exports"); if (importAliasNames.length) { write(", "); write(importAliasNames.join(", ")); } + write(") {"); } - function emitAMDModule(node, startIndex) { + function emitAMDModule(node) { emitEmitHelpers(node); collectExternalModuleInfo(node); writeLine(); @@ -28966,8 +29689,8 @@ var ts; write("\"" + node.moduleName + "\", "); } emitAMDDependencies(node, true); - write(") {"); increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, true); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -28977,7 +29700,8 @@ var ts; writeLine(); write("});"); } - function emitCommonJSModule(node, startIndex) { + function emitCommonJSModule(node) { + var startIndex = emitDirectivePrologues(node.statements, false); emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); @@ -28986,13 +29710,17 @@ var ts; emitTempDeclarations(true); emitExportEquals(false); } - function emitUMDModule(node, startIndex) { + function emitUMDModule(node) { emitEmitHelpers(node); collectExternalModuleInfo(node); - writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); - emitAMDDependencies(node, false); - write(") {"); + var dependencyNames = getAMDDependencyNames(node, false); + writeLines("(function (factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define("); + emitAMDDependencyList(dependencyNames); + write(", factory);"); + writeLines(" }\n})("); + emitAMDFactoryHeader(dependencyNames); increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, true); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -29002,11 +29730,12 @@ var ts; writeLine(); write("});"); } - function emitES6Module(node, startIndex) { + function emitES6Module(node) { externalImports = undefined; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + var startIndex = emitDirectivePrologues(node.statements, false); emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -29043,7 +29772,7 @@ var ts; if (ts.isLineBreak(c)) { if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + "\" + ' ' + \"" : "") + part; + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); } firstNonWhitespace = -1; } @@ -29056,7 +29785,7 @@ var ts; } if (firstNonWhitespace !== -1) { var part = text.substr(firstNonWhitespace); - result = (result ? result + "\" + ' ' + \"" : "") + part; + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); } if (result) { result = result.replace(/&(\w+);/g, function (s, m) { @@ -29164,25 +29893,12 @@ var ts; writeLine(); emitShebang(); emitDetachedComments(node); - var startIndex = emitDirectivePrologues(node.statements, false); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - if (languageVersion >= 2) { - emitES6Module(node, startIndex); - } - else if (compilerOptions.module === 2) { - emitAMDModule(node, startIndex); - } - else if (compilerOptions.module === 4) { - emitSystemModule(node, startIndex); - } - else if (compilerOptions.module === 3) { - emitUMDModule(node, startIndex); - } - else { - emitCommonJSModule(node, startIndex); - } + var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1]; + emitModule(node); } else { + var startIndex = emitDirectivePrologues(node.statements, false); externalImports = undefined; exportSpecifiers = undefined; exportEquals = undefined; @@ -29200,7 +29916,7 @@ var ts; function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { if (node) { if (node.flags & 2) { - return emitOnlyPinnedOrTripleSlashComments(node); + return emitCommentsOnNotEmittedNode(node); } if (isSpecializedCommentHandling(node)) { return emitNodeWithoutSourceMap(node); @@ -29222,28 +29938,28 @@ var ts; } function isSpecializedCommentHandling(node) { switch (node.kind) { + case 215: case 213: - case 211: - case 220: - case 219: - case 214: - case 225: + case 222: + case 221: + case 216: + case 227: return true; } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 191: + case 193: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 216: + case 218: return shouldEmitModuleDeclaration(node); - case 215: + case 217: return shouldEmitEnumDeclaration(node); } ts.Debug.assert(!isSpecializedCommentHandling(node)); - if (node.kind !== 190 && + if (node.kind !== 192 && node.parent && - node.parent.kind === 172 && + node.parent.kind === 174 && node.parent.body === node && compilerOptions.target <= 1) { return false; @@ -29252,25 +29968,25 @@ var ts; } function emitJavaScriptWorker(node) { switch (node.kind) { - case 67: + case 69: return emitIdentifier(node); - case 136: + case 138: return emitParameter(node); - case 141: - case 140: - return emitMethod(node); case 143: - case 144: + case 142: + return emitMethod(node); + case 145: + case 146: return emitAccessor(node); - case 95: + case 97: return emitThis(node); - case 93: + case 95: return emitSuper(node); - case 91: + case 93: return write("null"); - case 97: + case 99: return write("true"); - case 82: + case 84: return write("false"); case 8: case 9: @@ -29280,142 +29996,142 @@ var ts; case 13: case 14: return emitLiteral(node); - case 181: + case 183: return emitTemplateExpression(node); - case 188: + case 190: return emitTemplateSpan(node); - case 231: - case 232: - return emitJsxElement(node); + case 233: case 234: + return emitJsxElement(node); + case 236: return emitJsxText(node); - case 238: + case 240: return emitJsxExpression(node); - case 133: + case 135: return emitQualifiedName(node); - case 159: + case 161: return emitObjectBindingPattern(node); - case 160: + case 162: return emitArrayBindingPattern(node); - case 161: + case 163: return emitBindingElement(node); - case 162: + case 164: return emitArrayLiteral(node); - case 163: + case 165: return emitObjectLiteral(node); - case 243: + case 245: return emitPropertyAssignment(node); - case 244: + case 246: return emitShorthandPropertyAssignment(node); - case 134: + case 136: return emitComputedPropertyName(node); - case 164: + case 166: return emitPropertyAccess(node); - case 165: + case 167: return emitIndexedAccess(node); - case 166: + case 168: return emitCallExpression(node); - case 167: + case 169: return emitNewExpression(node); - case 168: + case 170: return emitTaggedTemplateExpression(node); - case 169: + case 171: return emit(node.expression); - case 187: + case 189: return emit(node.expression); - case 170: - return emitParenExpression(node); - case 211: - case 171: case 172: - return emitFunctionDeclaration(node); + return emitParenExpression(node); + case 213: case 173: - return emitDeleteExpression(node); case 174: - return emitTypeOfExpression(node); + return emitFunctionDeclaration(node); case 175: - return emitVoidExpression(node); + return emitDeleteExpression(node); case 176: - return emitAwaitExpression(node); + return emitTypeOfExpression(node); case 177: - return emitPrefixUnaryExpression(node); + return emitVoidExpression(node); case 178: - return emitPostfixUnaryExpression(node); + return emitAwaitExpression(node); case 179: - return emitBinaryExpression(node); + return emitPrefixUnaryExpression(node); case 180: + return emitPostfixUnaryExpression(node); + case 181: + return emitBinaryExpression(node); + case 182: return emitConditionalExpression(node); - case 183: + case 185: return emitSpreadElementExpression(node); - case 182: + case 184: return emitYieldExpression(node); - case 185: + case 187: return; - case 190: - case 217: + case 192: + case 219: return emitBlock(node); - case 191: + case 193: return emitVariableStatement(node); - case 192: + case 194: return write(";"); - case 193: + case 195: return emitExpressionStatement(node); - case 194: + case 196: return emitIfStatement(node); - case 195: + case 197: return emitDoStatement(node); - case 196: + case 198: return emitWhileStatement(node); - case 197: - return emitForStatement(node); case 199: - case 198: - return emitForInOrForOfStatement(node); - case 200: + return emitForStatement(node); case 201: - return emitBreakOrContinueStatement(node); + case 200: + return emitForInOrForOfStatement(node); case 202: - return emitReturnStatement(node); case 203: - return emitWithStatement(node); + return emitBreakOrContinueStatement(node); case 204: + return emitReturnStatement(node); + case 205: + return emitWithStatement(node); + case 206: return emitSwitchStatement(node); - case 239: - case 240: + case 241: + case 242: return emitCaseOrDefaultClause(node); - case 205: + case 207: return emitLabelledStatement(node); - case 206: + case 208: return emitThrowStatement(node); - case 207: + case 209: return emitTryStatement(node); - case 242: + case 244: return emitCatchClause(node); - case 208: + case 210: return emitDebuggerStatement(node); - case 209: + case 211: return emitVariableDeclaration(node); - case 184: + case 186: return emitClassExpression(node); - case 212: + case 214: return emitClassDeclaration(node); - case 213: - return emitInterfaceDeclaration(node); case 215: + return emitInterfaceDeclaration(node); + case 217: return emitEnumDeclaration(node); - case 245: + case 247: return emitEnumMember(node); - case 216: + case 218: return emitModuleDeclaration(node); - case 220: + case 222: return emitImportDeclaration(node); - case 219: + case 221: return emitImportEqualsDeclaration(node); - case 226: + case 228: return emitExportDeclaration(node); - case 225: + case 227: return emitExportAssignment(node); - case 246: + case 248: return emitSourceFileNode(node); } } @@ -29432,18 +30148,24 @@ var ts; } return leadingComments; } - function filterComments(ranges, onlyPinnedOrTripleSlashComments) { - if (ranges && onlyPinnedOrTripleSlashComments) { - ranges = ts.filter(ranges, isPinnedOrTripleSlashComment); - if (ranges.length === 0) { - return undefined; - } + function isPinnedComments(comment) { + return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; + } + function isTripleSlashComment(comment) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && + comment.pos + 2 < comment.end && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 47) { + var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); + return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || + textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? + true : false; } - return ranges; + return false; } function getLeadingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 246 || node.pos !== node.parent.pos) { + if (node.parent.kind === 248 || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { return getLeadingCommentsWithoutDetachedComments(); } @@ -29455,31 +30177,51 @@ var ts; } function getTrailingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 246 || node.end !== node.parent.end) { + if (node.parent.kind === 248 || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } } - function emitOnlyPinnedOrTripleSlashComments(node) { - emitLeadingCommentsWorker(node, true); + function emitCommentsOnNotEmittedNode(node) { + emitLeadingCommentsWorker(node, false); } function emitLeadingComments(node) { - return emitLeadingCommentsWorker(node, compilerOptions.removeComments); + return emitLeadingCommentsWorker(node, true); } - function emitLeadingCommentsWorker(node, onlyPinnedOrTripleSlashComments) { - var leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments); + function emitLeadingCommentsWorker(node, isEmittedNode) { + if (compilerOptions.removeComments) { + return; + } + var leadingComments; + if (isEmittedNode) { + leadingComments = getLeadingCommentsToEmit(node); + } + else { + if (node.pos === 0) { + leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); + } + } ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); } function emitTrailingComments(node) { - var trailingComments = filterComments(getTrailingCommentsToEmit(node), compilerOptions.removeComments); + if (compilerOptions.removeComments) { + return; + } + var trailingComments = getTrailingCommentsToEmit(node); ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); } function emitTrailingCommentsOfPosition(pos) { - var trailingComments = filterComments(ts.getTrailingCommentRanges(currentSourceFile.text, pos), compilerOptions.removeComments); + if (compilerOptions.removeComments) { + return; + } + var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos); ts.emitComments(currentSourceFile, writer, trailingComments, true, newLine, writeComment); } - function emitLeadingCommentsOfPosition(pos) { + function emitLeadingCommentsOfPositionWorker(pos) { + if (compilerOptions.removeComments) { + return; + } var leadingComments; if (hasDetachedComments(pos)) { leadingComments = getLeadingCommentsWithoutDetachedComments(); @@ -29487,12 +30229,19 @@ var ts; else { leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); } - leadingComments = filterComments(leadingComments, compilerOptions.removeComments); ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); } function emitDetachedComments(node) { - var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + var leadingComments; + if (compilerOptions.removeComments) { + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + } + } + else { + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + } if (leadingComments) { var detachedComments = []; var lastComment; @@ -29530,17 +30279,7 @@ var ts; write(shebang); } } - function isPinnedOrTripleSlashComment(comment) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { - return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; - } - else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && - comment.pos + 2 < comment.end && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 && - currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) { - return true; - } - } + var _a; } function emitFile(jsFilePath, sourceFile) { emitJavaScript(jsFilePath, sourceFile); @@ -29550,265 +30289,7 @@ var ts; } } ts.emitFiles = emitFiles; - var entities = { - "quot": 0x0022, - "amp": 0x0026, - "apos": 0x0027, - "lt": 0x003C, - "gt": 0x003E, - "nbsp": 0x00A0, - "iexcl": 0x00A1, - "cent": 0x00A2, - "pound": 0x00A3, - "curren": 0x00A4, - "yen": 0x00A5, - "brvbar": 0x00A6, - "sect": 0x00A7, - "uml": 0x00A8, - "copy": 0x00A9, - "ordf": 0x00AA, - "laquo": 0x00AB, - "not": 0x00AC, - "shy": 0x00AD, - "reg": 0x00AE, - "macr": 0x00AF, - "deg": 0x00B0, - "plusmn": 0x00B1, - "sup2": 0x00B2, - "sup3": 0x00B3, - "acute": 0x00B4, - "micro": 0x00B5, - "para": 0x00B6, - "middot": 0x00B7, - "cedil": 0x00B8, - "sup1": 0x00B9, - "ordm": 0x00BA, - "raquo": 0x00BB, - "frac14": 0x00BC, - "frac12": 0x00BD, - "frac34": 0x00BE, - "iquest": 0x00BF, - "Agrave": 0x00C0, - "Aacute": 0x00C1, - "Acirc": 0x00C2, - "Atilde": 0x00C3, - "Auml": 0x00C4, - "Aring": 0x00C5, - "AElig": 0x00C6, - "Ccedil": 0x00C7, - "Egrave": 0x00C8, - "Eacute": 0x00C9, - "Ecirc": 0x00CA, - "Euml": 0x00CB, - "Igrave": 0x00CC, - "Iacute": 0x00CD, - "Icirc": 0x00CE, - "Iuml": 0x00CF, - "ETH": 0x00D0, - "Ntilde": 0x00D1, - "Ograve": 0x00D2, - "Oacute": 0x00D3, - "Ocirc": 0x00D4, - "Otilde": 0x00D5, - "Ouml": 0x00D6, - "times": 0x00D7, - "Oslash": 0x00D8, - "Ugrave": 0x00D9, - "Uacute": 0x00DA, - "Ucirc": 0x00DB, - "Uuml": 0x00DC, - "Yacute": 0x00DD, - "THORN": 0x00DE, - "szlig": 0x00DF, - "agrave": 0x00E0, - "aacute": 0x00E1, - "acirc": 0x00E2, - "atilde": 0x00E3, - "auml": 0x00E4, - "aring": 0x00E5, - "aelig": 0x00E6, - "ccedil": 0x00E7, - "egrave": 0x00E8, - "eacute": 0x00E9, - "ecirc": 0x00EA, - "euml": 0x00EB, - "igrave": 0x00EC, - "iacute": 0x00ED, - "icirc": 0x00EE, - "iuml": 0x00EF, - "eth": 0x00F0, - "ntilde": 0x00F1, - "ograve": 0x00F2, - "oacute": 0x00F3, - "ocirc": 0x00F4, - "otilde": 0x00F5, - "ouml": 0x00F6, - "divide": 0x00F7, - "oslash": 0x00F8, - "ugrave": 0x00F9, - "uacute": 0x00FA, - "ucirc": 0x00FB, - "uuml": 0x00FC, - "yacute": 0x00FD, - "thorn": 0x00FE, - "yuml": 0x00FF, - "OElig": 0x0152, - "oelig": 0x0153, - "Scaron": 0x0160, - "scaron": 0x0161, - "Yuml": 0x0178, - "fnof": 0x0192, - "circ": 0x02C6, - "tilde": 0x02DC, - "Alpha": 0x0391, - "Beta": 0x0392, - "Gamma": 0x0393, - "Delta": 0x0394, - "Epsilon": 0x0395, - "Zeta": 0x0396, - "Eta": 0x0397, - "Theta": 0x0398, - "Iota": 0x0399, - "Kappa": 0x039A, - "Lambda": 0x039B, - "Mu": 0x039C, - "Nu": 0x039D, - "Xi": 0x039E, - "Omicron": 0x039F, - "Pi": 0x03A0, - "Rho": 0x03A1, - "Sigma": 0x03A3, - "Tau": 0x03A4, - "Upsilon": 0x03A5, - "Phi": 0x03A6, - "Chi": 0x03A7, - "Psi": 0x03A8, - "Omega": 0x03A9, - "alpha": 0x03B1, - "beta": 0x03B2, - "gamma": 0x03B3, - "delta": 0x03B4, - "epsilon": 0x03B5, - "zeta": 0x03B6, - "eta": 0x03B7, - "theta": 0x03B8, - "iota": 0x03B9, - "kappa": 0x03BA, - "lambda": 0x03BB, - "mu": 0x03BC, - "nu": 0x03BD, - "xi": 0x03BE, - "omicron": 0x03BF, - "pi": 0x03C0, - "rho": 0x03C1, - "sigmaf": 0x03C2, - "sigma": 0x03C3, - "tau": 0x03C4, - "upsilon": 0x03C5, - "phi": 0x03C6, - "chi": 0x03C7, - "psi": 0x03C8, - "omega": 0x03C9, - "thetasym": 0x03D1, - "upsih": 0x03D2, - "piv": 0x03D6, - "ensp": 0x2002, - "emsp": 0x2003, - "thinsp": 0x2009, - "zwnj": 0x200C, - "zwj": 0x200D, - "lrm": 0x200E, - "rlm": 0x200F, - "ndash": 0x2013, - "mdash": 0x2014, - "lsquo": 0x2018, - "rsquo": 0x2019, - "sbquo": 0x201A, - "ldquo": 0x201C, - "rdquo": 0x201D, - "bdquo": 0x201E, - "dagger": 0x2020, - "Dagger": 0x2021, - "bull": 0x2022, - "hellip": 0x2026, - "permil": 0x2030, - "prime": 0x2032, - "Prime": 0x2033, - "lsaquo": 0x2039, - "rsaquo": 0x203A, - "oline": 0x203E, - "frasl": 0x2044, - "euro": 0x20AC, - "image": 0x2111, - "weierp": 0x2118, - "real": 0x211C, - "trade": 0x2122, - "alefsym": 0x2135, - "larr": 0x2190, - "uarr": 0x2191, - "rarr": 0x2192, - "darr": 0x2193, - "harr": 0x2194, - "crarr": 0x21B5, - "lArr": 0x21D0, - "uArr": 0x21D1, - "rArr": 0x21D2, - "dArr": 0x21D3, - "hArr": 0x21D4, - "forall": 0x2200, - "part": 0x2202, - "exist": 0x2203, - "empty": 0x2205, - "nabla": 0x2207, - "isin": 0x2208, - "notin": 0x2209, - "ni": 0x220B, - "prod": 0x220F, - "sum": 0x2211, - "minus": 0x2212, - "lowast": 0x2217, - "radic": 0x221A, - "prop": 0x221D, - "infin": 0x221E, - "ang": 0x2220, - "and": 0x2227, - "or": 0x2228, - "cap": 0x2229, - "cup": 0x222A, - "int": 0x222B, - "there4": 0x2234, - "sim": 0x223C, - "cong": 0x2245, - "asymp": 0x2248, - "ne": 0x2260, - "equiv": 0x2261, - "le": 0x2264, - "ge": 0x2265, - "sub": 0x2282, - "sup": 0x2283, - "nsub": 0x2284, - "sube": 0x2286, - "supe": 0x2287, - "oplus": 0x2295, - "otimes": 0x2297, - "perp": 0x22A5, - "sdot": 0x22C5, - "lceil": 0x2308, - "rceil": 0x2309, - "lfloor": 0x230A, - "rfloor": 0x230B, - "lang": 0x2329, - "rang": 0x232A, - "loz": 0x25CA, - "spades": 0x2660, - "clubs": 0x2663, - "hearts": 0x2665, - "diams": 0x2666 - }; })(ts || (ts = {})); -/// -/// -/// var ts; (function (ts) { ts.programTime = 0; @@ -29816,7 +30297,7 @@ var ts; ts.ioReadTime = 0; ts.ioWriteTime = 0; var emptyArray = []; - ts.version = "1.6.2"; + ts.version = "1.7.2"; function findConfigFile(searchPath) { var fileName = "tsconfig.json"; while (true) { @@ -29854,11 +30335,11 @@ var ts; if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { var failedLookupLocations = []; var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolvedFileName = loadNodeModuleFromFile(candidate, false, failedLookupLocations, host); + var resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host); if (resolvedFileName) { return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; } - resolvedFileName = loadNodeModuleFromDirectory(candidate, false, failedLookupLocations, host); + resolvedFileName = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); return resolvedFileName ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; @@ -29868,13 +30349,8 @@ var ts; } } ts.nodeModuleNameResolver = nodeModuleNameResolver; - function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) { - if (loadOnlyDts) { - return tryLoad(".d.ts"); - } - else { - return ts.forEach(ts.supportedExtensions, tryLoad); - } + function loadNodeModuleFromFile(candidate, failedLookupLocation, host) { + return ts.forEach(ts.moduleFileExtensions, tryLoad); function tryLoad(ext) { var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; if (host.fileExists(fileName)) { @@ -29886,7 +30362,7 @@ var ts; } } } - function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) { + function loadNodeModuleFromDirectory(candidate, failedLookupLocation, host) { var packageJsonPath = ts.combinePaths(candidate, "package.json"); if (host.fileExists(packageJsonPath)) { var jsonContent; @@ -29898,7 +30374,7 @@ var ts; jsonContent = { typings: undefined }; } if (jsonContent.typings) { - var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host); + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host); if (result) { return result; } @@ -29907,7 +30383,7 @@ var ts; else { failedLookupLocation.push(packageJsonPath); } - return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), failedLookupLocation, host); } function loadModuleFromNodeModules(moduleName, directory, host) { var failedLookupLocations = []; @@ -29917,11 +30393,11 @@ var ts; if (baseName !== "node_modules") { var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var result = loadNodeModuleFromFile(candidate, true, failedLookupLocations, host); + var result = loadNodeModuleFromFile(candidate, failedLookupLocations, host); if (result) { return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; } - result = loadNodeModuleFromDirectory(candidate, true, failedLookupLocations, host); + result = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); if (result) { return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; } @@ -29939,7 +30415,7 @@ var ts; return i === 0 || (i === 1 && name.charCodeAt(0) === 46); } function classicNameResolver(moduleName, containingFile, compilerOptions, host) { - if (moduleName.indexOf('!') != -1) { + if (moduleName.indexOf("!") != -1) { return { resolvedModule: undefined, failedLookupLocations: [] }; } var searchPath = ts.getDirectoryPath(containingFile); @@ -30248,7 +30724,7 @@ var ts; return emitResult; } function getSourceFile(fileName) { - return filesByName.get(fileName); + return filesByName.get(fileName) || filesByName.get(ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory())); } function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { if (sourceFile) { @@ -30337,10 +30813,14 @@ var ts; var imports; for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var node = _a[_i]; + collect(node, true); + } + file.imports = imports || emptyArray; + function collect(node, allowRelativeModuleNames) { switch (node.kind) { - case 220: - case 219: - case 226: + case 222: + case 221: + case 228: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -30348,24 +30828,19 @@ var ts; if (!moduleNameExpr.text) { break; } - (imports || (imports = [])).push(moduleNameExpr); + if (allowRelativeModuleNames || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { + (imports || (imports = [])).push(moduleNameExpr); + } break; - case 216: + case 218: if (node.name.kind === 9 && (node.flags & 2 || ts.isDeclarationFile(file))) { ts.forEachChild(node.body, function (node) { - if (ts.isExternalModuleImportEqualsDeclaration(node) && - ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 9) { - var moduleName = ts.getExternalModuleImportEqualsDeclarationExpression(node); - if (moduleName) { - (imports || (imports = [])).push(moduleName); - } - } + collect(node, false); }); } break; } } - file.imports = imports || emptyArray; } function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var diagnosticArgument; @@ -30408,48 +30883,46 @@ var ts; } } function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - if (filesByName.contains(canonicalName)) { - return getSourceFileFromCache(fileName, canonicalName, false); + if (filesByName.contains(fileName)) { + return getSourceFileFromCache(fileName, false); } - else { - var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); - var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); - if (filesByName.contains(canonicalAbsolutePath)) { - return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); + var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); + if (filesByName.contains(normalizedAbsolutePath)) { + var file_1 = getSourceFileFromCache(normalizedAbsolutePath, true); + filesByName.set(fileName, file_1); + return file_1; + } + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }); - filesByName.set(canonicalName, file); - if (file) { - skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - filesByName.set(canonicalAbsolutePath, file); - var basePath = ts.getDirectoryPath(fileName); - if (!options.noResolve) { - processReferencedFiles(file, basePath); - } - processImportedModules(file, basePath); - if (isDefaultLib) { - file.isDefaultLib = true; - files.unshift(file); - } - else { - files.push(file); - } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + } + }); + filesByName.set(fileName, file); + if (file) { + skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; + filesByName.set(normalizedAbsolutePath, file); + var basePath = ts.getDirectoryPath(fileName); + if (!options.noResolve) { + processReferencedFiles(file, basePath); + } + processImportedModules(file, basePath); + if (isDefaultLib) { + file.isDefaultLib = true; + files.unshift(file); + } + else { + files.push(file); } - return file; } - function getSourceFileFromCache(fileName, canonicalName, useAbsolutePath) { - var file = filesByName.get(canonicalName); + return file; + function getSourceFileFromCache(fileName, useAbsolutePath) { + var file = filesByName.get(fileName); if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; - if (canonicalName !== sourceFileName) { + if (ts.normalizeSlashes(fileName) !== ts.normalizeSlashes(sourceFileName)) { if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); } @@ -30481,7 +30954,7 @@ var ts; if (importedFile && resolution.isExternalLibraryImport) { if (!ts.isExternalModule(importedFile)) { var start_2 = ts.getTokenPosOfNode(file.imports[i], file); - fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.File_0_is_not_a_module, importedFile.fileName)); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName)); } else if (!ts.fileExtensionIs(importedFile.fileName, ".d.ts")) { var start_3 = ts.getTokenPosOfNode(file.imports[i], file); @@ -30610,8 +31083,8 @@ var ts; var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } - if (options.module && languageVersion >= 2) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); + if (options.module === 5 && languageVersion < 2) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower)); } if (options.outDir || options.sourceRoot || @@ -30645,17 +31118,10 @@ var ts; !options.experimentalDecorators) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } - if (options.experimentalAsyncFunctions && - options.target !== 2) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); - } } } ts.createProgram = createProgram; })(ts || (ts = {})); -// Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. -// See LICENSE.txt in the project root for complete license information. -/// var ts; (function (ts) { var BreakpointResolver; @@ -30694,98 +31160,98 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 195) { + if (node.parent.kind === 197) { return spanInPreviousNode(node); } - if (node.parent.kind === 197) { + if (node.parent.kind === 199) { return textSpan(node); } - if (node.parent.kind === 179 && node.parent.operatorToken.kind === 24) { + if (node.parent.kind === 181 && node.parent.operatorToken.kind === 24) { return textSpan(node); } - if (node.parent.kind === 172 && node.parent.body === node) { + if (node.parent.kind === 174 && node.parent.body === node) { return textSpan(node); } } switch (node.kind) { - case 191: + case 193: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 209: - case 139: - case 138: - return spanInVariableDeclaration(node); - case 136: - return spanInParameterDeclaration(node); case 211: case 141: case 140: + return spanInVariableDeclaration(node); + case 138: + return spanInParameterDeclaration(node); + case 213: case 143: - case 144: case 142: - case 171: - case 172: + case 145: + case 146: + case 144: + case 173: + case 174: return spanInFunctionDeclaration(node); - case 190: + case 192: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 217: + case 219: return spanInBlock(node); - case 242: + case 244: return spanInBlock(node.block); - case 193: + case 195: return textSpan(node.expression); - case 202: + case 204: return textSpan(node.getChildAt(0), node.expression); - case 196: + case 198: return textSpan(node, ts.findNextToken(node.expression, node)); - case 195: + case 197: return spanInNode(node.statement); - case 208: + case 210: return textSpan(node.getChildAt(0)); - case 194: + case 196: return textSpan(node, ts.findNextToken(node.expression, node)); - case 205: + case 207: return spanInNode(node.statement); - case 201: - case 200: + case 203: + case 202: return textSpan(node.getChildAt(0), node.label); - case 197: - return spanInForStatement(node); - case 198: case 199: + return spanInForStatement(node); + case 200: + case 201: return textSpan(node, ts.findNextToken(node.expression, node)); - case 204: + case 206: return textSpan(node, ts.findNextToken(node.expression, node)); - case 239: - case 240: + case 241: + case 242: return spanInNode(node.statements[0]); - case 207: + case 209: return spanInBlock(node.tryBlock); - case 206: + case 208: return textSpan(node, node.expression); - case 225: + case 227: return textSpan(node, node.expression); - case 219: + case 221: return textSpan(node, node.moduleReference); - case 220: + case 222: return textSpan(node, node.moduleSpecifier); - case 226: + case 228: return textSpan(node, node.moduleSpecifier); - case 216: + case 218: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 212: - case 215: - case 245: - case 166: - case 167: + case 214: + case 217: + case 247: + case 168: + case 169: return textSpan(node); - case 203: + case 205: return spanInNode(node.statement); - case 213: - case 214: + case 215: + case 216: return undefined; case 23: case 1: @@ -30800,22 +31266,22 @@ var ts; return spanInOpenParenToken(node); case 18: return spanInCloseParenToken(node); - case 53: + case 54: return spanInColonToken(node); case 27: case 25: return spanInGreaterThanOrLessThanToken(node); - case 102: + case 104: return spanInWhileKeyword(node); - case 78: - case 70: - case 83: + case 80: + case 72: + case 85: return spanInNextNode(node); default: - if (node.parent.kind === 243 && node.parent.name === node) { + if (node.parent.kind === 245 && node.parent.name === node) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 169 && node.parent.type === node) { + if (node.parent.kind === 171 && node.parent.type === node) { return spanInNode(node.parent.expression); } if (ts.isFunctionLike(node.parent) && node.parent.type === node) { @@ -30825,12 +31291,12 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 198 || - variableDeclaration.parent.parent.kind === 199) { + if (variableDeclaration.parent.parent.kind === 200 || + variableDeclaration.parent.parent.kind === 201) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 191; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 197 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 193; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 199 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -30876,7 +31342,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1) || - (functionDeclaration.parent.kind === 212 && functionDeclaration.kind !== 142); + (functionDeclaration.parent.kind === 214 && functionDeclaration.kind !== 144); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -30896,23 +31362,23 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 216: + case 218: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 196: - case 194: case 198: - case 199: + case 196: + case 200: + case 201: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); - case 197: + case 199: 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 === 210) { + if (forStatement.initializer.kind === 212) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -30931,34 +31397,34 @@ var ts; } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 215: + case 217: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 212: + case 214: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 218: + case 220: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 217: + case 219: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 215: - case 212: + case 217: + case 214: return textSpan(node); - case 190: + case 192: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 242: + case 244: return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 218: + case 220: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { @@ -30970,24 +31436,24 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 195) { + if (node.parent.kind === 197) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 171: - case 211: - case 172: - case 141: - case 140: + case 173: + case 213: + case 174: case 143: - case 144: case 142: - case 196: - case 195: + case 145: + case 146: + case 144: + case 198: case 197: + case 199: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -30995,19 +31461,19 @@ var ts; return spanInNode(node.parent); } function spanInColonToken(node) { - if (ts.isFunctionLike(node.parent) || node.parent.kind === 243) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 245) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 169) { + if (node.parent.kind === 171) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 195) { + if (node.parent.kind === 197) { return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } return spanInNode(node.parent); @@ -31085,7 +31551,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 172; + return ts.isFunctionBlock(node) && node.parent.kind !== 174; } var depth = 0; var maxDepth = 20; @@ -31097,30 +31563,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 190: + case 192: if (!ts.isFunctionBlock(n)) { var parent_7 = n.parent; var openBrace = ts.findChildOfKind(n, 15, sourceFile); var closeBrace = ts.findChildOfKind(n, 16, sourceFile); - if (parent_7.kind === 195 || - parent_7.kind === 198 || + if (parent_7.kind === 197 || + parent_7.kind === 200 || + parent_7.kind === 201 || parent_7.kind === 199 || - parent_7.kind === 197 || - parent_7.kind === 194 || parent_7.kind === 196 || - parent_7.kind === 203 || - parent_7.kind === 242) { + parent_7.kind === 198 || + parent_7.kind === 205 || + parent_7.kind === 244) { addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_7.kind === 207) { + if (parent_7.kind === 209) { var tryStatement = parent_7; if (tryStatement.tryBlock === n) { addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 83, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 85, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -31136,23 +31602,23 @@ var ts; }); break; } - case 217: { + case 219: { var openBrace = ts.findChildOfKind(n, 15, sourceFile); var closeBrace = ts.findChildOfKind(n, 16, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 212: - case 213: + case 214: case 215: - case 163: - case 218: { + case 217: + case 165: + case 220: { var openBrace = ts.findChildOfKind(n, 15, sourceFile); var closeBrace = ts.findChildOfKind(n, 16, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 162: + case 164: var openBracket = ts.findChildOfKind(n, 19, sourceFile); var closeBracket = ts.findChildOfKind(n, 20, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -31178,10 +31644,10 @@ var ts; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_28 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_28); + for (var name_29 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_29); if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_28); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_29); if (!matches) { continue; } @@ -31192,14 +31658,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_28); + matches = patternMatcher.getMatches(containers, name_29); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_28, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_29, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -31222,7 +31688,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 67 || + if (node.kind === 69 || node.kind === 9 || node.kind === 8) { return node.text; @@ -31236,7 +31702,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 134) { + else if (declaration.name.kind === 136) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -31253,7 +31719,7 @@ var ts; } return true; } - if (expression.kind === 164) { + if (expression.kind === 166) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -31264,7 +31730,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 134) { + if (declaration.name.kind === 136) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -31315,7 +31781,6 @@ var ts; NavigateTo.getNavigateToItems = getNavigateToItems; })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); })(ts || (ts = {})); -/// var ts; (function (ts) { var NavigationBar; @@ -31328,14 +31793,14 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 216: + case 218: do { current = current.parent; - } while (current.kind === 216); - case 212: + } while (current.kind === 218); + case 214: + case 217: case 215: case 213: - case 211: indent++; } current = current.parent; @@ -31346,26 +31811,26 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 191: + case 193: ts.forEach(node.declarationList.declarations, visit); break; - case 159: - case 160: + case 161: + case 162: ts.forEach(node.elements, visit); break; - case 226: + case 228: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 220: + case 222: var importClause = node.importClause; if (importClause) { if (importClause.name) { childNodes.push(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 222) { + if (importClause.namedBindings.kind === 224) { childNodes.push(importClause.namedBindings); } else { @@ -31374,20 +31839,20 @@ var ts; } } break; - case 161: - case 209: + case 163: + case 211: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } - case 212: + case 214: + case 217: case 215: + case 218: case 213: - case 216: - case 211: - case 219: - case 224: - case 228: + case 221: + case 226: + case 230: childNodes.push(node); break; } @@ -31422,17 +31887,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 212: + case 214: + case 217: case 215: - case 213: topLevelNodes.push(node); break; - case 216: + case 218: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 211: + case 213: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -31443,9 +31908,9 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 211) { - if (functionDeclaration.body && functionDeclaration.body.kind === 190) { - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 211 && !isEmpty(s.name.text); })) { + if (functionDeclaration.kind === 213) { + if (functionDeclaration.body && functionDeclaration.body.kind === 192) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 213 && !isEmpty(s.name.text); })) { return true; } if (!ts.isFunctionBlock(functionDeclaration.parent)) { @@ -31498,7 +31963,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 136: + case 138: if (ts.isBindingPattern(node.name)) { break; } @@ -31506,34 +31971,34 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 141: - case 140: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); case 143: + case 142: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); + case 145: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 144: + case 146: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 147: + case 149: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 245: + case 247: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 145: + case 147: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 146: + case 148: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 139: - case 138: + case 141: + case 140: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 211: + case 213: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 209: - case 161: + case 211: + case 163: var variableDeclarationNode; - var name_29; - if (node.kind === 161) { - name_29 = node.name; + var name_30; + if (node.kind === 163) { + name_30 = node.name; variableDeclarationNode = node; - while (variableDeclarationNode && variableDeclarationNode.kind !== 209) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 211) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -31541,24 +32006,24 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_29 = node.name; + name_30 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.variableElement); } - case 142: + case 144: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 228: - case 224: - case 219: + case 230: + case 226: case 221: - case 222: + case 223: + case 224: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -31588,17 +32053,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 246: + case 248: return createSourceFileItem(node); - case 212: + case 214: return createClassItem(node); - case 215: + case 217: return createEnumItem(node); - case 213: + case 215: return createIterfaceItem(node); - case 216: + case 218: return createModuleItem(node); - case 211: + case 213: return createFunctionItem(node); } return undefined; @@ -31608,7 +32073,7 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 216) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 218) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -31620,7 +32085,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 === 190) { + if (node.body && node.body.kind === 192) { 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)); } @@ -31641,7 +32106,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 142 && member; + return member.kind === 144 && member; }); var nodes = removeDynamicallyNamedProperties(node); if (constructor) { @@ -31662,19 +32127,19 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 134; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 136; }); } function removeDynamicallyNamedProperties(node) { return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 216) { + while (node.body.kind === 218) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 246 + return node.kind === 248 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -32136,7 +32601,6 @@ var ts; return transition; } })(ts || (ts = {})); -/// var ts; (function (ts) { var SignatureHelp; @@ -32165,14 +32629,14 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 166) { + if (argumentInfo.invocation.kind !== 168) { return undefined; } var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 67 + var name = expression.kind === 69 ? expression - : expression.kind === 164 + : expression.kind === 166 ? expression.name : undefined; if (!name || !name.text) { @@ -32201,7 +32665,7 @@ var ts; } } function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 166 || node.parent.kind === 167) { + if (node.parent.kind === 168 || node.parent.kind === 169) { var callExpression = node.parent; if (node.kind === 25 || node.kind === 17) { @@ -32232,23 +32696,23 @@ var ts; }; } } - else if (node.kind === 11 && node.parent.kind === 168) { + else if (node.kind === 11 && node.parent.kind === 170) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0); } } - else if (node.kind === 12 && node.parent.parent.kind === 168) { + else if (node.kind === 12 && node.parent.parent.kind === 170) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 181); + ts.Debug.assert(templateExpression.kind === 183); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 188 && node.parent.parent.parent.kind === 168) { + else if (node.parent.kind === 190 && node.parent.parent.parent.kind === 170) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 181); + ts.Debug.assert(templateExpression.kind === 183); if (node.kind === 14 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } @@ -32312,7 +32776,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 181) { + if (template.kind === 183) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -32321,7 +32785,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 246; n = n.parent) { + for (var n = node; n.kind !== 248; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -32501,39 +32965,39 @@ var ts; return false; } switch (n.kind) { - case 212: - case 213: + case 214: case 215: - case 163: - case 159: - case 153: - case 190: case 217: - case 218: + case 165: + case 161: + case 155: + case 192: + case 219: + case 220: return nodeEndsWith(n, 16, sourceFile); - case 242: + case 244: return isCompletedNode(n.block, sourceFile); - case 167: + case 169: if (!n.arguments) { return true; } - case 166: - case 170: - case 158: + case 168: + case 172: + case 160: return nodeEndsWith(n, 18, sourceFile); - case 150: - case 151: + case 152: + case 153: return isCompletedNode(n.type, sourceFile); - case 142: - case 143: case 144: - case 211: - case 171: - case 141: - case 140: - case 146: case 145: - case 172: + case 146: + case 213: + case 173: + case 143: + case 142: + case 148: + case 147: + case 174: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -32541,61 +33005,62 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 18, sourceFile); - case 216: + case 218: return n.body && isCompletedNode(n.body, sourceFile); - case 194: + case 196: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 193: - return isCompletedNode(n.expression, sourceFile); + case 195: + return isCompletedNode(n.expression, sourceFile) || + hasChildOfKind(n, 23); + case 164: case 162: - case 160: - case 165: - case 134: - case 155: + case 167: + case 136: + case 157: return nodeEndsWith(n, 20, sourceFile); - case 147: + case 149: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 20, sourceFile); - case 239: - case 240: + case 241: + case 242: return false; - case 197: - case 198: case 199: - case 196: + case 200: + case 201: + case 198: return isCompletedNode(n.statement, sourceFile); - case 195: - var hasWhileKeyword = findChildOfKind(n, 102, sourceFile); + case 197: + var hasWhileKeyword = findChildOfKind(n, 104, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 18, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 152: + case 154: return isCompletedNode(n.exprName, sourceFile); - case 174: - case 173: + case 176: case 175: - case 182: - case 183: + case 177: + case 184: + case 185: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 168: + case 170: return isCompletedNode(n.template, sourceFile); - case 181: + case 183: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 188: + case 190: return ts.nodeIsPresent(n.literal); - case 177: - return isCompletedNode(n.operand, sourceFile); case 179: + return isCompletedNode(n.operand, sourceFile); + case 181: return isCompletedNode(n.right, sourceFile); - case 180: + case 182: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -32638,7 +33103,7 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 269 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 271 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -32718,7 +33183,7 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n) || n.kind === 234) { + if (isToken(n) || n.kind === 236) { return n; } var children = n.getChildren(); @@ -32726,16 +33191,16 @@ var ts; return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n) || n.kind === 234) { + if (isToken(n) || n.kind === 236) { return n; } var children = n.getChildren(); for (var i = 0, len = children.length; i < len; i++) { var child = children[i]; - if (position < child.end && (nodeHasTokens(child) || child.kind === 234)) { + if (position < child.end && (nodeHasTokens(child) || child.kind === 236)) { var start = child.getStart(sourceFile); var lookInPreviousChild = (start >= position) || - (child.kind === 234 && start === child.end); + (child.kind === 236 && start === child.end); if (lookInPreviousChild) { var candidate = findRightmostChildNodeWithTokens(children, i); return candidate && findRightmostToken(candidate); @@ -32745,7 +33210,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 246); + ts.Debug.assert(startNode !== undefined || n.kind === 248); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -32797,9 +33262,9 @@ var ts; var node = ts.getTokenAtPosition(sourceFile, position); if (isToken(node)) { switch (node.kind) { - case 100: - case 106: - case 72: + case 102: + case 108: + case 74: node = node.parent === undefined ? undefined : node.parent.parent; break; default: @@ -32845,21 +33310,21 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 149 || node.kind === 166) { + if (node.kind === 151 || node.kind === 168) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 212 || node.kind === 213) { + if (ts.isFunctionLike(node) || node.kind === 214 || node.kind === 215) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 && n.kind <= 132; + return n.kind >= 0 && n.kind <= 134; } ts.isToken = isToken; function isWord(kind) { - return kind === 67 || ts.isKeyword(kind); + return kind === 69 || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { @@ -32869,8 +33334,17 @@ var ts; return kind === 2 || kind === 3; } ts.isComment = isComment; + function isStringOrRegularExpressionOrTemplateLiteral(kind) { + if (kind === 9 + || kind === 10 + || ts.isTemplateLiteralKind(kind)) { + return true; + } + return false; + } + ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 15 <= kind && kind <= 66; + return 15 <= kind && kind <= 68; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -32880,9 +33354,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { + case 112: case 110: - case 108: - case 109: + case 111: return true; } return false; @@ -32908,7 +33382,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 136; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 138; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -32930,7 +33404,8 @@ var ts; increaseIndent: function () { indent++; }, decreaseIndent: function () { indent--; }, clear: resetWriter, - trackSymbol: function () { } + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } }; function writeIndent() { if (lineStart) { @@ -33088,7 +33563,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 224 || location.parent.kind === 228) && + (location.parent.kind === 226 || location.parent.kind === 230) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -33104,14 +33579,16 @@ var ts; } ts.stripQuotes = stripQuotes; })(ts || (ts = {})); -/// -/// var ts; (function (ts) { var formatting; (function (formatting) { - var scanner = ts.createScanner(2, false); + var standardScanner = ts.createScanner(2, false, 0); + var jsxScanner = ts.createScanner(2, false, 1); + var scanner; function getFormattingScanner(sourceFile, startPos, endPos) { + ts.Debug.assert(scanner === undefined); + scanner = sourceFile.languageVariant === 1 ? jsxScanner : standardScanner; scanner.setText(sourceFile.text); scanner.setTextPos(startPos); var wasNewLine = true; @@ -33126,11 +33603,14 @@ var ts; isOnToken: isOnToken, lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, close: function () { + ts.Debug.assert(scanner !== undefined); lastTokenInfo = undefined; scanner.setText(undefined); + scanner = undefined; } }; function advance() { + ts.Debug.assert(scanner !== undefined); lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { @@ -33172,10 +33652,10 @@ var ts; if (node) { switch (node.kind) { case 29: - case 62: - case 63: + case 64: + case 65: + case 45: case 44: - case 43: return true; } } @@ -33184,11 +33664,11 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 236: - case 233: + case 238: case 235: - case 232: - return node.kind === 67; + case 237: + case 234: + return node.kind === 69; } } return false; @@ -33201,9 +33681,10 @@ var ts; container.kind === 14; } function startsWithSlashToken(t) { - return t === 38 || t === 59; + return t === 39 || t === 61; } function readTokenInfo(n) { + ts.Debug.assert(scanner !== undefined); if (!isOnToken()) { return { leadingTrivia: leadingTrivia, @@ -33243,7 +33724,7 @@ var ts; currentToken = scanner.reScanTemplateToken(); lastScanAction = 3; } - else if (expectedScanAction === 4 && currentToken === 67) { + else if (expectedScanAction === 4 && currentToken === 69) { currentToken = scanner.scanJsxIdentifier(); lastScanAction = 4; } @@ -33285,6 +33766,7 @@ var ts; return fixTokenKind(lastTokenInfo, n); } function isOnToken() { + ts.Debug.assert(scanner !== undefined); var current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); var startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); return startPos < endPos && current !== 1 && !ts.isTrivia(current); @@ -33299,7 +33781,6 @@ var ts; formatting.getFormattingScanner = getFormattingScanner; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -/// var ts; (function (ts) { var formatting; @@ -33378,8 +33859,6 @@ var ts; formatting.FormattingContext = FormattingContext; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -/// -/// var ts; (function (ts) { var formatting; @@ -33401,8 +33880,6 @@ var ts; formatting.Rule = Rule; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -/// -/// var ts; (function (ts) { var formatting; @@ -33433,8 +33910,6 @@ var ts; formatting.RuleDescriptor = RuleDescriptor; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -/// -/// var ts; (function (ts) { var formatting; @@ -33462,7 +33937,6 @@ var ts; formatting.RuleOperation = RuleOperation; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -/// var ts; (function (ts) { var formatting; @@ -33496,28 +33970,24 @@ var ts; formatting.RuleOperationContext = RuleOperationContext; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -/// var ts; (function (ts) { var formatting; (function (formatting) { var Rules = (function () { function Rules() { - /// - /// Common Rules - /// this.IgnoreBeforeComment = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.Comments), formatting.RuleOperation.create1(1)); this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1)); this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16, 78), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16, 102), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16, 80), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16, 104), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.FromTokens([18, 20, 24, 23])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); @@ -33525,9 +33995,9 @@ var ts; this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8)); this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([67, 3, 71]); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([69, 3, 73]); this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18, 3, 77, 98, 83, 78]); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18, 3, 79, 100, 85, 80]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); @@ -33535,37 +34005,37 @@ var ts; this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(40, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(41, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(41, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100, 96, 90, 76, 92, 99]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([106, 72]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([102, 98, 92, 78, 94, 101, 119]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([108, 74]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(85, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(87, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(101, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(92, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18, 77, 78, 69]), 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([98, 83]), 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([121, 127]), 67), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(103, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(94, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18, 79, 80, 71]), 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([100, 85]), 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123, 129]), 69), 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(119, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123, 125]), 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113, 71, 120, 75, 79, 80, 81, 121, 104, 87, 105, 123, 124, 108, 110, 109, 127, 111]), 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([81, 104])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(121, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125, 127]), 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115, 73, 122, 77, 81, 82, 83, 123, 106, 89, 107, 125, 126, 110, 112, 111, 129, 113, 132]), 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([83, 106])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22, 67), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.FromTokens([18, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22, 69), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.FromTokens([18, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); @@ -33573,27 +34043,18 @@ var ts; this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.FromTokens([17, 19, 27, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeAssertionContext), 8)); this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8)); - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(54, 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([113, 67, 80, 75, 71, 111, 110, 108, 109, 121, 127, 19, 37])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(85, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37, formatting.Shared.TokenRange.FromTokens([67, 17])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(112, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112, 37]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); - this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116, 85), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116, 85), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceBeforeAmpersand = new formatting.Rule(formatting.RuleDescriptor.create3(45, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterAmpersand = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 45), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55, 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([115, 69, 82, 77, 73, 113, 112, 110, 111, 123, 129, 19, 37])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(87, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37, formatting.Shared.TokenRange.FromTokens([69, 17])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(114, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([114, 37]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); + this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118, 87), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12, 13]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13, 14])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -33619,12 +34080,8 @@ var ts; this.NoSpaceBeforeOpenParenInFuncCall, this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, this.SpaceAfterVoidOperator, - this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword, - this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword, - this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword, - this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString, - this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar, - this.SpaceBeforeAmpersand, this.SpaceAfterAmpersand, + this.SpaceBetweenAsyncAndOpenParen, this.SpaceBetweenAsyncAndFunctionKeyword, + this.SpaceBetweenTagAndTemplateString, this.NoSpaceAfterTemplateHeadAndMiddle, this.NoSpaceBeforeTemplateMiddleAndTail, this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, this.SpaceAfterModuleName, @@ -33676,44 +34133,46 @@ var ts; this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_30 in o) { - if (o[name_30] === rule) { - return name_30; + for (var name_31 in o) { + if (o[name_31] === rule) { + return name_31; } } throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 197; + return context.contextNode.kind === 199; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 179: - case 180: - case 187: - case 148: + case 181: + case 182: + case 189: + case 150: + case 158: + case 159: return true; - case 161: - case 214: - case 219: - case 209: - case 136: - case 245: - case 139: + case 163: + case 216: + case 221: + case 211: case 138: - return context.currentTokenSpan.kind === 55 || context.nextTokenSpan.kind === 55; - case 198: - return context.currentTokenSpan.kind === 88 || context.nextTokenSpan.kind === 88; - case 199: - return context.currentTokenSpan.kind === 132 || context.nextTokenSpan.kind === 132; + case 247: + case 141: + case 140: + return context.currentTokenSpan.kind === 56 || context.nextTokenSpan.kind === 56; + case 200: + return context.currentTokenSpan.kind === 90 || context.nextTokenSpan.kind === 90; + case 201: + return context.currentTokenSpan.kind === 134 || context.nextTokenSpan.kind === 134; } return false; }; @@ -33721,25 +34180,9 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 180; + return context.contextNode.kind === 182; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { - //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. - //// - //// Ex: - //// if (1) { .... - //// * ) and { are on the same line so apply the rule. Here we don't care whether it's same or multi block context - //// - //// Ex: - //// if (1) - //// { ... } - //// * ) and { are on differnet lines. We only need to format if the block is multiline context. So in this case we don't format. - //// - //// Ex: - //// if (1) - //// { ... - //// } - //// * ) and { are on differnet lines. We only need to format if the block is multiline context. So in this case we format. return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); }; Rules.IsBeforeMultilineBlockContext = function (context) { @@ -33762,86 +34205,86 @@ var ts; return true; } switch (node.kind) { - case 190: - case 218: - case 163: - case 217: + case 192: + case 220: + case 165: + case 219: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 211: - case 141: - case 140: + case 213: case 143: - case 144: - case 145: - case 171: case 142: - case 172: - case 213: + case 145: + case 146: + case 147: + case 173: + case 144: + case 174: + case 215: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 211 || context.contextNode.kind === 171; + return context.contextNode.kind === 213 || context.contextNode.kind === 173; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 212: - case 184: - case 213: + case 214: + case 186: case 215: - case 153: - case 216: + case 217: + case 155: + case 218: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 212: - case 216: - case 215: - case 190: - case 242: + case 214: + case 218: case 217: - case 204: + case 192: + case 244: + case 219: + case 206: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 194: - case 204: - case 197: - case 198: - case 199: case 196: - case 207: - case 195: - case 203: - case 242: + case 206: + case 199: + case 200: + case 201: + case 198: + case 209: + case 197: + case 205: + case 244: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 163; + return context.contextNode.kind === 165; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 166; + return context.contextNode.kind === 168; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 167; + return context.contextNode.kind === 169; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -33849,6 +34292,9 @@ var ts; Rules.IsPreviousTokenNotComma = function (context) { return context.currentTokenSpan.kind !== 24; }; + Rules.IsArrowFunctionContext = function (context) { + return context.contextNode.kind === 174; + }; Rules.IsSameLineTokenContext = function (context) { return context.TokensAreOnSameLine(); }; @@ -33865,41 +34311,41 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 137; + return node.kind === 139; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 210 && + return context.currentTokenParent.kind === 212 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 216; + return context.contextNode.kind === 218; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 153; + return context.contextNode.kind === 155; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { if (token.kind !== 25 && token.kind !== 27) { return false; } switch (parent.kind) { - case 149: - case 169: - case 212: - case 184: - case 213: - case 211: + case 151: case 171: - case 172: - case 141: - case 140: - case 145: - case 146: - case 166: - case 167: + case 214: case 186: + case 215: + case 213: + case 173: + case 174: + case 143: + case 142: + case 147: + case 148: + case 168: + case 169: + case 188: return true; default: return false; @@ -33910,20 +34356,19 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 169; + return context.contextNode.kind === 171; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 101 && context.currentTokenParent.kind === 175; + return context.currentTokenSpan.kind === 103 && context.currentTokenParent.kind === 177; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 182 && context.contextNode.expression !== undefined; + return context.contextNode.kind === 184 && context.contextNode.expression !== undefined; }; return Rules; })(); formatting.Rules = Rules; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -/// var ts; (function (ts) { var formatting; @@ -33939,7 +34384,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 132 + 1; + this.mapRowLength = 134 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -34060,7 +34505,6 @@ var ts; formatting.RulesBucket = RulesBucket; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -/// var ts; (function (ts) { var formatting; @@ -34116,7 +34560,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 132; token++) { + for (var token = 0; token <= 134; token++) { result.push(token); } return result; @@ -34158,36 +34602,23 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(68, 132); - TokenRange.BinaryOperators = TokenRange.FromRange(25, 66); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([88, 89, 132, 114, 122]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([40, 41, 49, 48]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 67, 17, 19, 15, 95, 90]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([67, 17, 95, 90]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([67, 18, 20, 90]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([67, 17, 95, 90]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([67, 18, 20, 90]); + TokenRange.Keywords = TokenRange.FromRange(70, 134); + TokenRange.BinaryOperators = TokenRange.FromRange(25, 68); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90, 91, 134, 116, 124]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([41, 42, 50, 49]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 69, 17, 19, 15, 97, 92]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([69, 17, 97, 92]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([69, 18, 20, 92]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([69, 17, 97, 92]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([69, 18, 20, 92]); TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([67, 126, 128, 118, 129, 101, 115]); + TokenRange.TypeNames = TokenRange.FromTokens([69, 128, 130, 120, 131, 103, 117]); return TokenRange; })(); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// var ts; (function (ts) { var formatting; @@ -34283,10 +34714,6 @@ var ts; formatting.RulesProvider = RulesProvider; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -/// -/// -/// -/// var ts; (function (ts) { var formatting; @@ -34356,17 +34783,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 212: - case 213: + case 214: + case 215: return ts.rangeContainsRange(parent.members, node); - case 216: + case 218: var body = parent.body; - return body && body.kind === 190 && ts.rangeContainsRange(body.statements, node); - case 246: - case 190: - case 217: + return body && body.kind === 192 && ts.rangeContainsRange(body.statements, node); + case 248: + case 192: + case 219: return ts.rangeContainsRange(parent.statements, node); - case 242: + case 244: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -34491,9 +34918,9 @@ var ts; if (indentation === -1) { if (isSomeBlock(node.kind)) { if (isSomeBlock(parent.kind) || - parent.kind === 246 || - parent.kind === 239 || - parent.kind === 240) { + parent.kind === 248 || + parent.kind === 241 || + parent.kind === 242) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -34526,30 +34953,31 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 212: return 71; - case 213: return 105; - case 211: return 85; - case 215: return 215; - case 143: return 121; - case 144: return 127; - case 141: + case 214: return 73; + case 215: return 107; + case 213: return 87; + case 217: return 217; + case 145: return 123; + case 146: return 129; + case 143: if (node.asteriskToken) { return 37; } - case 139: - case 136: + case 141: + case 138: return node.name.kind; } } function getDynamicIndentation(node, nodeStartLine, indentation, delta) { return { - getIndentationForComment: function (kind) { + getIndentationForComment: function (kind, tokenIndentation) { switch (kind) { case 16: case 20: + case 18: return indentation + delta; } - return indentation; + return tokenIndentation !== -1 ? tokenIndentation : indentation; }, getIndentationForToken: function (line, kind) { if (nodeStartLine !== line && node.decorators) { @@ -34564,9 +34992,9 @@ var ts; case 20: case 17: case 18: - case 78: - case 102: - case 54: + case 80: + case 104: + case 55: return indentation; default: return nodeStartLine !== line ? indentation + delta : indentation; @@ -34646,7 +35074,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 137 ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 139 ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -34718,8 +35146,12 @@ var ts; processTrivia(currentTokenInfo.trailingTrivia, parent, childContextNode, dynamicIndentation); } if (indentToken) { - var indentNextTokenOrTrivia = true; + var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? + dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind) : + -1; if (currentTokenInfo.leadingTrivia) { + var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation); + var indentNextTokenOrTrivia = true; for (var _i = 0, _a = currentTokenInfo.leadingTrivia; _i < _a.length; _i++) { var triviaItem = _a[_i]; if (!ts.rangeContainsRange(originalRange, triviaItem)) { @@ -34727,14 +35159,12 @@ var ts; } switch (triviaItem.kind) { case 3: - var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); indentMultilineComment(triviaItem, commentIndentation, !indentNextTokenOrTrivia); indentNextTokenOrTrivia = false; break; case 2: if (indentNextTokenOrTrivia) { - var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); - insertIndentation(triviaItem.pos, commentIndentation_1, false); + insertIndentation(triviaItem.pos, commentIndentation, false); indentNextTokenOrTrivia = false; } break; @@ -34744,8 +35174,7 @@ var ts; } } } - if (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) { - var tokenIndentation = dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind); + if (tokenIndentation !== -1) { insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded); lastIndentedLine = tokenStart.line; indentationOnLastIndentedLine = tokenIndentation; @@ -34877,7 +35306,7 @@ var ts; for (var line = line1; line < line2; ++line) { var lineStartPosition = ts.getStartPositionOfLine(line, sourceFile); var lineEndPosition = ts.getEndLinePosition(line, sourceFile); - if (range && ts.isComment(range.kind) && range.pos <= lineEndPosition && range.end > lineEndPosition) { + if (range && (ts.isComment(range.kind) || ts.isStringOrRegularExpressionOrTemplateLiteral(range.kind)) && range.pos <= lineEndPosition && range.end > lineEndPosition) { continue; } var pos = lineEndPosition; @@ -34936,20 +35365,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 190: - case 217: + case 192: + case 219: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { + case 144: + case 213: + case 173: + case 143: case 142: - case 211: - case 171: - case 141: - case 140: - case 172: + case 174: if (node.typeParameters === list) { return 25; } @@ -34957,8 +35386,8 @@ var ts; return 17; } break; - case 166: - case 167: + case 168: + case 169: if (node.typeArguments === list) { return 25; } @@ -34966,7 +35395,7 @@ var ts; return 17; } break; - case 149: + case 151: if (node.typeArguments === list) { return 25; } @@ -35033,7 +35462,6 @@ var ts; formatting.getIndentationString = getIndentationString; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -/// var ts; (function (ts) { var formatting; @@ -35044,21 +35472,31 @@ var ts; if (position > sourceFile.text.length) { return 0; } + if (options.IndentStyle === ts.IndentStyle.None) { + return 0; + } var precedingToken = ts.findPrecedingToken(position, sourceFile); if (!precedingToken) { return 0; } - var precedingTokenIsLiteral = precedingToken.kind === 9 || - precedingToken.kind === 10 || - precedingToken.kind === 11 || - precedingToken.kind === 12 || - precedingToken.kind === 13 || - precedingToken.kind === 14; + var precedingTokenIsLiteral = ts.isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 24 && precedingToken.parent.kind !== 179) { + if (options.IndentStyle === ts.IndentStyle.Block) { + var current_1 = position; + while (current_1 > 0) { + var char = sourceFile.text.charCodeAt(current_1); + if (!ts.isWhiteSpace(char) && !ts.isLineBreak(char)) { + break; + } + current_1--; + } + var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); + return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); + } + if (precedingToken.kind === 24 && precedingToken.parent.kind !== 181) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -35156,7 +35594,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 246 || !parentAndChildShareLine); + (parent.kind === 248 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -35180,8 +35618,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 194 && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 78, sourceFile); + if (parent.kind === 196 && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 80, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -35192,23 +35630,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 149: + case 151: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 163: + case 165: return node.parent.properties; - case 162: + case 164: return node.parent.elements; - case 211: - case 171: - case 172: - case 141: - case 140: - case 145: - case 146: { + case 213: + case 173: + case 174: + case 143: + case 142: + case 147: + case 148: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -35219,8 +35657,8 @@ var ts; } break; } - case 167: - case 166: { + case 169: + case 168: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -35248,8 +35686,8 @@ var ts; if (node.kind === 18) { return -1; } - if (node.parent && (node.parent.kind === 166 || - node.parent.kind === 167) && + if (node.parent && (node.parent.kind === 168 || + node.parent.kind === 169) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -35267,10 +35705,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { + case 168: + case 169: case 166: case 167: - case 164: - case 165: node = node.expression; break; default: @@ -35325,42 +35763,43 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 212: - case 184: - case 213: - case 215: + case 195: case 214: - case 162: - case 190: + case 186: + case 215: case 217: - case 163: - case 153: - case 155: - case 218: - case 240: - case 239: - case 170: + case 216: case 164: + case 192: + case 219: + case 165: + case 155: + case 157: + case 220: + case 242: + case 241: + case 172: case 166: - case 167: - case 191: - case 209: - case 225: - case 202: - case 180: - case 160: - case 159: - case 231: - case 232: - case 140: - case 145: - case 146: - case 136: - case 150: - case 151: - case 158: case 168: - case 176: + case 169: + case 193: + case 211: + case 227: + case 204: + case 182: + case 162: + case 161: + case 233: + case 234: + case 142: + case 147: + case 148: + case 138: + case 152: + case 153: + case 160: + case 170: + case 178: return true; } return false; @@ -35370,20 +35809,20 @@ var ts; return true; } switch (parent) { - case 195: - case 196: + case 197: case 198: + case 200: + case 201: case 199: - case 197: - case 194: - case 211: - case 171: - case 141: - case 172: - case 142: + case 196: + case 213: + case 173: case 143: + case 174: case 144: - return child !== 190; + case 145: + case 146: + return child !== 192; default: return false; } @@ -35392,21 +35831,11 @@ var ts; })(SmartIndenter = formatting.SmartIndenter || (formatting.SmartIndenter = {})); })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (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; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -/// -/// -/// -/// -/// -/// -/// -/// -/// var ts; (function (ts) { ts.servicesVersion = "0.4"; @@ -35522,7 +35951,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(269, nodes.pos, nodes.end, 4096, this); + var list = createNode(271, nodes.pos, nodes.end, 4096, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -35541,7 +35970,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 133) { + if (this.kind >= 135) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -35588,7 +36017,7 @@ var ts; return undefined; } var child = children[0]; - return child.kind < 133 ? child : child.getFirstToken(sourceFile); + return child.kind < 135 ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -35596,7 +36025,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 133 ? child : child.getLastToken(sourceFile); + return child.kind < 135 ? child : child.getLastToken(sourceFile); }; return NodeObject; })(); @@ -35638,7 +36067,7 @@ var ts; ts.forEach(declarations, function (declaration, indexOfDeclaration) { if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); - if (canUseParsedParamTagComments && declaration.kind === 136) { + if (canUseParsedParamTagComments && declaration.kind === 138) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -35646,13 +36075,13 @@ var ts; } }); } - if (declaration.kind === 216 && declaration.body.kind === 216) { + if (declaration.kind === 218 && declaration.body.kind === 218) { return; } - while (declaration.kind === 216 && declaration.parent.kind === 216) { + while (declaration.kind === 218 && declaration.parent.kind === 218) { declaration = declaration.parent; } - ts.forEach(getJsDocCommentTextRange(declaration.kind === 209 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 211 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { ts.addRange(jsDocCommentParts, cleanedJsDocComment); @@ -35962,9 +36391,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 134) { + if (declaration.name.kind === 136) { var expr = declaration.name.expression; - if (expr.kind === 164) { + if (expr.kind === 166) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -35974,7 +36403,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 67 || + if (node.kind === 69 || node.kind === 9 || node.kind === 8) { return node.text; @@ -35984,9 +36413,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 211: - case 141: - case 140: + case 213: + case 143: + case 142: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -36003,62 +36432,62 @@ var ts; ts.forEachChild(node, visit); } break; - case 212: - case 213: case 214: case 215: case 216: - case 219: - case 228: - case 224: - case 219: + case 217: + case 218: case 221: - case 222: - case 143: - case 144: - case 153: + case 230: + case 226: + case 221: + case 223: + case 224: + case 145: + case 146: + case 155: addDeclaration(node); - case 142: - case 191: - case 210: - case 159: - case 160: - case 217: + case 144: + case 193: + case 212: + case 161: + case 162: + case 219: ts.forEachChild(node, visit); break; - case 190: + case 192: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 136: + case 138: if (!(node.flags & 112)) { break; } - case 209: - case 161: + case 211: + case 163: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 245: - case 139: - case 138: + case 247: + case 141: + case 140: addDeclaration(node); break; - case 226: + case 228: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 220: + case 222: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 222) { + if (importClause.namedBindings.kind === 224) { addDeclaration(importClause.namedBindings); } else { @@ -36085,6 +36514,12 @@ var ts; HighlightSpanKind.reference = "reference"; HighlightSpanKind.writtenReference = "writtenReference"; })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); + (function (IndentStyle) { + IndentStyle[IndentStyle["None"] = 0] = "None"; + IndentStyle[IndentStyle["Block"] = 1] = "Block"; + IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; + })(ts.IndentStyle || (ts.IndentStyle = {})); + var IndentStyle = ts.IndentStyle; (function (SymbolDisplayPartKind) { SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className"; @@ -36200,14 +36635,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 171) { + if (declaration.kind === 173) { return true; } - if (declaration.kind !== 209 && declaration.kind !== 211) { + if (declaration.kind !== 211 && declaration.kind !== 213) { return false; } for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { - if (parent_8.kind === 246 || parent_8.kind === 217) { + if (parent_8.kind === 248 || parent_8.kind === 219) { return false; } } @@ -36318,7 +36753,7 @@ var ts; options.allowNonTsExtensions = true; options.noLib = true; options.noResolve = true; - var inputFileName = transpileOptions.fileName || "module.ts"; + var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); var sourceFile = ts.createSourceFile(inputFileName, input, options.target); if (transpileOptions.moduleName) { sourceFile.moduleName = transpileOptions.moduleName; @@ -36538,9 +36973,9 @@ var ts; scanner.setText(sourceText); var token = scanner.scan(); while (token !== 1) { - if (token === 120) { + if (token === 122) { token = scanner.scan(); - if (token === 123) { + if (token === 125) { token = scanner.scan(); if (token === 9) { recordAmbientExternalModule(); @@ -36548,25 +36983,25 @@ var ts; } } } - else if (token === 87) { + else if (token === 89) { token = scanner.scan(); if (token === 9) { recordModuleName(); continue; } else { - if (token === 67 || ts.isKeyword(token)) { + if (token === 69 || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 131) { + if (token === 133) { token = scanner.scan(); if (token === 9) { recordModuleName(); continue; } } - else if (token === 55) { + else if (token === 56) { token = scanner.scan(); - if (token === 125) { + if (token === 127) { token = scanner.scan(); if (token === 17) { token = scanner.scan(); @@ -36591,7 +37026,7 @@ var ts; } if (token === 16) { token = scanner.scan(); - if (token === 131) { + if (token === 133) { token = scanner.scan(); if (token === 9) { recordModuleName(); @@ -36601,11 +37036,11 @@ var ts; } else if (token === 37) { token = scanner.scan(); - if (token === 114) { + if (token === 116) { token = scanner.scan(); - if (token === 67 || ts.isKeyword(token)) { + if (token === 69 || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 131) { + if (token === 133) { token = scanner.scan(); if (token === 9) { recordModuleName(); @@ -36616,7 +37051,7 @@ var ts; } } } - else if (token === 80) { + else if (token === 82) { token = scanner.scan(); if (token === 15) { token = scanner.scan(); @@ -36625,7 +37060,7 @@ var ts; } if (token === 16) { token = scanner.scan(); - if (token === 131) { + if (token === 133) { token = scanner.scan(); if (token === 9) { recordModuleName(); @@ -36635,20 +37070,20 @@ var ts; } else if (token === 37) { token = scanner.scan(); - if (token === 131) { + if (token === 133) { token = scanner.scan(); if (token === 9) { recordModuleName(); } } } - else if (token === 87) { + else if (token === 89) { token = scanner.scan(); - if (token === 67 || ts.isKeyword(token)) { + if (token === 69 || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 55) { + if (token === 56) { token = scanner.scan(); - if (token === 125) { + if (token === 127) { token = scanner.scan(); if (token === 17) { token = scanner.scan(); @@ -36674,7 +37109,7 @@ var ts; ts.preProcessFile = preProcessFile; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 205 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 207 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -36682,17 +37117,17 @@ var ts; return undefined; } function isJumpStatementTarget(node) { - return node.kind === 67 && - (node.parent.kind === 201 || node.parent.kind === 200) && + return node.kind === 69 && + (node.parent.kind === 203 || node.parent.kind === 202) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { - return node.kind === 67 && - node.parent.kind === 205 && + return node.kind === 69 && + node.parent.kind === 207 && node.parent.label === node; } function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 205; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 207; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -36703,48 +37138,48 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 133 && node.parent.right === node; + return node.parent.kind === 135 && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 164 && node.parent.name === node; + return node && node.parent && node.parent.kind === 166 && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 166 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 168 && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 167 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 169 && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 216 && node.parent.name === node; + return node.parent.kind === 218 && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { - return node.kind === 67 && + return node.kind === 69 && ts.isFunctionLike(node.parent) && node.parent.name === node; } function isNameOfPropertyAssignment(node) { - return (node.kind === 67 || node.kind === 9 || node.kind === 8) && - (node.parent.kind === 243 || node.parent.kind === 244) && node.parent.name === node; + return (node.kind === 69 || node.kind === 9 || node.kind === 8) && + (node.parent.kind === 245 || node.parent.kind === 246) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 || node.kind === 8) { switch (node.parent.kind) { - case 139: - case 138: - case 243: - case 245: case 141: case 140: + case 245: + case 247: case 143: - case 144: - case 216: + case 142: + case 145: + case 146: + case 218: return node.parent.name === node; - case 165: + case 167: return node.parent.argumentExpression === node; } } @@ -36782,7 +37217,7 @@ var ts; } } var keywordCompletions = []; - for (var i = 68; i <= 132; i++) { + for (var i = 70; i <= 134; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -36797,17 +37232,17 @@ var ts; return undefined; } switch (node.kind) { - case 246: - case 141: - case 140: - case 211: - case 171: + case 248: case 143: - case 144: - case 212: + case 142: case 213: + case 173: + case 145: + case 146: + case 214: case 215: - case 216: + case 217: + case 218: return node; } } @@ -36815,38 +37250,38 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 216: return ScriptElementKind.moduleElement; - case 212: return ScriptElementKind.classElement; - case 213: return ScriptElementKind.interfaceElement; - case 214: return ScriptElementKind.typeElement; - case 215: return ScriptElementKind.enumElement; - case 209: + case 218: return ScriptElementKind.moduleElement; + case 214: return ScriptElementKind.classElement; + case 215: return ScriptElementKind.interfaceElement; + case 216: return ScriptElementKind.typeElement; + case 217: return ScriptElementKind.enumElement; + case 211: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 211: return ScriptElementKind.functionElement; - case 143: return ScriptElementKind.memberGetAccessorElement; - case 144: return ScriptElementKind.memberSetAccessorElement; + case 213: return ScriptElementKind.functionElement; + case 145: return ScriptElementKind.memberGetAccessorElement; + case 146: return ScriptElementKind.memberSetAccessorElement; + case 143: + case 142: + return ScriptElementKind.memberFunctionElement; case 141: case 140: - return ScriptElementKind.memberFunctionElement; - case 139: - case 138: return ScriptElementKind.memberVariableElement; - case 147: return ScriptElementKind.indexSignatureElement; - case 146: return ScriptElementKind.constructSignatureElement; - case 145: return ScriptElementKind.callSignatureElement; - case 142: return ScriptElementKind.constructorImplementationElement; - case 135: return ScriptElementKind.typeParameterElement; - case 245: return ScriptElementKind.variableElement; - case 136: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 219: - case 224: + case 149: return ScriptElementKind.indexSignatureElement; + case 148: return ScriptElementKind.constructSignatureElement; + case 147: return ScriptElementKind.callSignatureElement; + case 144: return ScriptElementKind.constructorImplementationElement; + case 137: return ScriptElementKind.typeParameterElement; + case 247: return ScriptElementKind.variableElement; + case 138: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; case 221: - case 228: - case 222: + case 226: + case 223: + case 230: + case 224: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -37028,44 +37463,44 @@ var ts; return false; } switch (node.kind) { - case 219: + case 221: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 225: + case 227: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 212: + case 214: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 241: + case 243: var heritageClause = node; - if (heritageClause.token === 104) { + if (heritageClause.token === 106) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 213: + case 215: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 216: + case 218: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 214: + case 216: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 141: - case 140: - case 142: case 143: + case 142: case 144: - case 171: - case 211: - case 172: - case 211: + case 145: + case 146: + case 173: + case 213: + case 174: + case 213: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -37073,20 +37508,20 @@ var ts; return true; } break; - case 191: + case 193: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 209: + case 211: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 166: - case 167: + case 168: + case 169: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -37094,7 +37529,7 @@ var ts; return true; } break; - case 136: + case 138: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -37110,17 +37545,17 @@ var ts; return true; } break; - case 139: + case 141: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 215: + case 217: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 169: + case 171: 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 137: + case 139: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -37146,17 +37581,17 @@ var ts; for (var _i = 0; _i < modifiers.length; _i++) { var modifier = modifiers[_i]; switch (modifier.kind) { + case 112: case 110: - case 108: - case 109: - case 120: + case 111: + case 122: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; - case 111: - case 80: - case 72: - case 75: case 113: + case 82: + case 74: + case 77: + case 115: } } } @@ -37220,9 +37655,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { + case 269: case 267: - case 265: - case 266: + case 268: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -37250,6 +37685,7 @@ var ts; var node = currentToken; var isRightOfDot = false; var isRightOfOpenTag = false; + var isStartingCloseTag = false; var location = ts.getTouchingPropertyName(sourceFile, position); if (contextToken) { if (isCompletionListBlocker(contextToken)) { @@ -37258,11 +37694,11 @@ var ts; } var parent_9 = contextToken.parent, kind = contextToken.kind; if (kind === 21) { - if (parent_9.kind === 164) { + if (parent_9.kind === 166) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_9.kind === 133) { + else if (parent_9.kind === 135) { node = contextToken.parent.left; isRightOfDot = true; } @@ -37270,9 +37706,14 @@ var ts; return undefined; } } - else if (kind === 25 && sourceFile.languageVariant === 1) { - isRightOfOpenTag = true; - location = contextToken; + else if (sourceFile.languageVariant === 1) { + if (kind === 25) { + isRightOfOpenTag = true; + location = contextToken; + } + else if (kind === 39 && contextToken.parent.kind === 237) { + isStartingCloseTag = true; + } } } var semanticStart = new Date().getTime(); @@ -37293,6 +37734,12 @@ var ts; isMemberCompletion = true; isNewIdentifierLocation = false; } + else if (isStartingCloseTag) { + var tagName = contextToken.parent.parent.openingElement.tagName; + symbols = [typeChecker.getSymbolAtLocation(tagName)]; + isMemberCompletion = true; + isNewIdentifierLocation = false; + } else { if (!tryGetGlobalSymbols()) { return undefined; @@ -37303,7 +37750,7 @@ var ts; function getTypeScriptMemberSymbols() { isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 67 || node.kind === 133 || node.kind === 164) { + if (node.kind === 69 || node.kind === 135 || node.kind === 166) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeChecker.getAliasedSymbol(symbol); @@ -37349,7 +37796,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType; - if ((jsxContainer.kind === 232) || (jsxContainer.kind === 233)) { + if ((jsxContainer.kind === 234) || (jsxContainer.kind === 235)) { attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); @@ -37383,49 +37830,64 @@ var ts; var start = new Date().getTime(); var result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || isSolelyIdentifierDefinitionLocation(contextToken) || - isDotOfNumericLiteral(contextToken); + isDotOfNumericLiteral(contextToken) || + isInJsxText(contextToken); log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); return result; } + function isInJsxText(contextToken) { + if (contextToken.kind === 236) { + return true; + } + if (contextToken.kind === 27 && contextToken.parent) { + if (contextToken.parent.kind === 235) { + return true; + } + if (contextToken.parent.kind === 237 || contextToken.parent.kind === 234) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 233; + } + } + return false; + } function isNewIdentifierDefinitionLocation(previousToken) { if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 24: - return containingNodeKind === 166 - || containingNodeKind === 142 - || containingNodeKind === 167 - || containingNodeKind === 162 - || containingNodeKind === 179 - || containingNodeKind === 150; + return containingNodeKind === 168 + || containingNodeKind === 144 + || containingNodeKind === 169 + || containingNodeKind === 164 + || containingNodeKind === 181 + || containingNodeKind === 152; case 17: - return containingNodeKind === 166 - || containingNodeKind === 142 - || containingNodeKind === 167 - || containingNodeKind === 170 - || containingNodeKind === 158; + return containingNodeKind === 168 + || containingNodeKind === 144 + || containingNodeKind === 169 + || containingNodeKind === 172 + || containingNodeKind === 160; case 19: - return containingNodeKind === 162 - || containingNodeKind === 147 - || containingNodeKind === 134; - case 123: - case 124: + return containingNodeKind === 164 + || containingNodeKind === 149 + || containingNodeKind === 136; + case 125: + case 126: return true; case 21: - return containingNodeKind === 216; + return containingNodeKind === 218; case 15: - return containingNodeKind === 212; - case 55: - return containingNodeKind === 209 - || containingNodeKind === 179; + return containingNodeKind === 214; + case 56: + return containingNodeKind === 211 + || containingNodeKind === 181; case 12: - return containingNodeKind === 181; + return containingNodeKind === 183; case 13: - return containingNodeKind === 188; + return containingNodeKind === 190; + case 112: case 110: - case 108: - case 109: - return containingNodeKind === 139; + case 111: + return containingNodeKind === 141; } switch (previousToken.getText()) { case "public": @@ -37456,12 +37918,12 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 163) { + if (objectLikeContainer.kind === 165) { isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 159) { + else if (objectLikeContainer.kind === 161) { isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); if (ts.isVariableLike(rootDeclaration)) { @@ -37487,9 +37949,9 @@ var ts; return true; } function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 223 ? - 220 : - 226; + var declarationKind = namedImportsOrExports.kind === 225 ? + 222 : + 228; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -37511,7 +37973,7 @@ var ts; case 15: case 24: var parent_10 = contextToken.parent; - if (parent_10 && (parent_10.kind === 163 || parent_10.kind === 159)) { + if (parent_10 && (parent_10.kind === 165 || parent_10.kind === 161)) { return parent_10; } break; @@ -37525,8 +37987,8 @@ var ts; case 15: case 24: switch (contextToken.parent.kind) { - case 223: - case 227: + case 225: + case 229: return contextToken.parent; } } @@ -37538,27 +38000,30 @@ var ts; var parent_11 = contextToken.parent; switch (contextToken.kind) { case 26: - case 38: - case 67: - case 236: - case 237: - if (parent_11 && (parent_11.kind === 232 || parent_11.kind === 233)) { + case 39: + case 69: + case 238: + case 239: + if (parent_11 && (parent_11.kind === 234 || parent_11.kind === 235)) { return parent_11; } + else if (parent_11.kind === 238) { + return parent_11.parent; + } break; case 9: - if (parent_11 && ((parent_11.kind === 236) || (parent_11.kind === 237))) { + if (parent_11 && ((parent_11.kind === 238) || (parent_11.kind === 239))) { return parent_11.parent; } break; case 16: if (parent_11 && - parent_11.kind === 238 && + parent_11.kind === 240 && parent_11.parent && - (parent_11.parent.kind === 236)) { + (parent_11.parent.kind === 238)) { return parent_11.parent.parent; } - if (parent_11 && parent_11.kind === 237) { + if (parent_11 && parent_11.kind === 239) { return parent_11.parent; } break; @@ -37568,16 +38033,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 171: - case 172: - case 211: - case 141: - case 140: + case 173: + case 174: + case 213: case 143: - case 144: + case 142: case 145: case 146: case 147: + case 148: + case 149: return true; } return false; @@ -37586,77 +38051,83 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 24: - return containingNodeKind === 209 || - containingNodeKind === 210 || - containingNodeKind === 191 || - containingNodeKind === 215 || - isFunction(containingNodeKind) || + return containingNodeKind === 211 || containingNodeKind === 212 || - containingNodeKind === 184 || - containingNodeKind === 213 || - containingNodeKind === 160 || - containingNodeKind === 214; + containingNodeKind === 193 || + containingNodeKind === 217 || + isFunction(containingNodeKind) || + containingNodeKind === 214 || + containingNodeKind === 186 || + containingNodeKind === 215 || + containingNodeKind === 162 || + containingNodeKind === 216; case 21: - return containingNodeKind === 160; - case 53: - return containingNodeKind === 161; + return containingNodeKind === 162; + case 54: + return containingNodeKind === 163; case 19: - return containingNodeKind === 160; + return containingNodeKind === 162; case 17: - return containingNodeKind === 242 || + return containingNodeKind === 244 || isFunction(containingNodeKind); case 15: - return containingNodeKind === 215 || - containingNodeKind === 213 || - containingNodeKind === 153; + return containingNodeKind === 217 || + containingNodeKind === 215 || + containingNodeKind === 155; case 23: - return containingNodeKind === 138 && + return containingNodeKind === 140 && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 213 || - contextToken.parent.parent.kind === 153); + (contextToken.parent.parent.kind === 215 || + contextToken.parent.parent.kind === 155); case 25: - return containingNodeKind === 212 || - containingNodeKind === 184 || - containingNodeKind === 213 || - containingNodeKind === 214 || + return containingNodeKind === 214 || + containingNodeKind === 186 || + containingNodeKind === 215 || + containingNodeKind === 216 || isFunction(containingNodeKind); - case 111: - return containingNodeKind === 139; + case 113: + return containingNodeKind === 141; case 22: - return containingNodeKind === 136 || + return containingNodeKind === 138 || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 160); + contextToken.parent.parent.kind === 162); + case 112: case 110: + case 111: + return containingNodeKind === 138; + case 116: + return containingNodeKind === 226 || + containingNodeKind === 230 || + containingNodeKind === 224; + case 73: + case 81: + case 107: + case 87: + case 102: + case 123: + case 129: + case 89: case 108: - case 109: - return containingNodeKind === 136; + case 74: case 114: - containingNodeKind === 224 || - containingNodeKind === 228 || - containingNodeKind === 222; - case 71: - case 79: - case 105: - case 85: - case 100: - case 121: - case 127: - case 87: - case 106: - case 72: - case 112: - case 130: + case 132: return true; } switch (contextToken.getText()) { + case "abstract": + case "async": case "class": - case "interface": + case "const": + case "declare": case "enum": case "function": - case "var": - case "static": + case "interface": case "let": - case "const": + case "private": + case "protected": + case "public": + case "static": + case "var": case "yield": return true; } @@ -37676,8 +38147,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_31 = element.propertyName || element.name; - exisingImportsOrExports[name_31.text] = true; + var name_32 = element.propertyName || element.name; + exisingImportsOrExports[name_32.text] = true; } if (ts.isEmpty(exisingImportsOrExports)) { return exportsOfModule; @@ -37691,16 +38162,16 @@ var ts; var existingMemberNames = {}; for (var _i = 0; _i < existingMembers.length; _i++) { var m = existingMembers[_i]; - if (m.kind !== 243 && - m.kind !== 244 && - m.kind !== 161) { + if (m.kind !== 245 && + m.kind !== 246 && + m.kind !== 163) { continue; } if (m.getStart() <= position && position <= m.getEnd()) { continue; } var existingName = void 0; - if (m.kind === 161 && m.propertyName) { + if (m.kind === 163 && m.propertyName) { existingName = m.propertyName.text; } else { @@ -37717,7 +38188,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 236) { + if (attr.kind === 238) { seenNames[attr.name.text] = true; } } @@ -37756,10 +38227,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_32 in nameTable) { - if (!allNames[name_32]) { - allNames[name_32] = name_32; - var displayName = getCompletionEntryDisplayName(name_32, target, true); + for (var name_33 in nameTable) { + if (!allNames[name_33]) { + allNames[name_33] = name_33; + var displayName = getCompletionEntryDisplayName(name_33, target, true); if (displayName) { var entry = { name: displayName, @@ -37850,7 +38321,7 @@ var ts; function getSymbolKind(symbol, location) { var flags = symbol.getFlags(); if (flags & 32) - return ts.getDeclarationOfKind(symbol, 184) ? + return ts.getDeclarationOfKind(symbol, 186) ? ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & 384) return ScriptElementKind.enumElement; @@ -37946,14 +38417,14 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 164) { + if (location.parent && location.parent.kind === 166) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } var callExpression; - if (location.kind === 166 || location.kind === 167) { + if (location.kind === 168 || location.kind === 169) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -37965,9 +38436,9 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 167 || callExpression.expression.kind === 93; + var useConstructSignatures = callExpression.kind === 169 || callExpression.expression.kind === 95; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); - if (!ts.contains(allSignatures, signature.target || signature)) { + if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; } if (signature) { @@ -37980,7 +38451,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(90)); + displayParts.push(ts.keywordPart(92)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -37995,10 +38466,10 @@ var ts; case ScriptElementKind.letElement: case ScriptElementKind.parameterElement: case ScriptElementKind.localVariableElement: - displayParts.push(ts.punctuationPart(53)); + displayParts.push(ts.punctuationPart(54)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(90)); + displayParts.push(ts.keywordPart(92)); displayParts.push(ts.spacePart()); } if (!(type.flags & 65536)) { @@ -38013,21 +38484,21 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 119 && location.parent.kind === 142)) { + (location.kind === 121 && location.parent.kind === 144)) { var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 142 ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 144 ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 142) { + if (functionDeclaration.kind === 144) { symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 145 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 147 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -38036,11 +38507,11 @@ var ts; } } if (symbolFlags & 32 && !hasAddedSymbolInfo) { - if (ts.getDeclarationOfKind(symbol, 184)) { + if (ts.getDeclarationOfKind(symbol, 186)) { pushTypePart(ScriptElementKind.localClassElement); } else { - displayParts.push(ts.keywordPart(71)); + displayParts.push(ts.keywordPart(73)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -38048,37 +38519,37 @@ var ts; } if ((symbolFlags & 64) && (semanticMeaning & 2)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(105)); + displayParts.push(ts.keywordPart(107)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(130)); + displayParts.push(ts.keywordPart(132)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55)); + displayParts.push(ts.operatorPart(56)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); } if (symbolFlags & 384) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(72)); + displayParts.push(ts.keywordPart(74)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(79)); + displayParts.push(ts.keywordPart(81)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 216); - var isNamespace = declaration && declaration.name && declaration.name.kind === 67; - displayParts.push(ts.keywordPart(isNamespace ? 124 : 123)); + var declaration = ts.getDeclarationOfKind(symbol, 218); + var isNamespace = declaration && declaration.name && declaration.name.kind === 69; + displayParts.push(ts.keywordPart(isNamespace ? 126 : 125)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -38090,7 +38561,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(88)); + displayParts.push(ts.keywordPart(90)); displayParts.push(ts.spacePart()); if (symbol.parent) { addFullSymbolName(symbol.parent, enclosingDeclaration); @@ -38099,20 +38570,20 @@ var ts; else { var container = ts.getContainingFunction(location); if (container) { - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135).parent; + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 137).parent; var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 146) { - displayParts.push(ts.keywordPart(90)); + if (signatureDeclaration.kind === 148) { + displayParts.push(ts.keywordPart(92)); displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 145 && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 147 && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); } else { - var declaration = ts.getDeclarationOfKind(symbol, 135).parent; - displayParts.push(ts.keywordPart(130)); + var declaration = ts.getDeclarationOfKind(symbol, 137).parent; + displayParts.push(ts.keywordPart(132)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -38122,11 +38593,11 @@ var ts; if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 245) { + if (declaration.kind === 247) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55)); + displayParts.push(ts.operatorPart(56)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); } @@ -38134,17 +38605,17 @@ var ts; } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(87)); + displayParts.push(ts.keywordPart(89)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 219) { + if (declaration.kind === 221) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55)); + displayParts.push(ts.operatorPart(56)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(125)); + displayParts.push(ts.keywordPart(127)); displayParts.push(ts.punctuationPart(17)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(18)); @@ -38153,7 +38624,7 @@ var ts; var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55)); + displayParts.push(ts.operatorPart(56)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -38169,7 +38640,7 @@ var ts; if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & 3 || symbolKind === ScriptElementKind.localVariableElement) { - displayParts.push(ts.punctuationPart(53)); + displayParts.push(ts.punctuationPart(54)); displayParts.push(ts.spacePart()); if (type.symbol && type.symbol.flags & 262144) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { @@ -38267,11 +38738,11 @@ var ts; var symbol = typeChecker.getSymbolAtLocation(node); if (!symbol) { switch (node.kind) { - case 67: - case 164: - case 133: + case 69: + case 166: + case 135: + case 97: case 95: - case 93: var type = typeChecker.getTypeAtLocation(node); if (type) { return { @@ -38320,7 +38791,7 @@ var ts; } return result; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { - if (isNewExpressionTarget(location) || location.kind === 119) { + if (isNewExpressionTarget(location) || location.kind === 121) { if (symbol.flags & 32) { for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { var declaration = _a[_i]; @@ -38343,8 +38814,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 142) || - (!selectConstructors && (d.kind === 211 || d.kind === 141 || d.kind === 140))) { + if ((selectConstructors && d.kind === 144) || + (!selectConstructors && (d.kind === 213 || d.kind === 143 || d.kind === 142))) { declarations.push(d); if (d.body) definition = d; @@ -38395,11 +38866,11 @@ var ts; } if (symbol.flags & 8388608) { var declaration = symbol.declarations[0]; - if (node.kind === 67 && node.parent === declaration) { + if (node.kind === 69 && node.parent === declaration) { symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 244) { + if (node.parent.kind === 246) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -38470,9 +38941,9 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 67 || + if (node.kind === 69 || + node.kind === 97 || node.kind === 95 || - node.kind === 93 || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, false, false); @@ -38521,77 +38992,77 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 86: - case 78: - if (hasKind(node.parent, 194)) { + case 88: + case 80: + if (hasKind(node.parent, 196)) { return getIfElseOccurrences(node.parent); } break; - case 92: - if (hasKind(node.parent, 202)) { + case 94: + if (hasKind(node.parent, 204)) { return getReturnOccurrences(node.parent); } break; - case 96: - if (hasKind(node.parent, 206)) { + case 98: + if (hasKind(node.parent, 208)) { return getThrowOccurrences(node.parent); } break; - case 70: - if (hasKind(parent(parent(node)), 207)) { + case 72: + if (hasKind(parent(parent(node)), 209)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 98: - case 83: - if (hasKind(parent(node), 207)) { + case 100: + case 85: + if (hasKind(parent(node), 209)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 94: - if (hasKind(node.parent, 204)) { + case 96: + if (hasKind(node.parent, 206)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 69: - case 75: - if (hasKind(parent(parent(parent(node))), 204)) { + case 71: + case 77: + if (hasKind(parent(parent(parent(node))), 206)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 68: - case 73: - if (hasKind(node.parent, 201) || hasKind(node.parent, 200)) { + case 70: + case 75: + if (hasKind(node.parent, 203) || hasKind(node.parent, 202)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; - case 84: - if (hasKind(node.parent, 197) || - hasKind(node.parent, 198) || - hasKind(node.parent, 199)) { + case 86: + if (hasKind(node.parent, 199) || + hasKind(node.parent, 200) || + hasKind(node.parent, 201)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 102: - case 77: - if (hasKind(node.parent, 196) || hasKind(node.parent, 195)) { + case 104: + case 79: + if (hasKind(node.parent, 198) || hasKind(node.parent, 197)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 119: - if (hasKind(node.parent, 142)) { + case 121: + if (hasKind(node.parent, 144)) { return getConstructorOccurrences(node.parent); } break; - case 121: - case 127: - if (hasKind(node.parent, 143) || hasKind(node.parent, 144)) { + case 123: + case 129: + if (hasKind(node.parent, 145) || hasKind(node.parent, 146)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 191)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 193)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -38603,10 +39074,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 206) { + if (node.kind === 208) { statementAccumulator.push(node); } - else if (node.kind === 207) { + else if (node.kind === 209) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -38628,10 +39099,10 @@ var ts; var child = throwStatement; while (child.parent) { var parent_12 = child.parent; - if (ts.isFunctionBlock(parent_12) || parent_12.kind === 246) { + if (ts.isFunctionBlock(parent_12) || parent_12.kind === 248) { return parent_12; } - if (parent_12.kind === 207) { + if (parent_12.kind === 209) { var tryStatement = parent_12; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; @@ -38646,7 +39117,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 201 || node.kind === 200) { + if (node.kind === 203 || node.kind === 202) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -38662,15 +39133,15 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { switch (node_2.kind) { - case 204: - if (statement.kind === 200) { + case 206: + if (statement.kind === 202) { continue; } - case 197: - case 198: case 199: - case 196: - case 195: + case 200: + case 201: + case 198: + case 197: if (!statement.label || isLabeledBy(node_2, statement.label.text)) { return node_2; } @@ -38687,24 +39158,24 @@ var ts; function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 212 || - container.kind === 184 || - (declaration.kind === 136 && hasKind(container, 142)))) { + if (!(container.kind === 214 || + container.kind === 186 || + (declaration.kind === 138 && hasKind(container, 144)))) { return undefined; } } - else if (modifier === 111) { - if (!(container.kind === 212 || container.kind === 184)) { + else if (modifier === 113) { + if (!(container.kind === 214 || container.kind === 186)) { return undefined; } } - else if (modifier === 80 || modifier === 120) { - if (!(container.kind === 217 || container.kind === 246)) { + else if (modifier === 82 || modifier === 122) { + if (!(container.kind === 219 || container.kind === 248)) { return undefined; } } - else if (modifier === 113) { - if (!(container.kind === 212 || declaration.kind === 212)) { + else if (modifier === 115) { + if (!(container.kind === 214 || declaration.kind === 214)) { return undefined; } } @@ -38715,8 +39186,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 217: - case 246: + case 219: + case 248: if (modifierFlag & 256) { nodes = declaration.members.concat(declaration); } @@ -38724,15 +39195,15 @@ var ts; nodes = container.statements; } break; - case 142: + case 144: nodes = container.parameters.concat(container.parent.members); break; - case 212: - case 184: + case 214: + case 186: nodes = container.members; if (modifierFlag & 112) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 142 && member; + return member.kind === 144 && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -38753,19 +39224,19 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 110: + case 112: return 16; - case 108: + case 110: return 32; - case 109: - return 64; case 111: + return 64; + case 113: return 128; - case 80: + case 82: return 1; - case 120: + case 122: return 2; - case 113: + case 115: return 256; default: ts.Debug.fail(); @@ -38785,13 +39256,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 143); - tryPushAccessorKeyword(accessorDeclaration.symbol, 144); + tryPushAccessorKeyword(accessorDeclaration.symbol, 145); + tryPushAccessorKeyword(accessorDeclaration.symbol, 146); 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, 121, 127); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 123, 129); }); } } } @@ -38800,18 +39271,18 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 119); + return pushKeywordIf(keywords, token, 121); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 84, 102, 77)) { - if (loopNode.kind === 195) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86, 104, 79)) { + if (loopNode.kind === 197) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 102)) { + if (pushKeywordIf(keywords, loopTokens[i], 104)) { break; } } @@ -38820,7 +39291,7 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 68, 73); + pushKeywordIf(keywords, statement.getFirstToken(), 70, 75); } }); return ts.map(keywords, getHighlightSpanForNode); @@ -38829,13 +39300,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { + case 199: + case 200: + case 201: case 197: case 198: - case 199: - case 195: - case 196: return getLoopBreakContinueOccurrences(owner); - case 204: + case 206: return getSwitchCaseDefaultOccurrences(owner); } } @@ -38843,13 +39314,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 94); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 96); ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 69, 75); + pushKeywordIf(keywords, clause.getFirstToken(), 71, 77); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 68); + pushKeywordIf(keywords, statement.getFirstToken(), 70); } }); }); @@ -38857,13 +39328,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 98); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 100); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 70); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 72); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 83, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 83); + var finallyKeyword = ts.findChildOfKind(tryStatement, 85, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 85); } return ts.map(keywords, getHighlightSpanForNode); } @@ -38874,50 +39345,50 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 96); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 98); }); if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 92); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 94); }); } return ts.map(keywords, getHighlightSpanForNode); } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 190))) { + if (!(func && hasKind(func.body, 192))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 92); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 94); }); ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 96); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 98); }); return ts.map(keywords, getHighlightSpanForNode); } function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 194) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 196) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 86); + pushKeywordIf(keywords, children[0], 88); for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 78)) { + if (pushKeywordIf(keywords, children[i], 80)) { break; } } - if (!hasKind(ifStatement.elseStatement, 194)) { + if (!hasKind(ifStatement.elseStatement, 196)) { break; } ifStatement = ifStatement.elseStatement; } var result = []; for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 78 && i < keywords.length - 1) { + if (keywords[i].kind === 80 && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; var shouldCombindElseAndIf = true; @@ -38995,12 +39466,12 @@ var ts; if (!node) { return undefined; } - if (node.kind !== 67 && + if (node.kind !== 69 && !isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && !isNameOfExternalModuleImportOrDeclaration(node)) { return undefined; } - ts.Debug.assert(node.kind === 67 || node.kind === 8 || node.kind === 9); + ts.Debug.assert(node.kind === 69 || node.kind === 8 || node.kind === 9); return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { @@ -39014,10 +39485,10 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 95) { + if (node.kind === 97) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 93) { + if (node.kind === 95) { return getReferencesForSuperKeyword(node); } var symbol = typeChecker.getSymbolAtLocation(node); @@ -39068,7 +39539,7 @@ var ts; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 224 || declaration.kind === 228; + return declaration.kind === 226 || declaration.kind === 230; }); } function getInternedName(symbol, location, declarations) { @@ -39081,13 +39552,13 @@ var ts; } function getSymbolScope(symbol) { var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 171 || valueDeclaration.kind === 184)) { + if (valueDeclaration && (valueDeclaration.kind === 173 || valueDeclaration.kind === 186)) { return valueDeclaration; } 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, 212); + return ts.getAncestor(privateDeclaration, 214); } } if (symbol.flags & 8388608) { @@ -39108,7 +39579,7 @@ var ts; if (scope && scope !== container) { return undefined; } - if (container.kind === 246 && !ts.isExternalModule(container)) { + if (container.kind === 248 && !ts.isExternalModule(container)) { return undefined; } scope = container; @@ -39167,7 +39638,7 @@ var ts; function isValidReferencePosition(node, searchSymbolName) { if (node) { switch (node.kind) { - case 67: + case 69: return node.getWidth() === searchSymbolName.length; case 9: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || @@ -39255,13 +39726,13 @@ var ts; } var staticFlag = 128; switch (searchSpaceNode.kind) { - case 139: - case 138: case 141: case 140: - case 142: case 143: + case 142: case 144: + case 145: + case 146: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; @@ -39274,7 +39745,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 93) { + if (!node || node.kind !== 95) { return; } var container = ts.getSuperContainer(node, false); @@ -39289,32 +39760,32 @@ var ts; var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); var staticFlag = 128; switch (searchSpaceNode.kind) { - case 141: - case 140: + case 143: + case 142: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } - case 139: - case 138: - case 142: - case 143: + case 141: + case 140: case 144: + case 145: + case 146: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; - case 246: + case 248: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 211: - case 171: + case 213: + case 173: break; default: return undefined; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 246) { + if (searchSpaceNode.kind === 248) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -39340,30 +39811,31 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 95) { + if (!node || node.kind !== 97) { return; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 171: - case 211: + case 173: + case 213: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 141: - case 140: + case 143: + case 142: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 212: + case 186: + case 214: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 246: - if (container.kind === 246 && !ts.isExternalModule(container)) { + case 248: + if (container.kind === 248 && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -39398,11 +39870,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 | 64)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 212) { + if (declaration.kind === 214) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 213) { + else if (declaration.kind === 215) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -39452,17 +39924,17 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_33 = node.text; + var name_34 = node.text; if (contextualType) { if (contextualType.flags & 16384) { - var unionProperty = contextualType.getProperty(name_33); + var unionProperty = contextualType.getProperty(name_34); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_33); + var symbol = t.getProperty(name_34); if (symbol) { result_4.push(symbol); } @@ -39471,7 +39943,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_33); + var symbol_1 = contextualType.getProperty(name_34); if (symbol_1) { return [symbol_1]; } @@ -39511,17 +39983,17 @@ var ts; }; } function isWriteAccess(node) { - if (node.kind === 67 && ts.isDeclarationName(node)) { + if (node.kind === 69 && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 178 || parent.kind === 177) { + if (parent.kind === 180 || parent.kind === 179) { return true; } - else if (parent.kind === 179 && parent.left === node) { + else if (parent.kind === 181 && parent.left === node) { var operator = parent.operatorToken.kind; - return 55 <= operator && operator <= 66; + return 56 <= operator && operator <= 68; } } return false; @@ -39552,33 +40024,33 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 136: - case 209: - case 161: - case 139: case 138: - case 243: - case 244: - case 245: + case 211: + case 163: case 141: case 140: - case 142: + case 245: + case 246: + case 247: case 143: + case 142: case 144: - case 211: - case 171: - case 172: - case 242: - return 1; - case 135: + case 145: + case 146: case 213: - case 214: - case 153: - return 2; - case 212: + case 173: + case 174: + case 244: + return 1; + case 137: case 215: - return 1 | 2; case 216: + case 155: + return 2; + case 214: + case 217: + return 1 | 2; + case 218: if (node.name.kind === 9) { return 4 | 1; } @@ -39588,14 +40060,14 @@ var ts; else { return 4; } - case 223: - case 224: - case 219: - case 220: case 225: case 226: + case 221: + case 222: + case 227: + case 228: return 1 | 2 | 4; - case 246: + case 248: return 4 | 1; } return 1 | 2 | 4; @@ -39605,8 +40077,9 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 149 || - (node.parent.kind === 186 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); + return node.parent.kind === 151 || + (node.parent.kind === 188 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + node.kind === 97 && !ts.isExpression(node); } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -39614,47 +40087,47 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 164) { - while (root.parent && root.parent.kind === 164) { + if (root.parent.kind === 166) { + while (root.parent && root.parent.kind === 166) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 186 && root.parent.parent.kind === 241) { + if (!isLastClause && root.parent.kind === 188 && root.parent.parent.kind === 243) { var decl = root.parent.parent.parent; - return (decl.kind === 212 && root.parent.parent.token === 104) || - (decl.kind === 213 && root.parent.parent.token === 81); + return (decl.kind === 214 && root.parent.parent.token === 106) || + (decl.kind === 215 && root.parent.parent.token === 83); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 133) { - while (root.parent && root.parent.kind === 133) { + if (root.parent.kind === 135) { + while (root.parent && root.parent.kind === 135) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 149 && !isLastClause; + return root.parent.kind === 151 && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 133) { + while (node.parent.kind === 135) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 67); - if (node.parent.kind === 133 && + ts.Debug.assert(node.kind === 69); + if (node.parent.kind === 135 && node.parent.right === node && - node.parent.parent.kind === 219) { + node.parent.parent.kind === 221) { return 1 | 2 | 4; } return 4; } function getMeaningFromLocation(node) { - if (node.parent.kind === 225) { + if (node.parent.kind === 227) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -39688,15 +40161,15 @@ var ts; return; } switch (node.kind) { - case 164: - case 133: + case 166: + case 135: case 9: - case 82: - case 97: - case 91: + case 84: + case 99: case 93: case 95: - case 67: + case 97: + case 69: break; default: return; @@ -39707,7 +40180,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 216 && + if (nodeForStartPos.parent.parent.kind === 218 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -39734,10 +40207,10 @@ var ts; } function checkForClassificationCancellation(kind) { switch (kind) { - case 216: - case 212: + case 218: + case 214: + case 215: case 213: - case 211: cancellationToken.throwIfCancellationRequested(); } } @@ -39785,7 +40258,7 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 216 && + return declaration.kind === 218 && ts.getModuleInstanceState(declaration) === 1; }); } @@ -39794,7 +40267,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(kind); - if (kind === 67 && !ts.nodeIsMissing(node)) { + if (kind === 69 && !ts.nodeIsMissing(node)) { var identifier = node; if (classifiableNames[identifier.text]) { var symbol = typeChecker.getSymbolAtLocation(node); @@ -39918,16 +40391,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 265: + case 267: processJSDocParameterTag(tag); break; - case 268: + case 270: processJSDocTemplateTag(tag); break; - case 267: + case 269: processElement(tag.typeExpression); break; - case 266: + case 268: processElement(tag.typeExpression); break; } @@ -40007,17 +40480,17 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 55) { - if (token.parent.kind === 209 || - token.parent.kind === 139 || - token.parent.kind === 136) { + if (tokenKind === 56) { + if (token.parent.kind === 211 || + token.parent.kind === 141 || + token.parent.kind === 138) { return 5; } } - if (token.parent.kind === 179 || - token.parent.kind === 177 || - token.parent.kind === 178 || - token.parent.kind === 180) { + if (token.parent.kind === 181 || + token.parent.kind === 179 || + token.parent.kind === 180 || + token.parent.kind === 182) { return 5; } } @@ -40035,35 +40508,35 @@ var ts; else if (ts.isTemplateLiteralKind(tokenKind)) { return 6; } - else if (tokenKind === 67) { + else if (tokenKind === 69) { if (token) { switch (token.parent.kind) { - case 212: + case 214: if (token.parent.name === token) { return 11; } return; - case 135: + case 137: if (token.parent.name === token) { return 15; } return; - case 213: + case 215: if (token.parent.name === token) { return 13; } return; - case 215: + case 217: if (token.parent.name === token) { return 12; } return; - case 216: + case 218: if (token.parent.name === token) { return 14; } return; - case 136: + case 138: if (token.parent.name === token) { return 17; } @@ -40177,19 +40650,40 @@ var ts; if (!tokenAtPos || tokenStart < position) { return undefined; } - var containingFunction = ts.getAncestor(tokenAtPos, 211); - if (!containingFunction || containingFunction.getStart() < position) { + var commentOwner; + findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { + switch (commentOwner.kind) { + case 213: + case 143: + case 144: + case 214: + case 193: + break findOwner; + case 248: + return undefined; + case 218: + if (commentOwner.parent.kind === 218) { + return undefined; + } + break findOwner; + } + } + if (!commentOwner || commentOwner.getStart() < position) { return undefined; } - var parameters = containingFunction.parameters; + var parameters = getParametersForJsDocOwningNode(commentOwner); var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); var newLine = host.getNewLine ? host.getNewLine() : "\r\n"; - var docParams = parameters.reduce(function (prev, cur, index) { - return prev + - indentationStr + " * @param " + (cur.name.kind === 67 ? cur.name.text : "param" + index) + newLine; - }, ""); + var docParams = ""; + for (var i = 0, numParams = parameters.length; i < numParams; i++) { + var currentName = parameters[i].name; + var paramName = currentName.kind === 69 ? + currentName.text : + "param" + i; + docParams += indentationStr + " * @param " + paramName + newLine; + } var preamble = "/**" + newLine + indentationStr + " * "; var result = preamble + newLine + @@ -40198,6 +40692,38 @@ var ts; (tokenStart === position ? newLine + indentationStr : ""); return { newText: result, caretOffset: preamble.length }; } + function getParametersForJsDocOwningNode(commentOwner) { + if (ts.isFunctionLike(commentOwner)) { + return commentOwner.parameters; + } + if (commentOwner.kind === 193) { + var varStatement = commentOwner; + var varDeclarations = varStatement.declarationList.declarations; + if (varDeclarations.length === 1 && varDeclarations[0].initializer) { + return getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer); + } + } + return emptyArray; + } + function getParametersFromRightHandSideOfAssignment(rightHandSide) { + while (rightHandSide.kind === 172) { + rightHandSide = rightHandSide.expression; + } + switch (rightHandSide.kind) { + case 173: + case 174: + return rightHandSide.parameters; + case 186: + for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.kind === 144) { + return member.parameters; + } + } + break; + } + return emptyArray; + } function getTodoComments(fileName, descriptors) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); @@ -40240,8 +40766,6 @@ var ts; return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); } function getTodoCommentsRegExp() { - // NOTE: ?: means 'non-capture group'. It allows us to have groups without having to - // filter them out later in the final result array. var singleLineCommentStart = /(?:\/\/+\s*)/.source; var multiLineCommentStart = /(?:\/\*+\s*)/.source; var anyNumberOfSpacesAndAsterixesAtStartOfLine = /(?:^(?:\s|\*)*)/.source; @@ -40264,7 +40788,7 @@ var ts; var sourceFile = getValidSourceFile(fileName); var typeChecker = program.getTypeChecker(); var node = ts.getTouchingWord(sourceFile, position); - if (node && node.kind === 67) { + if (node && node.kind === 69) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { var declarations = symbol.getDeclarations(); @@ -40362,13 +40886,13 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 67: + case 69: nameTable[node.text] = node.text; break; case 9: case 8: if (ts.isDeclarationName(node) || - node.parent.kind === 230 || + node.parent.kind === 232 || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -40381,31 +40905,31 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 165 && + node.parent.kind === 167 && node.parent.argumentExpression === node; } function createClassifier() { var scanner = ts.createScanner(2, false); var noRegexTable = []; - noRegexTable[67] = true; + noRegexTable[69] = true; noRegexTable[9] = true; noRegexTable[8] = true; noRegexTable[10] = true; - noRegexTable[95] = true; - noRegexTable[40] = true; + noRegexTable[97] = true; noRegexTable[41] = true; + noRegexTable[42] = true; noRegexTable[18] = true; noRegexTable[20] = true; noRegexTable[16] = true; - noRegexTable[97] = true; - noRegexTable[82] = true; + noRegexTable[99] = true; + noRegexTable[84] = true; var templateStack = []; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 121 || - keyword2 === 127 || - keyword2 === 119 || - keyword2 === 111) { + if (keyword2 === 123 || + keyword2 === 129 || + keyword2 === 121 || + keyword2 === 113) { return true; } return false; @@ -40500,31 +41024,31 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 38 || token === 59) && !noRegexTable[lastNonTriviaToken]) { + if ((token === 39 || token === 61) && !noRegexTable[lastNonTriviaToken]) { if (scanner.reScanSlashToken() === 10) { token = 10; } } else if (lastNonTriviaToken === 21 && isKeyword(token)) { - token = 67; + token = 69; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - token = 67; + token = 69; } - else if (lastNonTriviaToken === 67 && + else if (lastNonTriviaToken === 69 && token === 25) { angleBracketStack++; } else if (token === 27 && angleBracketStack > 0) { angleBracketStack--; } - else if (token === 115 || + else if (token === 117 || + token === 130 || token === 128 || - token === 126 || - token === 118 || - token === 129) { + token === 120 || + token === 131) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - token = 67; + token = 69; } } else if (token === 12) { @@ -40622,40 +41146,41 @@ var ts; function isBinaryExpressionOperatorToken(token) { switch (token) { case 37: - case 38: case 39: + case 40: case 35: case 36: - case 42: case 43: case 44: + case 45: case 25: case 27: case 28: case 29: - case 89: - case 88: + case 91: + case 90: + case 116: case 30: case 31: case 32: case 33: - case 45: - case 47: case 46: - case 50: + case 48: + case 47: case 51: - case 65: - case 64: + case 52: + case 67: case 66: - case 61: - case 62: + case 68: case 63: - case 56: + case 64: + case 65: case 57: case 58: case 59: - case 60: - case 55: + case 61: + case 62: + case 56: case 24: return true; default: @@ -40666,17 +41191,17 @@ var ts; switch (token) { case 35: case 36: + case 50: case 49: - case 48: - case 40: case 41: + case 42: return true; default: return false; } } function isKeyword(token) { - return token >= 68 && token <= 132; + return token >= 70 && token <= 134; } function classFromKind(token) { if (isKeyword(token)) { @@ -40685,7 +41210,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5; } - else if (token >= 15 && token <= 66) { + else if (token >= 15 && token <= 68) { return 10; } switch (token) { @@ -40702,7 +41227,7 @@ var ts; case 5: case 4: return 8; - case 67: + case 69: default: if (ts.isTemplateLiteralKind(token)) { return 6; @@ -40728,7 +41253,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 246 ? new SourceFileObject() : new NodeObject(); + var proto = kind === 248 ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = -1; proto.end = -1; @@ -40744,10 +41269,6 @@ var ts; } initializeServices(); })(ts || (ts = {})); -/// -/// -/// -/// var ts; (function (ts) { var server; @@ -40764,6 +41285,22 @@ var ts; return spaceCache[n]; } server.generateSpaces = generateSpaces; + function generateIndentString(n, editorOptions) { + if (editorOptions.ConvertTabsToSpaces) { + return generateSpaces(n); + } + else { + var result = ""; + for (var i = 0; i < Math.floor(n / editorOptions.TabSize); i++) { + result += "\t"; + } + for (var i = 0; i < n % editorOptions.TabSize; i++) { + result += " "; + } + return result; + } + } + server.generateIndentString = generateIndentString; function compareNumber(a, b) { if (a < b) { return -1; @@ -41375,28 +41912,27 @@ var ts; IndentSize: formatOptions.IndentSize, TabSize: formatOptions.TabSize, NewLineCharacter: "\n", - ConvertTabsToSpaces: formatOptions.ConvertTabsToSpaces + ConvertTabsToSpaces: formatOptions.ConvertTabsToSpaces, + IndentStyle: ts.IndentStyle.Smart }; - var indentPosition = compilerService.languageService.getIndentationAtPosition(file, position, editorOptions); + var preferredIndent = compilerService.languageService.getIndentationAtPosition(file, position, editorOptions); + var hasIndent = 0; for (var i = 0, len = lineText.length; i < len; i++) { if (lineText.charAt(i) == " ") { - indentPosition--; + hasIndent++; } else if (lineText.charAt(i) == "\t") { - indentPosition -= editorOptions.IndentSize; + hasIndent += editorOptions.TabSize; } else { break; } } - if (indentPosition > 0) { - var spaces = generateSpaces(indentPosition); - edits.push({ span: ts.createTextSpanFromBounds(position, position), newText: spaces }); - } - else if (indentPosition < 0) { + if (preferredIndent !== hasIndent) { + var firstNoWhiteSpacePosition = lineInfo.offset + i; edits.push({ - span: ts.createTextSpanFromBounds(position, position - indentPosition), - newText: "" + span: ts.createTextSpanFromBounds(lineInfo.offset, firstNoWhiteSpacePosition), + newText: generateIndentString(preferredIndent, editorOptions) }); } } @@ -41528,6 +42064,9 @@ var ts; } }; Session.prototype.closeClientFile = function (fileName) { + if (!fileName) { + return; + } var file = ts.normalizePath(fileName); this.projectService.closeClientFile(file); }; @@ -41710,10 +42249,6 @@ var ts; server.Session = Session; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); -/// -/// -/// -/// var ts; (function (ts) { var server; @@ -41888,6 +42423,7 @@ var ts; if (scriptInfo) { this.filenameToScript[info.fileName] = undefined; this.roots = copyListRemovingItem(info, this.roots); + this.resolvedModuleNames.remove(info.fileName); } }; LSHost.prototype.saveTo = function (filename, tmpfilename) { @@ -41981,6 +42517,7 @@ var ts; function Project(projectService, projectOptions) { this.projectService = projectService; this.projectOptions = projectOptions; + this.directoriesWatchedForTsconfig = []; this.filenameToSourceFile = {}; this.updateGraphSeq = 0; this.openRefCount = 0; @@ -41996,6 +42533,9 @@ var ts; Project.prototype.openReferencedFile = function (filename) { return this.projectService.openFile(filename, false); }; + Project.prototype.getRootFiles = function () { + return this.compilerService.host.roots.map(function (info) { return info.fileName; }); + }; Project.prototype.getFileNames = function () { var sourceFiles = this.program.getSourceFiles(); return sourceFiles.map(function (sourceFile) { return sourceFile.fileName; }); @@ -42038,11 +42578,9 @@ var ts; return this.projectFilename; }; Project.prototype.addRoot = function (info) { - info.defaultProject = this; this.compilerService.host.addRoot(info); }; Project.prototype.removeRoot = function (info) { - info.defaultProject = undefined; this.compilerService.host.removeRoot(info); }; Project.prototype.filesToString = function () { @@ -42079,6 +42617,9 @@ var ts; this.configuredProjects = []; this.openFilesReferenced = []; this.openFileRootsConfigured = []; + this.directoryWatchersForTsconfig = {}; + this.directoryWatchersRefCount = {}; + this.timerForDetectingProjectFilelistChanges = {}; this.addDefaultHostConfiguration(); } ProjectService.prototype.addDefaultHostConfiguration = function () { @@ -42110,8 +42651,54 @@ var ts; } } }; + ProjectService.prototype.directoryWatchedForSourceFilesChanged = function (project, fileName) { + if (fileName && !ts.isSupportedSourceFileName(fileName)) { + return; + } + this.log("Detected source file changes: " + fileName); + this.startTimerForDetectingProjectFilelistChanges(project); + }; + ProjectService.prototype.startTimerForDetectingProjectFilelistChanges = function (project) { + var _this = this; + if (this.timerForDetectingProjectFilelistChanges[project.projectFilename]) { + clearTimeout(this.timerForDetectingProjectFilelistChanges[project.projectFilename]); + } + this.timerForDetectingProjectFilelistChanges[project.projectFilename] = setTimeout(function () { return _this.handleProjectFilelistChanges(project); }, 250); + }; + ProjectService.prototype.handleProjectFilelistChanges = function (project) { + var _this = this; + var _a = this.configFileToProjectOptions(project.projectFilename), succeeded = _a.succeeded, projectOptions = _a.projectOptions, error = _a.error; + var newRootFiles = projectOptions.files.map((function (f) { return _this.getCanonicalFileName(f); })); + var currentRootFiles = project.getRootFiles().map((function (f) { return _this.getCanonicalFileName(f); })); + if (!ts.arrayIsEqualTo(currentRootFiles && currentRootFiles.sort(), newRootFiles && newRootFiles.sort())) { + this.updateConfiguredProject(project); + this.updateProjectStructure(); + } + }; + ProjectService.prototype.directoryWatchedForTsconfigChanged = function (fileName) { + var _this = this; + if (ts.getBaseFileName(fileName) != "tsconfig.json") { + this.log(fileName + " is not tsconfig.json"); + return; + } + this.log("Detected newly added tsconfig file: " + fileName); + var _a = this.configFileToProjectOptions(fileName), succeeded = _a.succeeded, projectOptions = _a.projectOptions, error = _a.error; + var rootFilesInTsconfig = projectOptions.files.map(function (f) { return _this.getCanonicalFileName(f); }); + var openFileRoots = this.openFileRoots.map(function (s) { return _this.getCanonicalFileName(s.fileName); }); + for (var _i = 0; _i < openFileRoots.length; _i++) { + var openFileRoot = openFileRoots[_i]; + if (rootFilesInTsconfig.indexOf(openFileRoot) >= 0) { + this.reloadProjects(); + return; + } + } + }; + ProjectService.prototype.getCanonicalFileName = function (fileName) { + var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + return ts.normalizePath(name); + }; ProjectService.prototype.watchedProjectConfigFileChanged = function (project) { - this.log("Config File Changed: " + project.projectFilename); + this.log("Config file changed: " + project.projectFilename); this.updateConfiguredProject(project); this.updateProjectStructure(); }; @@ -42142,11 +42729,28 @@ var ts; this.psLogger.close(); }; ProjectService.prototype.createInferredProject = function (root) { - var iproj = new Project(this); - iproj.addRoot(root); - iproj.finishGraph(); - this.inferredProjects.push(iproj); - return iproj; + var _this = this; + var project = new Project(this); + project.addRoot(root); + var currentPath = ts.getDirectoryPath(root.fileName); + var parentPath = ts.getDirectoryPath(currentPath); + while (currentPath != parentPath) { + if (!project.projectService.directoryWatchersForTsconfig[currentPath]) { + this.log("Add watcher for: " + currentPath); + project.projectService.directoryWatchersForTsconfig[currentPath] = + this.host.watchDirectory(currentPath, function (fileName) { return _this.directoryWatchedForTsconfigChanged(fileName); }); + project.projectService.directoryWatchersRefCount[currentPath] = 1; + } + else { + project.projectService.directoryWatchersRefCount[currentPath] += 1; + } + project.directoriesWatchedForTsconfig.push(currentPath); + currentPath = parentPath; + parentPath = ts.getDirectoryPath(parentPath); + } + project.finishGraph(); + this.inferredProjects.push(project); + return project; }; ProjectService.prototype.fileDeletedInFilesystem = function (info) { this.psLogger.info(info.fileName + " deleted"); @@ -42157,6 +42761,9 @@ var ts; if (!info.isOpen) { this.filenameToScriptInfo[info.fileName] = undefined; var referencingProjects = this.findReferencingProjects(info); + if (info.defaultProject) { + info.defaultProject.removeRoot(info); + } for (var i = 0, len = referencingProjects.length; i < len; i++) { referencingProjects[i].removeReferencedFile(info); } @@ -42184,12 +42791,27 @@ var ts; } this.configuredProjects = configuredProjects; }; - ProjectService.prototype.removeConfiguredProject = function (project) { - project.projectFileWatcher.close(); - this.configuredProjects = copyListRemovingItem(project, this.configuredProjects); + ProjectService.prototype.removeProject = function (project) { + this.log("remove project: " + project.getRootFiles().toString()); + if (project.isConfiguredProject()) { + project.projectFileWatcher.close(); + project.directoryWatcher.close(); + this.configuredProjects = copyListRemovingItem(project, this.configuredProjects); + } + else { + for (var _i = 0, _a = project.directoriesWatchedForTsconfig; _i < _a.length; _i++) { + var directory = _a[_i]; + if (!(--project.projectService.directoryWatchersRefCount[directory])) { + this.log("Close directory watcher for: " + directory); + project.projectService.directoryWatchersForTsconfig[directory].close(); + delete project.projectService.directoryWatchersForTsconfig[directory]; + } + } + this.inferredProjects = copyListRemovingItem(project, this.inferredProjects); + } var fileNames = project.getFileNames(); - for (var _i = 0; _i < fileNames.length; _i++) { - var fileName = fileNames[_i]; + for (var _b = 0; _b < fileNames.length; _b++) { + var fileName = fileNames[_b]; var info = this.getScriptInfo(fileName); if (info.defaultProject == project) { info.defaultProject = undefined; @@ -42222,8 +42844,7 @@ var ts; for (var i = 0, len = this.openFileRoots.length; i < len; i++) { var r = this.openFileRoots[i]; if (info.defaultProject.getSourceFile(r)) { - this.inferredProjects = - copyListRemovingItem(r.defaultProject, this.inferredProjects); + this.removeProject(r.defaultProject); this.openFilesReferenced.push(r); r.defaultProject = info.defaultProject; } @@ -42238,6 +42859,7 @@ var ts; this.updateConfiguredProjectList(); }; ProjectService.prototype.closeOpenFile = function (info) { + info.svc.reloadFromFile(info.fileName); var openFileRoots = []; var removedProject; for (var i = 0, len = this.openFileRoots.length; i < len; i++) { @@ -42264,17 +42886,12 @@ var ts; this.openFileRootsConfigured = openFileRootsConfigured; } if (removedProject) { - if (removedProject.isConfiguredProject()) { - this.configuredProjects = copyListRemovingItem(removedProject, this.configuredProjects); - } - else { - this.inferredProjects = copyListRemovingItem(removedProject, this.inferredProjects); - } + this.removeProject(removedProject); var openFilesReferenced = []; 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) { f.defaultProject = undefined; orphanFiles.push(f); } @@ -42315,6 +42932,7 @@ var ts; return referencingProjects; }; ProjectService.prototype.reloadProjects = function () { + this.log("reload projects."); for (var _i = 0, _a = this.openFileRoots; _i < _a.length; _i++) { var info = _a[_i]; this.openOrUpdateConfiguredProjectForFile(info.fileName); @@ -42356,13 +42974,21 @@ var ts; var rootFile = this.openFileRoots[i]; var rootedProject = rootFile.defaultProject; var referencingProjects = this.findReferencingProjects(rootFile, rootedProject); - if (referencingProjects.length === 0) { - rootFile.defaultProject = rootedProject; - openFileRoots.push(rootFile); + if (rootFile.defaultProject && rootFile.defaultProject.isConfiguredProject()) { + if (!rootedProject.isConfiguredProject()) { + this.removeProject(rootedProject); + } + this.openFileRootsConfigured.push(rootFile); } else { - this.inferredProjects = copyListRemovingItem(rootedProject, this.inferredProjects); - this.openFilesReferenced.push(rootFile); + if (referencingProjects.length === 0) { + rootFile.defaultProject = rootedProject; + openFileRoots.push(rootFile); + } + else { + this.removeProject(rootedProject); + this.openFilesReferenced.push(rootFile); + } } } this.openFileRoots = openFileRoots; @@ -42533,12 +43159,12 @@ var ts; configFilename = ts.normalizePath(configFilename); var dirPath = ts.getDirectoryPath(configFilename); var contents = this.host.readFile(configFilename); - var rawConfig = ts.parseConfigFileText(configFilename, contents); + var rawConfig = ts.parseConfigFileTextToJson(configFilename, contents); if (rawConfig.error) { return { succeeded: false, error: rawConfig.error }; } else { - var parsedCommandLine = ts.parseConfigFile(rawConfig.config, this.host, dirPath); + var parsedCommandLine = ts.parseJsonConfigFileContent(rawConfig.config, this.host, dirPath); if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) { return { succeeded: false, error: { errorMsg: "tsconfig option errors" } }; } @@ -42561,26 +43187,28 @@ var ts; return error; } else { - var proj = this.createProject(configFilename, projectOptions); - for (var i = 0, len = projectOptions.files.length; i < len; i++) { - var rootFilename = projectOptions.files[i]; + var project = this.createProject(configFilename, projectOptions); + for (var _i = 0, _b = projectOptions.files; _i < _b.length; _i++) { + var rootFilename = _b[_i]; if (this.host.fileExists(rootFilename)) { var info = this.openFile(rootFilename, clientFileName == rootFilename); - proj.addRoot(info); + project.addRoot(info); } else { return { errorMsg: "specified file " + rootFilename + " not found" }; } } - proj.finishGraph(); - proj.projectFileWatcher = this.host.watchFile(configFilename, function (_) { return _this.watchedProjectConfigFileChanged(proj); }); - return { success: true, project: proj }; + project.finishGraph(); + project.projectFileWatcher = this.host.watchFile(configFilename, function (_) { return _this.watchedProjectConfigFileChanged(project); }); + this.log("Add recursive watcher for: " + ts.getDirectoryPath(configFilename)); + project.directoryWatcher = this.host.watchDirectory(ts.getDirectoryPath(configFilename), function (path) { return _this.directoryWatchedForSourceFilesChanged(project, path); }, true); + return { success: true, project: project }; } }; ProjectService.prototype.updateConfiguredProject = function (project) { if (!this.host.fileExists(project.projectFilename)) { this.log("Config file deleted"); - this.removeConfiguredProject(project); + this.removeProject(project); } else { var _a = this.configFileToProjectOptions(project.projectFilename), succeeded = _a.succeeded, projectOptions = _a.projectOptions, error = _a.error; @@ -42595,7 +43223,9 @@ var ts; for (var _i = 0; _i < fileNamesToRemove.length; _i++) { var fileName = fileNamesToRemove[_i]; var info = this.getScriptInfo(fileName); - project.removeRoot(info); + if (info) { + project.removeRoot(info); + } } for (var _b = 0; _b < fileNamesToAdd.length; _b++) { var fileName = fileNamesToAdd[_b]; @@ -42607,11 +43237,15 @@ var ts; if (info.isOpen) { if (this.openFileRoots.indexOf(info) >= 0) { this.openFileRoots = copyListRemovingItem(info, this.openFileRoots); + if (info.defaultProject && !info.defaultProject.isConfiguredProject()) { + this.removeProject(info.defaultProject); + } } if (this.openFilesReferenced.indexOf(info) >= 0) { this.openFilesReferenced = copyListRemovingItem(info, this.openFilesReferenced); } this.openFileRootsConfigured.push(info); + info.defaultProject = project; } } project.addRoot(info); @@ -42656,6 +43290,7 @@ var ts; TabSize: 4, NewLineCharacter: ts.sys ? ts.sys.newLine : '\n', ConvertTabsToSpaces: true, + IndentStyle: ts.IndentStyle.Smart, InsertSpaceAfterCommaDelimiter: true, InsertSpaceAfterSemicolonInForStatements: true, InsertSpaceBeforeAndAfterBinaryOperators: true, @@ -43496,8 +44131,6 @@ var ts; server.LineLeaf = LineLeaf; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); -/// -/// var ts; (function (ts) { var server; @@ -43573,79 +44206,6 @@ var ts; }; return Logger; })(); - var WatchedFileSet = (function () { - function WatchedFileSet(interval, chunkSize) { - if (interval === void 0) { interval = 2500; } - if (chunkSize === void 0) { chunkSize = 30; } - this.interval = interval; - this.chunkSize = chunkSize; - this.watchedFiles = []; - this.nextFileToCheck = 0; - } - WatchedFileSet.copyListRemovingItem = function (item, list) { - var copiedList = []; - for (var i = 0, len = list.length; i < len; i++) { - if (list[i] != item) { - copiedList.push(list[i]); - } - } - return copiedList; - }; - WatchedFileSet.getModifiedTime = function (fileName) { - return fs.statSync(fileName).mtime; - }; - WatchedFileSet.prototype.poll = function (checkedIndex) { - var watchedFile = this.watchedFiles[checkedIndex]; - if (!watchedFile) { - return; - } - fs.stat(watchedFile.fileName, function (err, stats) { - if (err) { - watchedFile.callback(watchedFile.fileName); - } - else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { - watchedFile.mtime = WatchedFileSet.getModifiedTime(watchedFile.fileName); - watchedFile.callback(watchedFile.fileName); - } - }); - }; - WatchedFileSet.prototype.startWatchTimer = function () { - var _this = this; - this.watchTimer = setInterval(function () { - var count = 0; - var nextToCheck = _this.nextFileToCheck; - var firstCheck = -1; - while ((count < _this.chunkSize) && (nextToCheck !== firstCheck)) { - _this.poll(nextToCheck); - if (firstCheck < 0) { - firstCheck = nextToCheck; - } - nextToCheck++; - if (nextToCheck === _this.watchedFiles.length) { - nextToCheck = 0; - } - count++; - } - _this.nextFileToCheck = nextToCheck; - }, this.interval); - }; - WatchedFileSet.prototype.addFile = function (fileName, callback) { - var file = { - fileName: fileName, - callback: callback, - mtime: WatchedFileSet.getModifiedTime(fileName) - }; - this.watchedFiles.push(file); - if (this.watchedFiles.length === 1) { - this.startWatchTimer(); - } - return file; - }; - WatchedFileSet.prototype.removeFile = function (file) { - this.watchedFiles = WatchedFileSet.copyListRemovingItem(file, this.watchedFiles); - }; - return WatchedFileSet; - })(); var IOSession = (function (_super) { __extends(IOSession, _super); function IOSession(host, logger) { @@ -43706,13 +44266,6 @@ var ts; return new Logger(fileName, detailLevel); } var logger = createLoggerFromEnv(); - var watchedFileSet = new WatchedFileSet(); - ts.sys.watchFile = function (fileName, callback) { - var watchedFile = watchedFileSet.addFile(fileName, callback); - return { - close: function () { return watchedFileSet.removeFile(watchedFile); } - }; - }; var ioSession = new IOSession(ts.sys, logger); process.on('uncaughtException', function (err) { ioSession.logError(err, "unknown"); @@ -43720,21 +44273,6 @@ var ts; ioSession.listen(); })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -/// var debugObjectHost = this; var ts; (function (ts) { @@ -44294,7 +44832,7 @@ var ts; var _this = this; return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { var text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()); - var result = ts.parseConfigFileText(fileName, text); + var result = ts.parseConfigFileTextToJson(fileName, text); if (result.error) { return { options: {}, @@ -44302,7 +44840,7 @@ var ts; errors: [realizeDiagnostic(result.error, '\r\n')] }; } - var configFile = ts.parseConfigFile(result.config, _this.host, ts.getDirectoryPath(ts.normalizeSlashes(fileName))); + var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(ts.normalizeSlashes(fileName))); return { options: configFile.options, files: configFile.fileNames, @@ -44387,4 +44925,4 @@ var TypeScript; Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; })(Services = TypeScript.Services || (TypeScript.Services = {})); })(TypeScript || (TypeScript = {})); -var toolsVersion = "1.6"; +var toolsVersion = "1.7";